Closed
Description
Clang-tidy version 13 generates no warnings for this code:
#define CREATE_STRUCT(name) \
struct name { /* NOLINT */ \
int a = 0; \
int b; \
};
CREATE_STRUCT(X)
CREATE_STRUCT(Y)
CREATE_STRUCT(Z)
when invoked as:
clang-tidy-13 test.cpp -checks=cppcoreguidelines-pro-type-member-init
Clang-tidy version 14 generates warnings on lines 7-9 when invoked the same way.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
paulaltin commentedon Apr 27, 2022
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."
https://reviews.llvm.org/D24845
paulaltin commentedon Apr 27, 2022
If anyone knows of a workaround for this (short of marking every use of the macro with
NOLINT
), I would be very grateful. Adding NOLINT to every line that uses the macro isn't possible in my case, but I can modify the macro definition.llvmbot commentedon Apr 27, 2022
@llvm/issue-subscribers-clang-tidy
firewave commentedon Apr 27, 2022
I encountered a similar issue with
NOLINTNEXTLINE
quite a while ago - see #46511.paulaltin commentedon Apr 28, 2022
@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
NOLINTNEXTLINE
andNOLINT
comments were enough to suppress the warning in version 13, but neither works in version 14.Other warnings can be suppressed as expected, even in multi-line macros, e.g. the
NOLINT
comment here works to suppress thereadability-use-anyofallof
warning in both versions:[-][clang-tidy] NOLINT not working in multi-line macros in clang-tidy-14 (regression)[/-][+][clang-tidy] NOLINT does not suppress cppcoreguidelines-pro-type-member-init warnings in clang-tidy-14 (regression)[/+][-][clang-tidy] NOLINT does not suppress cppcoreguidelines-pro-type-member-init warnings in clang-tidy-14 (regression)[/-][+][clang-tidy] NOLINT does not suppress cppcoreguidelines-pro-type-member-init warnings in macros using clang-tidy-14 (regression)[/+]Skylion007 commentedon May 9, 2022
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.
Skylion007 commentedon May 9, 2022
@paulaltin This implies the issue is not specific to this check, feel free to update the title.
[-][clang-tidy] NOLINT does not suppress cppcoreguidelines-pro-type-member-init warnings in macros using clang-tidy-14 (regression)[/-][+][clang-tidy] NOLINT not working in macros in clang-tidy-14 (regression)[/+]paulaltin commentedon May 11, 2022
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:
Skylion007 commentedon May 11, 2022
@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).
31 remaining items