Skip to content

[clang-tidy] readability-use-concise-preprocessor-directives, take consistency into account #155680

@carlosgalvezp

Description

@carlosgalvezp

Consider this example:

#if defined(FOO)  // warning: use #ifdef instead
int x;
#elif defined(BAR)  // but it becomes inconsistent with this one
int y;
#else
int z;
#endif

Here we use if defined because we don't have elifdef until C++23, so we want to keep consistency. However the check warns about it.

Not sure how difficult it would be to implement or if it's worth at all, but would be nice if the check was smart enough to understand this use case (possibly under an option). Otherwise if we think it's too niche of a use case I can just close this and NOLINT it :)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions