Skip to content

[llvm-config] Add new flag --quote-paths to optionally quote and escape paths #103397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aganea
Copy link
Member

@aganea aganea commented Aug 13, 2024

If any of the printed paths by llvm-config contain quotes, spaces, backslashes or dollar sign characters, these paths will be quoted and escaped, but only if using --quote-paths. The previous behavior is retained for compatibility and --quote-paths is there to acknowledge the migration to the new behavior.

Following discussion in #76304

Fixes #28117

Superseeds #97305

I could also do what @tothambrus11 suggests in #97305 (comment) but that makes all Windows paths quoted & escaped since they all contain backslashes.

If any of the printed paths by llvm-config contains quotes, spaces,
backslashes or dollar sign characters, these paths can be quoted if
using --quote-paths and the corresponding characters will be escaped.

Following discussion in llvm#76304

Fixes llvm#28117
@aganea aganea self-assigned this Aug 13, 2024
@aganea aganea removed their assignment Aug 13, 2024
Comment on lines 512 to 518
bool QuotePaths = false;
for (int i = 1; i != argc; ++i) {
if (StringRef(argv[i]) == "--quote-paths") {
QuotePaths = true;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do something like:

Suggested change
bool QuotePaths = false;
for (int i = 1; i != argc; ++i) {
if (StringRef(argv[i]) == "--quote-paths") {
QuotePaths = true;
break;
}
}
bool QuotePaths = std::any_of(&argv[0], &argv[argc], [](const char *arg) {
return StringRef(arg) == "--quote-paths";
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spaces in paths from llvm-config should be quoted
3 participants