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

[clang-tidy] readability-redundant-preprocessor false positive on builtin preprocessor checks #64825

Open
philnik777 opened this issue Aug 19, 2023 · 2 comments
Labels
clang-tidy confirmed Verified by a second party false-positive Warning fires when it should not

Comments

@philnik777
Copy link
Contributor

philnik777 commented Aug 19, 2023

#if __has_builtin(__remove_cvref)
#  if __has_cpp_attribute(no_unique_address)
#  endif
#endif

(Godbolt) generates

1 warning generated.
<source>:2:4: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
    2 | #  if __has_cpp_attribute(no_unique_address)
      |    ^
<source>:1:2: note: previous #if was here
    1 | #if __has_builtin(__remove_cvref)
      |  ^
1 warning generated.

which is obviously wrong.

@philnik777 philnik777 added clang-tidy false-positive Warning fires when it should not labels Aug 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Aug 19, 2023

@llvm/issue-subscribers-clang-tidy

@PiotrZSL PiotrZSL added the confirmed Verified by a second party label Aug 19, 2023
@PiotrZSL
Copy link
Member

What I found is that ConditionRange point to ')' character only, and we compare later ')' with ')', oryginal issue is probably somewhere in clang preprocessor, but still easiest fix would be simply to take as a begining of range a token after 'if'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy confirmed Verified by a second party false-positive Warning fires when it should not
Projects
None yet
Development

No branches or pull requests

3 participants