[clang] [clang-tools-extra] [Tooling] Resolve tool names from PATH in CommonOptionsParser (PR #213681)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 14 06:36:05 PDT 2026
https://github.com/zeyi2 updated https://github.com/llvm/llvm-project/pull/213681
>From 5ea820d09e4b0483ddfb304eb30f52481d1d7003 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Mon, 3 Aug 2026 22:09:08 +0800
Subject: [PATCH 1/2] [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;
>From 49b992dcc873db2ccac3435e50c85094ba9a391e Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Fri, 14 Aug 2026 21:35:37 +0800
Subject: [PATCH 2/2] update release notes
---
clang-tools-extra/docs/ReleaseNotes.md | 3 ---
clang/docs/ReleaseNotes.md | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md
index 47ac59f456a2a..4a4048c5f9637 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -94,9 +94,6 @@ infrastructure are described first, followed by tool-specific sections.
### Improvements to clang-tidy
-- Improved {program}`clang-tidy` by resolving tool names without a path in
- compilation databases through `PATH`.
-
- Improved {program}`check_clang_tidy.py` by adding support of
`-std=cXX-or-earlier` values, mirroring the existing `-std=cXX-or-later`.
New construct expands to the given standard and every earlier one.
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 9a19bb2f2d5c7..dc2d1ce3f5212 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -179,6 +179,9 @@ features cannot lower the translation-unit ABI level;
### Non-comprehensive list of changes in this release
+- Clang tools using `CommonOptionsParser` now resolve tool names without a
+ path in compilation databases through `PATH`.
+
- Clang now allows GNU computed `goto` extension in `constexpr` functions, matching the relaxed
`constexpr` function body rules introduced in C++23.
More information about the cfe-commits
mailing list