Closed mumin16 closed 4 years ago
Does this happen if you run clang-tidy manually from the command line?
My main includes are in main.cpp. i want to check my submodule:
clang-tidy -checks="cppcoreguidelines-*" mysubmodule.hpp -- -Iinclude/
my command line is wrong?
I need more information.
.clang-tidy
file in the root of your project?
clang-tidy.checks
in .vscode/settings.json
?compile_commands.json
file in the root of your project?Hi! I thought of chiming in because I am having the same issue(I think). In a simple .h file, the extension says that cstdint
is not found. When I run from the command line:
clang-tidy src/game.h -p build/compile_commands.json
I get what I think the correct output: some errors, but not the missing standard include.
In my settings.json
I have:
"clang-tidy.buildPath": "build/compile_commands.json"
And in clang-tidy console in VS Code I see:
clang-tidy <path-to>/game.h --export-fixes=- -p="build/compile_commands.json"
[...]
error: 'cstdint' file not found [clang-diagnostic-error]
This last command also works from the command line. The problem with the extension disappears if I use the cmake-tools option to copy the compile_commands.json
file to the project root directory. So, in a way, the clang-tidy.buildPath
settings seems not to be working for me.
I don't see why the command would behave differently in the terminal vs through Node's execFile
or spawn
. What OS are you using?
Hi, I use Ubuntu 18.04.
I realized that yesterday I omitted probably the most important bit of information:
The extension logging ends with this:
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory ""./build/compile_commands.json""
No compilation database found in /home/astranieri/projects/cg_uttt/"./build/compile_commands.json" or any parent directory
I tried with both absolute and relative arguments. I know absolutely zero about javascript but maybe the arguments are not consumed correctly when you invoke the process? Some stripping of double quotes perhaps.
I stumbled across the same problem. It appears as if the extension setting "clang-tidy.buildPath" is being ignored. Maybe I have not set the path properly. What does the setting expect, when the file is located at "/build/compile_commands.json"?
The problem is the double quotes. To fix it, please remove the double quotes in line 37 from tidy.ts ->:
args.push(-p="${buildPath}"
);
I found this on line 30 of $HOME/.vscode-oss/extensions/notskm.clang-tidy-0.4.1/tidy.js
file and changed it to:
args.push(`-p=${buildPath}`);
did not change anything apparently.
UPDATE: replacing ${workspaceFolder}
with the full path in my "clang-tidy.buildPath": "${workspaceFolder}/build/compile_commands.json",
line, along with @knehez' suggestion fixed it for me
Clang-Tidy can't find my header files