IARSystems / iar-vsc-build

Visual Studio Code extension for developing and building IAR projects
Mozilla Public License 2.0
38 stars 5 forks source link

Include paths not set up to use clang-tidy #40

Open jwbmwv opened 1 year ago

jwbmwv commented 1 year ago

I like to use clang-tidy as my static analysis tool inside VS Code. This extension does not initialize the include paths that are needed for it, or any other extension needing paths to work properly since the proper header files annot be found.

jlonnberg commented 1 year ago

@jwbmwv Hi, are you using a vscode-extension for Clang-Tidy and if so, which one? To me it seems like they typically work using a compilation database, much like the clangd extension. You can generate a compilation database using iarbuild and ninja but that will unfortunatly not be compatible with clang.

jwbmwv commented 1 year ago

I'm using notskm.clang-tidy

I have no proof, but it appears that iar-build does not expose the include paths in a manor that this extension and/or clang-tidy itself can consume. The result is a list of include errors in the Problems tab for every file I open. This makes me ignore the problem window and miss useful messages. I have not had problems.

This appears to happen with any extension of this sort that does not generate a c_cpp_properties.json file automatically. i.e. Microsoft's Embedded Tools when importing an STM32Cube project.

jlonnberg commented 1 year ago

Reading up on https://clang.llvm.org/extra/clang-tidy/ refers to the compilation database, from which the clang typically sources its information. I glanced through the source code for notskm.clangtidy and it support adding it supports adding options to the command line under clang-tidy.compilerArgs so you could possibly append the include paths there.

spoorcc commented 1 year ago

I successfully use clang-tidy with iar-build from the C/C++ Microsoft plugin, which has clang-tidy inside. It is possible to set this up in your settings / code workspace with:

"C_Cpp.codeAnalysis.clangTidy.enabled": true

You can exclude files with: "C_Cpp.codeAnalysis.exclude" : {"somefolder" : true}

and optionally run it automatically with

"C_Cpp.codeAnalysis.runAutomatically: true".

See https://github.com/microsoft/vscode-cpptools/pull/7816 for details

javari99 commented 5 months ago

Hello, I have been setting up clang-tidy using the c/c++ extension from vscode as @spoorcc suggested. The problem is that the extension is always trying to analyze the IAR compiler's standard lib source files and giving errors. How can I exclude such files?

Example message: "call to undeclared function '__iar_something'; ISO C99 and later do not support implicit function declarations"