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

Change the include directories for linked components to use SYSTEM includes rather than normal ones. (IDFGH-14015) #14838

Closed
BIGduzy opened this issue Nov 6, 2024 · 2 comments
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@BIGduzy
Copy link

BIGduzy commented Nov 6, 2024

Is your feature request related to a problem?

When using a language server such as clangd, the language server adds inline warning/error diagnostics to the code in your editor.
These language servers usually parse your compile_commands.json to figure out which files belong to your projects and which compiler flags you've used.
If a macro is imported by a header that is not included using -isystem rather than -I warnings stemming from the expanded macro will be shown in the file where the macro is used.

An example is that when you use clang-tidy, all ESP_LOG* macros will be highlighted with a warning for clang-tidy's avoid-do-while rule:
image

As an example, I want the rule enabled because our internal code standards require it, but I don't have to change vendor code so the warning is just useless/added noise.

Describe the solution you'd like.

I would appreciate it if esp-components (such as esp_log) would export their include directories as SYSTEM so that I don't get warnings from code I can't change in my own code.

Describe alternatives you've considered.

I've attempted to use CMake scripting to edit all include directories on the main target that starts with /opt/esp (my installation directory) so that they are removed from my target and re-added as a system include but couldn't get it to work.

Additional context.

No response

@BIGduzy BIGduzy added the Type: Feature Request Feature request for IDF label Nov 6, 2024
@github-actions github-actions bot changed the title Change the include directories for linked components to use SYSTEM includes rather than normal ones. Change the include directories for linked components to use SYSTEM includes rather than normal ones. (IDFGH-14015) Nov 6, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 6, 2024
@igrr
Copy link
Member

igrr commented Nov 6, 2024

@BIGduzy As an alternative solution, could you try excluding IDF root directory from analysis in clang-tidy?

If a macro is imported by a header that is not included using -isystem rather than -I warnings stemming from the expanded macro will be shown in the file where the macro is used.

I'm afraid that in some cases this can mask genuine errors.

Even in your case, technically you do get these do/while loops injected into your application code via macros, so the warning is probably justified? If your coding standard doesn't allow do/while loops you probably should create a wrapper function and call it instead of the macros IDF provides, then disable this check just for the file which defines the wrapper function.

@BIGduzy
Copy link
Author

BIGduzy commented Nov 7, 2024

Thank you for your reply @igrr. It seems we require a new clang version to exclude directories from clang-tidy. Which for now is not prioritized.

Wrapper functions would be a better solution perhaps, but it would require us to refactor the code we already have. For now I'll close the issue.
Thank you.

@BIGduzy BIGduzy closed this as completed Nov 7, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Won't Do This will not be worked on and removed Status: Opened Issue is new labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants