homebrew-core icon indicating copy to clipboard operation
homebrew-core copied to clipboard

clang-tidy broken with llvm v19.1.3

Open lukeshingles opened this issue 1 year ago • 20 comments

brew gist-logs <formula> link OR brew config AND brew doctor output

https://gist.github.com/lukeshingles/b1477f4b5eaf327af99940ec848213b4

Verification

  • [X] My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • [X] I ran brew update and am still able to reproduce my issue.
  • [X] I have resolved all warnings from brew doctor and that did not fix my problem.
  • [X] I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

clang-tidy is no longer finding system headers since the llvm 19.1.3 update (https://github.com/Homebrew/homebrew-core/pull/196094)

What happened (include all command output)?

$ clang-tidy helloworld.cpp
4 warnings and 1 error generated.
Error while processing /Users/luke/test/helloworld.cpp.
warning: -lunwind: 'linker' input unused [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib' [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib/c++' [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib/unwind' [clang-diagnostic-unused-command-line-argument]
helloworld.cpp:1:10: error: 'iostream' file not found [clang-diagnostic-error]
    1 | #include <iostream>
      |          ^~~~~~~~~~
Found compiler error(s).

What did you expect to happen?

Using llvm 19.1.2 formula, the output is:

$ clang-tidy helloworld.cpp
4 warnings generated.
warning: -lunwind: 'linker' input unused [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib' [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib/c++' [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '-L/opt/homebrew/opt/llvm/lib/unwind' [clang-diagnostic-unused-command-line-argument]

(Some warnings but no error finding <iostream>).

Step-by-step reproduction instructions (by running brew commands)

// helloworld.cpp
#include <iostream>

int main() {
  std::cout << "Hello World!";
  return 0;
}
pip install compiledb
compiledb make helloworld
clang-tidy helloworld.cpp

lukeshingles avatar Nov 01 '24 11:11 lukeshingles

I get the same errors when I run clang-tidy from pip (latest version is 19.1.0) when brew llvm 19.1.3 is installed.

lukeshingles avatar Nov 01 '24 12:11 lukeshingles

Oh, that's annoying. Looks like clang-tidy does not use Clang config files.

As a workaround, try

xcrun clang-tidy helloworld.cpp

carlocab avatar Nov 01 '24 17:11 carlocab

Similar problem, but with clang. With 19.1.3, clang can't find stuff like #include<string>.

Now I'll have to manually add --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk for things to work.

I wonder if this is as expected. Or what is the right way to fix this system-header-missing problem?

Congyuwang avatar Nov 02 '24 10:11 Congyuwang

For me, I didn’t have any problem compiling with clang++. Does my simple example compile?

lukeshingles avatar Nov 02 '24 10:11 lukeshingles

@Congyuwang, I can't reproduce your issue so I'll need to know:

  • the output of your brew config
  • the output of your brew doctor
  • the output of ls -la /Library/Developer/CommandLineTools
  • the exact steps needed to reproduce the failure you're seeing

carlocab avatar Nov 02 '24 12:11 carlocab

Looks like clang-tidy does not use Clang config files.

For the clang-tidy issue: looks like it's not resolving the config directory correctly:

$ /opt/homebrew/opt/llvm/bin/clang++ -v test.cpp
Homebrew clang version 19.1.3
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.3/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin23.cfg
System configuration file directory: /opt/homebrew/etc/clang
User configuration file directory: /Users/bo/.config/clang
 "/opt/homebrew/Cellar/llvm/19.1.3/bin/clang-19" -cc1 ...

$ /opt/homebrew/opt/llvm/bin/clang-tidy test.cpp
Homebrew clang version 19.1.3
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: 
System configuration file directory: ../../../../etc/clang
User configuration file directory: /Users/bo/.config/clang
ignoring nonexistent directory "../include/c++/v1"
ignoring nonexistent directory "/usr/include/c++/v1"
clang Invocation:
 "c++" "-cc1" ...

Bo98 avatar Nov 03 '24 01:11 Bo98

For the clang-tidy issue: looks like it's not resolving the config directory correctly:

This seems to be why:

InstalledDir:

It doesn't know where the driver is, so it can't resolve the path to the config file.

carlocab avatar Nov 03 '24 10:11 carlocab

For the clang-tidy issue: looks like it's not resolving the config directory correctly:

This seems to be why:

InstalledDir:

It doesn't know where the driver is, so it can't resolve the path to the config file.

would it work to use a custom prefix flag with path while building to fix issue?

xakep8 avatar Nov 06 '24 03:11 xakep8

would it work to use a custom prefix flag with path while building to fix issue?

Not quite, since InstalledDir is not populated by the build-time install prefix. For clang, this is populated here (and then printed here). clang-tidy needs to do something similar.

In any case, we also do set CMAKE_INSTALL_PREFIX when building, so not sure there is much more to do in that regard.

carlocab avatar Nov 06 '24 03:11 carlocab

LLVM is designed to be relocatable so it does not bake in install prefixes.

Bo98 avatar Nov 06 '24 05:11 Bo98

@Congyuwang, I think your issue should have been fixed by #197410. You'll need to brew update && brew reinstall llvm to pick up the fix. (Or do brew update && brew postinstall llvm if you're only doing native builds.)

carlocab avatar Nov 13 '24 01:11 carlocab

@carlocab Not working. Running the following

main.c

int main() {
    return 0;
}

build.sh

eval "$(brew shellenv)"
export LLD=${HOMEBREW_PREFIX}/opt/lld/bin/ld64.lld
export CC=${HOMEBREW_PREFIX}/opt/llvm/bin/clang
${CC} -O3 --target=arm64-apple-macosx10.14 -fuse-ld=${LLD} -o main main.c -v

Run ./build.sh

We get

Homebrew clang version 19.1.3
Target: arm64-apple-macosx10.14
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.3/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-macosx10.14.cfg
System configuration file directory: /opt/homebrew/etc/clang
User configuration file directory: /Users/congyuwang/.config/clang
 "/opt/homebrew/Cellar/llvm/19.1.3/bin/clang-19" -cc1 -triple arm64-apple-macosx10.14.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -dumpdir main- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -fdefine-target-os-macros -target-cpu apple-m1 -target-feature +zcm -target-feature +zcz -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -target-abi darwinpcs -debugger-tuning=lldb -fdebug-compilation-dir=/Users/congyuwang/Projects/CppProjects/brew-clang-debug -target-linker-version 1115.7.3 -v -fcoverage-compilation-dir=/Users/congyuwang/Projects/CppProjects/brew-clang-debug -resource-dir /opt/homebrew/Cellar/llvm/19.1.3/lib/clang/19 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include -internal-isystem /opt/homebrew/Cellar/llvm/19.1.3/lib/clang/19/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -O3 -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fmax-type-align=16 -fcolor-diagnostics -vectorize-loops -vectorize-slp -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/fc/bckw5h_s4c9fz9dlgltf7b840000gn/T/main-b0ef43.o -x c main.c
clang -cc1 version 19.1.3 based upon LLVM 19.1.3 default target arm64-apple-darwin24.1.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /opt/homebrew/Cellar/llvm/19.1.3/lib/clang/19/include
End of search list.
 "/opt/homebrew/opt/lld/bin/ld64.lld" -demangle -lto_library /opt/homebrew/Cellar/llvm/19.1.3/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 11.0.0 11.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -mllvm -enable-linkonceodr-outlining -o main /var/folders/fc/bckw5h_s4c9fz9dlgltf7b840000gn/T/main-b0ef43.o -lSystem /opt/homebrew/Cellar/llvm/19.1.3/lib/clang/19/lib/darwin/libclang_rt.osx.a
ld64.lld: error: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Seems like MacOSX10.14.sdk is not found.

However, specifying --sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk compiles successfully.

Congyuwang avatar Nov 13 '24 10:11 Congyuwang

❯ ls /Library/Developer/CommandLineTools/SDKs/
MacOSX.sdk     MacOSX12.1.sdk MacOSX12.3.sdk MacOSX14.5.sdk MacOSX14.sdk   MacOSX15.1.sdk MacOSX15.sdk

I only have the above. MacOS 15.1, Xcode 16.1. There is no MacOSX10.14.sdk.

Whereas we have

❯ cat /opt/homebrew/etc/clang/arm64-apple-macosx10.14.cfg
--sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

Congyuwang avatar Nov 13 '24 10:11 Congyuwang

@Congyuwang, don't use --target. Use -mmacos-version-min. See discussion at #197532.

carlocab avatar Nov 13 '24 10:11 carlocab

@Congyuwang, don't use --target. Use -mmacos-version-min. See discussion at #197532.

I must say that this maybe the correct way to go. But I didn’t add the target flag myself, but it is added by some (I need further investigation to see) upstream dependencies. So this incorrect use of target for the purpose can be quite common.

Congyuwang avatar Nov 13 '24 11:11 Congyuwang

The missing InstalledDir might be a red herring. That can be fixed with:

Patch
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index af18194ae0fe..493d9657f988 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -251,18 +251,16 @@ static bool stripPositionalArgs(std::vector<const char *> Args,
       IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
       &*DiagOpts, &DiagClient, false);
 
-  // The clang executable path isn't required since the jobs the driver builds
-  // will not be executed.
-  std::unique_ptr<driver::Driver> NewDriver(new driver::Driver(
-      /* ClangExecutable= */ "", llvm::sys::getDefaultTargetTriple(),
-      Diagnostics));
-  NewDriver->setCheckInputsExist(false);
-
   // This becomes the new argv[0]. The value is used to detect libc++ include
   // dirs on Mac, it isn't used for other platforms.
   std::string Argv0 = GetClangToolCommand();
   Args.insert(Args.begin(), Argv0.c_str());
 
+  std::unique_ptr<driver::Driver> NewDriver(new driver::Driver(
+      Argv0, llvm::sys::getDefaultTargetTriple(),
+      Diagnostics));
+  NewDriver->setCheckInputsExist(false);
+
   // By adding -c, we force the driver to treat compilation as the last phase.
   // It will then issue warnings via Diagnostics about un-used options that
   // would have been used for linking. If the user provided a compiler name as

Unfortunately, this produces different errors, and doesn't seem to change the include path:

clang-tidy helloworld.cpp -- -v
❯ ~LLVM/build/bin/clang-tidy helloworld.cpp -- -v
clang version 20.0.0git (https://github.com/llvm/llvm-project.git c4d656a4e992648f3490536336c230041c74dc38)
Target: arm64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Users/carlocab/github/llvm-project/build/bin
Build config: +assertions
Configuration file: /Users/carlocab/github/llvm-project/build/etc/clang/arm64-apple-darwin24.1.0.cfg
System configuration file directory: /Users/carlocab/github/llvm-project/build/etc/clang
User configuration file directory: /Users/carlocab/.config/clang
clang version 20.0.0git (https://github.com/llvm/llvm-project.git c4d656a4e992648f3490536336c230041c74dc38)
Target: arm64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Users/carlocab/github/llvm-project/build/bin
Build config: +assertions
Configuration file: /Users/carlocab/github/llvm-project/build/etc/clang/arm64-apple-darwin24.1.0.cfg
System configuration file directory: /Users/carlocab/github/llvm-project/build/etc/clang
User configuration file directory: /Users/carlocab/.config/clang
clang Invocation:
 "/Users/carlocab/github/llvm-project/build/bin/clang-tool" "-cc1" "-triple" "arm64-apple-macosx15.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-fsyntax-only" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "helloworld.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-fbuiltin-headers-in-system-modules" "-fdefine-target-os-macros" "-target-cpu" "apple-m1" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+v8.4a" "-target-feature" "+aes" "-target-feature" "+altnzcv" "-target-feature" "+ccdp" "-target-feature" "+ccpp" "-target-feature" "+complxnum" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+flagm" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" "-target-feature" "+fptoint" "-target-feature" "+fullfp16" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+neon" "-target-feature" "+pauth" "-target-feature" "+perfmon" "-target-feature" "+predres" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sb" "-target-feature" "+sha2" "-target-feature" "+sha3" "-target-feature" "+specrestrict" "-target-feature" "+ssbs" "-target-abi" "darwinpcs" "-debugger-tuning=lldb" "-fdebug-compilation-dir=/tmp/clang-tidy-cpp" "-target-linker-version" "1115.7.3" "-v" "-fcoverage-compilation-dir=/tmp/clang-tidy-cpp" "-resource-dir" "/Users/carlocab/github/llvm-project/build/lib/clang/20" "-internal-isystem" "/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/Users/carlocab/github/llvm-project/build/lib/clang/20/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fmax-type-align=16" "-fcolor-diagnostics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c++" "/tmp/clang-tidy-cpp/helloworld.cpp"

clang -cc1 version 20.0.0git based upon LLVM 20.0.0git default target arm64-apple-darwin24.1.0
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory "/System/Library/SubFrameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/carlocab/github/llvm-project/build/bin/../include/c++/v1
 /Users/carlocab/github/llvm-project/build/lib/clang/20/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
8 errors generated.
Error while processing /tmp/clang-tidy-cpp/helloworld.cpp.
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/__locale_dir/support/bsd_like.h:21:10: error: 'time.h' file not found [clang-diagnostic-error]
   21 | #include <time.h>
      |          ^~~~~~~~
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/__mbstate_t.h:51:4: error: "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform." [clang-diagnostic-error]
   51 | #  error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
      |    ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/stdlib.h:143:30: error: unknown type name 'ldiv_t' [clang-diagnostic-error]
  143 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
      |                              ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/stdlib.h:143:82: error: no member named 'ldiv' in the global namespace [clang-diagnostic-error]
  143 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); }
      |                                                                                ~~^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/stdlib.h:145:30: error: unknown type name 'lldiv_t' [clang-diagnostic-error]
  145 | inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
      |                              ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/stdlib.h:145:93: error: no member named 'lldiv' in the global namespace [clang-diagnostic-error]
  145 | inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); }
      |                                                                                           ~~^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/string.h:94:102: error: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]
   94 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
      |                                                                                                      ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/__cstddef/size_t.h:20:7: note: 'std::size_t' declared here
   20 | using size_t = decltype(sizeof(int));
      |       ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/string.h:97:90: error: unknown type name 'size_t'; did you mean 'std::size_t'? [clang-diagnostic-error]
   97 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
      |                                                                                          ^
/Users/carlocab/github/llvm-project/build/bin/../include/c++/v1/__cstddef/size_t.h:20:7: note: 'std::size_t' declared here
   20 | using size_t = decltype(sizeof(int));
      |       ^
Found compiler error(s).

Weirdly enough, dropping the -v flag produces the original error:

clang-tidy helloworld.cpp
❯ ~LLVM/build/bin/clang-tidy helloworld.cpp
1 error generated.
Error while processing /tmp/clang-tidy-cpp/helloworld.cpp.
helloworld.cpp:2:10: error: 'iostream' file not found [clang-diagnostic-error]
    2 | #include <iostream>
      |          ^~~~~~~~~~
Found compiler error(s).

But the source of all these errors should be the same.

carlocab avatar Nov 24 '24 14:11 carlocab

Ah, that'll be because the config files aren't loaded until https://github.com/llvm/llvm-project/blob/0c21ed48f40b2a6e3aa7e5d1873cf2455e847786/clang/lib/Driver/Driver.cpp#L1249-L1256.

Edit: No, I don't think that's it, since BuildCompilation is later called at https://github.com/llvm/llvm-project/blob/0c21ed48f40b2a6e3aa7e5d1873cf2455e847786/clang/lib/Tooling/CompilationDatabase.cpp#L283. Not sure what's wrong then.

carlocab avatar Nov 24 '24 14:11 carlocab

Ah, wait. I forgot to add the right config file in the configured location. If I create one with the appropriate --sysroot flag, doing

path/to/clang-tidy helloworld.cpp -- -v

succeeds. But dropping the -- -v doesn't. Not really sure why passing the extra flags changes clang-tidy's behaviour here, but... 🤷

carlocab avatar Nov 25 '24 12:11 carlocab

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Dec 16 '24 21:12 github-actions[bot]

Edit: No, I don't think that's it, since BuildCompilation is later called at https://github.com/llvm/llvm-project/blob/0c21ed48f40b2a6e3aa7e5d1873cf2455e847786/clang/lib/Tooling/CompilationDatabase.cpp#L283. Not sure what's wrong then.

But dropping the -- -v doesn't. Not really sure why passing the extra flags changes clang-tidy's behaviour here, but... 🤷

Wouldn't this be impacted by -- handling https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/clang/lib/Tooling/CompilationDatabase.cpp#L332-L334

  const char *const *DoubleDash = std::find(Argv, Argv + Argc, StringRef("--"));
  if (DoubleDash == Argv + Argc)
    return nullptr;

Even just appending -- seems to work:

❯ clang-tidy helloworld.cpp -- && echo $?
0

cho-m avatar Feb 13 '25 18:02 cho-m