-
Notifications
You must be signed in to change notification settings - Fork 13.2k
[clang-tidy] NOLINT not working in macros in clang-tidy-14 (regression) #55134
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
Comments
It appears from the summary of this patch that the intention is for "clang-tidy [to] look at the line of macro invocation and every line of macro definition for a NOLINT comment." |
If anyone knows of a workaround for this (short of marking every use of the macro with |
@llvm/issue-subscribers-clang-tidy |
I encountered a similar issue with |
@firewave – interesting, thanks for the info! Did you ever find a solution/workaround? It looks like this issue is also specific to this check, and doesn't actually have anything to do with the macro having multiple lines – if I put the entire macro on one line the problem still occurs:
Either of the Other warnings can be suppressed as expected, even in multi-line macros, e.g. the
|
I am encountering similar issues with google-explicit-constructor when trying to update clang-tidy to 14 for pybind11: https://github.com/pybind/pybind11/blob/2e331308d38a521c087e7fc0cfee227cd29f3f71/include/pybind11/pytypes.h#L1029 . NOLINTS are ignored. Interestingly, the 'bugprone-macro-*' NOLINT comments seem to work fine. Even NOLINTBEGIN NOLINTEND do not work when used in the multiline macro. |
@paulaltin This implies the issue is not specific to this check, feel free to update the title. |
Checks known to have regressed in version 14:
Checks known to have regressed in version 13:
Checks that were not working before version 13/14:
|
@paulaltin I have confirmed that the 'google-explicit ctor' seems to have actually regressed in version 13 as well (at least the latest minor release of it). |
Thanks @Skylion007 – I've updated the comment above. |
I don't have that much experience in the clang-tidy code base, but trying to look around the codebase, I am bit suspicious of this commit: b9d9968, but I don't see anything obvious that changed in these checks that could have broken them between 12-13 and 13-14. I also noticed a lot of the other checks that are working have preprocessor callbacks. I am really not familiar with the codebase though so I am bit unsure where the regression is coming. Any thoughts @EugeneZelenko ? |
Looks like that commit was authored by @HighCommander4, perhaps they can help? |
Stepping through the code suggests that this loop iterates twice, and checks the line |
Looks to be a regression from 5da7c04, cc @salman-javed-nz |
The regression is caused by a change made in that patch to how the location to be checked is updated from one iteration of the loop to the next.
These two functions have slightly different behaviour, specifically in the case where I'm not sure why the patch made this change; it seems unrelated to the purpose of the patch. |
Thanks for the discovery. I'll see what I can do to fix this. From a brief initial look, it looks like @HighCommander4 is right on the money with the line of code he has isolated this issue to. There's a number of |
Thanks @HighCommander4 and @salman-javed-nz, really appreciate your quick responses and attention to this! |
Local branch amd-gfx 15127a3 Merged main:6f215ca680fd into amd-gfx:e4c95cb9a7ae Remote branch main 9ff4f2d [clang-tidy] Fix llvm#55134 (regression introduced by 5da7c04)
@paulaltin @salman-javed-nz Did we miss the opportunity for this to be backported in to the 14.x branch? |
5da7c04 introduced a regression in the NOLINT macro checking loop, replacing the call to `getImmediateExpansionRange().getBegin()` with `getImmediateMacroCallerLoc()`, which has similar but subtly different behaviour. The consequence is that NOLINTs cannot suppress diagnostics when they are attached to a token that came from a macro **argument**, rather than elsewhere in the macro expansion. Revert to pre-patch behaviour and add test cases to cover this issue. Differential Revision: https://reviews.llvm.org/D126138 (cherry picked from commit 9ff4f2d)
5da7c04 introduced a regression in the NOLINT macro checking loop, replacing the call to `getImmediateExpansionRange().getBegin()` with `getImmediateMacroCallerLoc()`, which has similar but subtly different behaviour. The consequence is that NOLINTs cannot suppress diagnostics when they are attached to a token that came from a macro **argument**, rather than elsewhere in the macro expansion. Revert to pre-patch behaviour and add test cases to cover this issue. Differential Revision: https://reviews.llvm.org/D126138 (cherry picked from commit 9ff4f2d)
5da7c04 introduced a regression in the NOLINT macro checking loop, replacing the call to `getImmediateExpansionRange().getBegin()` with `getImmediateMacroCallerLoc()`, which has similar but subtly different behaviour. The consequence is that NOLINTs cannot suppress diagnostics when they are attached to a token that came from a macro **argument**, rather than elsewhere in the macro expansion. Revert to pre-patch behaviour and add test cases to cover this issue. Differential Revision: https://reviews.llvm.org/D126138 (cherry picked from commit 9ff4f2d)
Clang-tidy version 13 generates no warnings for this code:
when invoked as:
Clang-tidy version 14 generates warnings on lines 7-9 when invoked the same way.
The text was updated successfully, but these errors were encountered: