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 not respecting -Wno-builtin-macro-redefined with gnu++20 #56709

Closed
barci2 opened this issue Jul 25, 2022 · 6 comments
Closed

clang-tidy not respecting -Wno-builtin-macro-redefined with gnu++20 #56709

barci2 opened this issue Jul 25, 2022 · 6 comments
Labels
clang-tidy confirmed Verified by a second party

Comments

@barci2
Copy link

barci2 commented Jul 25, 2022

If clang-tidy is set to use the gnu++20 language standard (does not work with regular c++ or lower versions of gnu++) then the -Wno-builtin-macro-redefined CDB flag is not respected, even if the macro is redefined as a compilation flag itself. Note that this is not an issue with the regular compiler as it does not throw that error. Minimal reproducer:
touch test.cc && llvm-project/build/bin/clang-tidy test.cc -- -std=gnu++20 -D__TIME__ -Wno-builtin-macro-redefined

@llvmbot
Copy link
Member

llvmbot commented Jul 25, 2022

@llvm/issue-subscribers-clang-tidy

@HappyCerberus
Copy link

Is there any workaround?

This just cropped up for me when using the Bazel module for clang-tidy integration: https://github.com/erenon/bazel_clang_tidy

@igormcoelho
Copy link

igormcoelho commented Dec 6, 2022

Just got into this error, with the same problem using https://github.com/erenon/bazel_clang_tidy.
The clang-tidy fix proposed there (erenon/bazel_clang_tidy#29) resolved this for me, putting this flag into .clang-tidy file: -clang-diagnostic-builtin-macro-redefined
So, maybe it's an issue of clang-tidy itself, not clang? Anyway, disabling this clang-tidy check resolved the issue for me.

@HappyCerberus
Copy link

So, maybe it's an issue of clang-tidy itself, not clang?

This is a clang-tidy bug report (nothing to do with clang).

@AaronBallman AaronBallman added the confirmed Verified by a second party label Dec 6, 2022
@AaronBallman
Copy link
Collaborator

Can confirm this issue: https://godbolt.org/z/ohq19e8Wq Clang silences the diagnostic and clang-tidy continues to issue it.

@PiotrZSL
Copy link
Member

Related to #61969

phlax pushed a commit to envoyproxy/envoy that referenced this issue Nov 28, 2024
Previously, `redefining builtin macro
[clang-diagnostic-builtin-macro-redefined,-warnings-as-errors]` was
reported
despite the existence of the `-Wno-builtin-macro-redefined` in the
compiler argument.
This is a known issue for older version of clang as in
* llvm/llvm-project#56709
* erenon/bazel_clang_tidy#29

The workaround discussed was to explicitly add
`-clang-diagnostic-builtin-macro-redefined`
in the checks of clang-tidy, which can be removed after we upgrade to
LLVM 17.

part of #28566 

Signed-off-by: Takeshi Yoneda <[email protected]>
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
Projects
None yet
Development

No branches or pull requests

7 participants