Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwbmwv opened this issue Mar 1, 2023 · 5 comments
Open

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

jwbmwv opened this issue Mar 1, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@jwbmwv
Copy link

jwbmwv commented Mar 1, 2023

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
Copy link
Collaborator

@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.

@jlonnberg jlonnberg self-assigned this Mar 8, 2023
@jlonnberg jlonnberg added the enhancement New feature or request label Mar 8, 2023
@jwbmwv
Copy link
Author

jwbmwv commented Mar 10, 2023

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
Copy link
Collaborator

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
Copy link

spoorcc commented Mar 13, 2023

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 microsoft/vscode-cpptools#7816 for details

@javari99
Copy link

javari99 commented Apr 9, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants