[PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Sun May 8 11:57:56 PDT 2016


djasper added inline comments.

================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:63
@@ +62,3 @@
+    removeFromFoundDecls(Used->getCanonicalDecl());
+  } else if (const auto *DRE = Result.Nodes.getNodeAs<DeclRefExpr>("used")) {
+    if (const auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
----------------
Use early return here instead of "else".

================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:65
@@ +64,3 @@
+    if (const auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
+      if (const auto *FDT = FD->getPrimaryTemplate()) {
+        removeFromFoundDecls(FDT);
----------------
No braces for single statement ifs.

================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:68
@@ +67,3 @@
+      } else {
+        removeFromFoundDecls(FD);
+      }
----------------
Wouldn't you also want to do this via the canonical decl? Add a test.

================
Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:71
@@ +70,3 @@
+    } else if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+      removeFromFoundDecls(VD);
+    }
----------------
Would it be important to look at something like the canonical decl here? Can you add a test with a (static) class variable that is initialized out of line?

================
Comment at: test/clang-tidy/misc-unused-using-decls.cpp:60
@@ +59,3 @@
+  UsedFunc();
+  UsedTemplateFunc<int>();
+  cout << endl;
----------------
Can you add tests where variables and functions are solely referenced by pointers to members? Compare:
http://reviews.llvm.org/D20054


Repository:
  rL LLVM

http://reviews.llvm.org/D20018





More information about the cfe-commits mailing list