https://github.com/zeyi2 created 
https://github.com/llvm/llvm-project/pull/213681

None

>From 5ea820d09e4b0483ddfb304eb30f52481d1d7003 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <[email protected]>
Date: Mon, 3 Aug 2026 22:09:08 +0800
Subject: [PATCH] [Tooling] Resolve tool names from PATH in CommonOptionsParser

---
 clang-tools-extra/docs/ReleaseNotes.rst               | 3 +++
 clang/lib/Tooling/CommonOptionsParser.cpp             | 1 +
 clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp | 5 +++++
 3 files changed, 9 insertions(+)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 9a5a23f3d8542..df0b3df12708e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@ Improvements to clang-query
 Improvements to clang-tidy
 --------------------------
 
+- Improved :program:`clang-tidy` by resolving tool names without a path in
+  compilation databases through ``PATH``.
+
 New checks
 ^^^^^^^^^^
 
diff --git a/clang/lib/Tooling/CommonOptionsParser.cpp 
b/clang/lib/Tooling/CommonOptionsParser.cpp
index c8c3ca98323e2..454e7ca68a65f 100644
--- a/clang/lib/Tooling/CommonOptionsParser.cpp
+++ b/clang/lib/Tooling/CommonOptionsParser.cpp
@@ -139,6 +139,7 @@ llvm::Error CommonOptionsParser::init(
           new FixedCompilationDatabase(".", std::vector<std::string>()));
     }
   }
+  Compilations = inferToolLocation(std::move(Compilations));
   auto AdjustingCompilations =
       std::make_unique<ArgumentsAdjustingCompilations>(
           std::move(Compilations));
diff --git a/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp 
b/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp
index 7a801a2814402..bcee5ad949fbe 100644
--- a/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp
+++ b/clang/test/Tooling/clang-check-mac-libcxx-relpath.cpp
@@ -12,6 +12,11 @@
 // RUN: cp "%s" "%t/test.cpp"
 // clang-check will produce an error code if the mock library is not found.
 // RUN: clang-check -p "%t" "%t/test.cpp"
+//
+// Resolve a driver without a path through PATH.
+// RUN: chmod +x %t/mock-libcxx/bin/clang
+// RUN: echo '[{"directory":"%t","command":"clang -stdlib=libc++ -target 
x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > 
%t/compile_commands.json
+// RUN: env "PATH=%t/mock-libcxx/bin%{pathsep}%PATH%" clang-check -p "%t" 
"%t/test.cpp"
 
 #include <mock_vector>
 vector v;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to