[PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration
Daniel Marjamäki via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 16 04:22:44 PDT 2016
danielmarjamaki added a comment.
For information, I am testing this on debian packages right now. I will see the results next week.
================
Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:22
@@ +21,3 @@
+void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+ // FIXME: Add matchers.
+ Finder->addMatcher(varDecl().bind("Decl"), this);
----------------
I forgot to remove this FIXME comment, I will remove it.
================
Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:41
@@ +40,3 @@
+
+ // Don't generate fixits for multivariable declarations.
+ bool MultiVar = false;
----------------
Imho this is a clumpsy way to see if it's a "multivariable" declaration. Do you know if there is a better way?
================
Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:50
@@ +49,3 @@
+
+ if (MultiVar) {
+ diag(VD->getLocation(), "redundant variable %0 declaration")
----------------
Is there a better way to rewrite this ... I tried something like this without success:
```
auto D = diag(..);
if (!MultiVar)
D << FixItHint..;
```
================
Comment at: clang-tidy/readability/RedundantDeclarationCheck.h:19
@@ +18,3 @@
+
+/// FIXME: Write a short description.
+///
----------------
I will fix this FIXME.
================
Comment at: test/clang-tidy/readability-redundant-declaration.cpp:11
@@ +10,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant variable A declaration
+// CHECK-FIXES: {{^}}extern int A,B;{{$}}
+
----------------
Ideally this would be changed to "extern int B;". I currently don't fix multivariable declarations.
https://reviews.llvm.org/D24656
More information about the cfe-commits
mailing list