https://github.com/sam-mccall updated 
https://github.com/llvm/llvm-project/pull/66757

>From 1923a5142f9cbd3556bba599b611ae8a1bbec776 Mon Sep 17 00:00:00 2001
From: Sam McCall <sam.mcc...@gmail.com>
Date: Tue, 19 Sep 2023 12:16:54 +0200
Subject: [PATCH 1/2] [clangd] Allow --query-driver to match a dot-normalized
 form of the path

(In addition to the un-normalized form, so this is back-compatible)
---
 clang-tools-extra/clangd/SystemIncludeExtractor.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp 
b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
index 88df5b04ccb09f3..3f93927434dbfa8 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 whitelist, 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;
   }

>From de641152074d95aa8f83843543d6c486a98da908 Mon Sep 17 00:00:00 2001
From: Sam McCall <sam.mcc...@gmail.com>
Date: Tue, 19 Sep 2023 12:24:36 +0200
Subject: [PATCH 2/2] use allowlisted words

---
 clang-tools-extra/clangd/SystemIncludeExtractor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp 
b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
index 3f93927434dbfa8..74bae786425c829 100644
--- a/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ b/clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -345,7 +345,7 @@ extractSystemIncludesAndTarget(const DriverArgs &InputArgs,
 
   // If driver was "../foo" then having to allowlist "/path/a/../foo" rather
   // than "/path/foo" is absurd.
-  // Allow either to match the whitelist, then proceed with "/path/a/../foo".
+  // 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);

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to