Author: Sam McCall Date: 2023-09-22T11:09:18+02:00 New Revision: 01d3045d1261c72abcf9cc1071be87434cf7086d
URL: https://github.com/llvm/llvm-project/commit/01d3045d1261c72abcf9cc1071be87434cf7086d DIFF: https://github.com/llvm/llvm-project/commit/01d3045d1261c72abcf9cc1071be87434cf7086d.diff LOG: [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) Added: Modified: clang-tools-extra/clangd/SystemIncludeExtractor.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp index 88df5b04ccb09f3..74bae786425c829 100644 --- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp +++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp @@ -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; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits