microsoft / microsoft/vscode-cpptools
C_Cpp.codeAnalysis.clangTidy.useBuildPath should work with CMake configuration
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
I use ms-vscode.cmake-tools and ms-vscode.cpptools and rely on the default behaviour as much as possible.
When running Code analysis on active file clang-tidy crashes. I can also call clang-tidy (even official clang-tidy-14) with all the arguments that the cpptools would pass and get a crash. It really looks like a clang-tidy bug. I tried to work around by passing compile_commands.json to clang-tidy.
Not sure how C_Cpp.codeAnalysis.clangTidy.useBuildPath is supposed to work.
Just having
"C_Cpp.codeAnalysis.clangTidy.useBuildPath": true
does not pass the -p option, it still passes build arguments after --. It seems I also have to set "C_Cpp.default.compileCommands".
"C_Cpp.default.compileCommands": "${command:cmake.buildDirectory}/compile_commands.json"
also does not work. It looks like C_Cpp.default.compileCommands does not support any substitutions, even ${workspaceFolder} does not work.
The only way I could make it work was something like
"cmake.copyCompileCommands": "/workspace/build/compile_commands.json",
"C_Cpp.default.compileCommands": "/workspace/build/compile_commands.json",
"C_Cpp.codeAnalysis.clangTidy.useBuildPath": true
With the first cmake.copyCompileCommands I copy the current configuration (I have multiple) to a stable location. This can be used by C_Cpp.default.compileCommands and the -p=/workspace/build/ is passed to clang-tidy.
Substitutions should be supported by C_Cpp.default.compileCommands.
Only setting C_Cpp.codeAnalysis.clangTidy.useBuildPath to true should be enough if ms-vscode.cmake-tools is the configuration provider and it has generated a compile_commands.json
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Lesen Sie die Behandlung von C_Cpp.codeAnalysis.clangTidy.useBuildPath und C_Cpp.default.compileCommands, und reproduzieren Sie anschließend das Problem mit dem CMake-Konfigurationsanbieter und seiner generierten compile_commands.json. Prüfen Sie, wie cmake.copyCompileCommands und ${command:cmake.buildDirectory} behandelt werden, und verifizieren Sie, dass useBuildPath funktioniert, ohne einen festen kopierten Pfad zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cmake, cpp, vscode
- Bereich
- build-system, developer-experience, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100