Open llvmbot opened 4 years ago
I'm moving this to clang->Tooling as this seems like the issue is in the tooling, all clang-tidy has done is expose this issue.
6 months later and this extremely major bug is still there. What's worse, this doesn't seem to happen on clang-tidy 6, but I saw it on 11.
This bug probably belongs in clang->Tooling as I suspect other clang-tools will also have this shortfall.
Of course CXX=$(realpath which clang++
) will not work, because it will resolve to clang instead of clang++, but the idea is to pass full path to CMake with actual installation directory.
CXX=$(realpath which clang++
)++
would work :)
Extended Description
I spent way too much time troubleshooting this, but it was not obvious at first why tidy is complaining.
Let's consider following example: Clang installed with official apt package, created symlink: /usr/bin/clang++ -> ../lib/llvm-10/bin/clang++
Now if you run CMake with clang++ as compiler everything will compile fine. And we have, following entry in compile_commands.json "command": "/usr/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp"
Run clang-tidy -p build main.cpp and it doesn't add /usr/lib/llvm-10/bin/../include/c++/v1 to include dirs... (and fails obviously)
But there is more, if we edit compile_commands.json (or run cmake with fullpath to compiler), so that we have: "command": "/usr/lib/llvm-10/bin/clang++ -stdlib=libc++ -o main.o -c main.cpp" it will work fine...
I can pass full path to cmake, CXX=$(realpath
which clang++
), and it will work, but this is clunky if you ask me. Especially if one have /usr/bin/c++ symlinked to clang++ and expect things to just work and don't want to manually resolve symlinks.--
I took quick look and Driver::getInstalledDir() if InstalledDir is empty, returns Dir, which is apparently invocation dir and doesn't resolve symlinks. And later is used and InstalledDir which obviously is wrong in case of symlink.