Skip to content

Commit 01d3045

Browse files
authored
[clangd] Allow --query-driver to match a dot-normalized form of the path (#66757)
(In addition to the un-normalized form, so this is back-compatible)
1 parent fe7fe6d commit 01d3045

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clang-tools-extra/clangd/SystemIncludeExtractor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,13 @@ extractSystemIncludesAndTarget(const DriverArgs &InputArgs,
343343
SPAN_ATTACH(Tracer, "driver", Driver);
344344
SPAN_ATTACH(Tracer, "lang", InputArgs.Lang);
345345

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

0 commit comments

Comments
 (0)