[clang-tidy] How to ignore predefined macro definitions?

Hi all,

For a portable C project using POSIX extensions I typically use a predefined
macro, usually passing -D_POSIX_C_SOURCE=200112L or similar to the command-
line through the build system.

When also using the readability-identifier-naming checker in clang-tidy, with
option readability-identifier-naming.MacroDefinitionCase set to UPPER_CASE,
the following warning is emitted, due to the underscore prefix.

error: invalid case style for macro definition '_POSIX_C_SOURCE' [readability-
identifier-naming,-warnings-as-errors]

Usually /* NOLINT */ or similar can be used to silence the error, but in this
case it it predefined, so this in not possible. It also appears that clang-
tidy's -header-filter and -line-filter cannot be used to resolve this.

Is there some other way to ignore only the _POSIX_C_SOURCE definition? Or
perhaps some way to get it to ignore definitions passed on the command-line?
The current "workaround" is disabling the entire readability-identifier-naming
check, which is a shame as I find it very useful.

Version: Clang 6.0.0, Debian stretch backports, x86_64.

Thanks in advance,

Melvin Vermeeren.

Hi all,

For a portable C project using POSIX extensions I typically use a predefined
macro, usually passing -D_POSIX_C_SOURCE=200112L or similar to the command-
line through the build system.

When also using the readability-identifier-naming checker in clang-tidy, with
option readability-identifier-naming.MacroDefinitionCase set to UPPER_CASE,
the following warning is emitted, due to the underscore prefix.

error: invalid case style for macro definition '_POSIX_C_SOURCE' [readability-
identifier-naming,-warnings-as-errors]

Just a thought:
https://clang.llvm.org/doxygen/SourceLocation_8h_source.html#l00108
clang::SourceLocation::isValid()
103 /// Return true if this is a valid SourceLocation object.
104 ///
105 /// Invalid SourceLocations are often used when events have no
corresponding
106 /// location in the source (e.g. a diagnostic is required for a
command line
107 /// option).
^ is that not being checked/honored before emitting the diagnostic?

Usually /* NOLINT */ or similar can be used to silence the error, but in this
case it it predefined, so this in not possible. It also appears that clang-
tidy's -header-filter and -line-filter cannot be used to resolve this.

Is there some other way to ignore only the _POSIX_C_SOURCE definition? Or
perhaps some way to get it to ignore definitions passed on the command-line?
The current "workaround" is disabling the entire readability-identifier-naming
check, which is a shame as I find it very useful.

Version: Clang 6.0.0, Debian stretch backports, x86_64.

Thanks in advance,

Melvin Vermeeren.

Roman.