Skip to content

[clangd] Allow --query-driver to match a dot-normalized form of the path #66757

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

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clang-tools-extra/clangd/SystemIncludeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,13 @@ extractSystemIncludesAndTarget(const DriverArgs &InputArgs,
SPAN_ATTACH(Tracer, "driver", Driver);
SPAN_ATTACH(Tracer, "lang", InputArgs.Lang);

if (!QueryDriverRegex.match(Driver)) {
// If driver was "../foo" then having to allowlist "/path/a/../foo" rather
// than "/path/foo" is absurd.
// Allow either to match the allowlist, then proceed with "/path/a/../foo".
// This was our historical behavior, and it *could* resolve to something else.
llvm::SmallString<256> NoDots(Driver);
llvm::sys::path::remove_dots(NoDots, /*remove_dot_dot=*/true);
if (!QueryDriverRegex.match(Driver) && !QueryDriverRegex.match(NoDots)) {
vlog("System include extraction: not allowed driver {0}", Driver);
return std::nullopt;
}
Expand Down