Currently check does not look into LinkageSpecDecl
when removing redundant variable re-declarations.
This were leaving code in non-compiling state.
Fix patch fixes this and adds removal also of 'extern C'.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp | ||
---|---|---|
84 | auto could be used because type is explicitly stated in same statement. |
Looks good, thanks for the fix! Do we think it's worth documenting in the Release Notes?
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp | ||
---|---|---|
86 | This can be removed, leaving it as: if (const auto *Extern = ... && !Extern->hasBraces()) | |
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-declaration.cpp | ||
126 | Typo: dummy I don't quite see why these are needed to test the example in PR42068? |
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-declaration.cpp | ||
---|---|---|
126 | I wasn't sure about getLocForEndOfToken, so just wanted to add some tokens before and after, to be 100% sure that they wont be removed. |
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp | ||
---|---|---|
86 | If you mean: if (const auto *Extern = Result.Nodes.getNodeAs<LinkageSpecDecl>("extern"); !Extern->hasBraces()) ` then no, it cannot be like this because Extern can be null. |
Looks great, thanks!
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp | ||
---|---|---|
86 | You are right, this can only be done when there's no other conditions in the if! |
auto could be used because type is explicitly stated in same statement.