[PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu May 19 06:35:46 PDT 2016
alexfh requested changes to this revision.
This revision now requires changes to proceed.
================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:22
@@ +21,3 @@
+namespace {
+bool IsValidDecl(const Decl *TargetDecl) {
+ // Ignores using-declarations defined in macros.
----------------
This method assumes a rather non-trivial definition of "valid". Please add a comment what exactly this method does.
Also, static is preferred to anonymous namespaces for functions in LLVM style (http://llvm.org/docs/CodingStandards.html#anonymous-namespaces):
| ... make anonymous namespaces as small as possible, and only use them for class declarations. ...
================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:29
@@ +28,3 @@
+ if (isa<CXXRecordDecl>(TargetDecl->getDeclContext())) {
+ llvm::errs() << "context\n";
+ return false;
----------------
Debug output?
================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:102
@@ +101,3 @@
+ for (auto &Context : Contexts) {
+ if (Context.UsingTargetDecls.find(D->getCanonicalDecl()) !=
+ Context.UsingTargetDecls.end()) {
----------------
.count() for sets is as effective, but results in clearer code.
================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.h:39
@@ +38,3 @@
+ : FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+ std::set<const Decl *> UsingTargetDecls;
+ const UsingDecl *FoundUsingDecl;
----------------
`SmallPtrSet` should be more efficient here.
================
Comment at: test/clang-tidy/misc-unused-using-decls.cpp:86
@@ +85,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
----------------
Not for this patch, but it makes sense to remove trailing comments on deleted lines.
http://reviews.llvm.org/D20429
More information about the cfe-commits
mailing list