[PATCH] D51041: [clang-tidy] Don't run misc-unused-using-decls check in C++17.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 22 00:57:53 PDT 2018


hokein updated this revision to Diff 161893.
hokein added a comment.

Remove redundant CPlusPlus2a.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51041

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls-cxx17.cpp


Index: test/clang-tidy/misc-unused-using-decls-cxx17.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/misc-unused-using-decls-cxx17.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- -fno-delayed-template-parsing -std=gnu++17
+
+namespace ns {
+template <typename K, typename V>
+class KV {
+public:
+  KV(K, V);
+};
+}
+
+using ns::KV;
+
+void f() {
+  KV(1, 2);
+}
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===================================================================
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -29,6 +29,11 @@
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
+  // FIXME: make the check support C++17 or later. The check relies on the fact
+  // that the used declarations are visited after the "using" declaration, but
+  // it is not ture in C++17's template argument deduction.
+  if (!getLangOpts().CPlusPlus || getLangOpts().CPlusPlus17)
+    return;
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(enumType(DeclMatcher)), this);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51041.161893.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180822/9b1669a1/attachment.bin>


More information about the cfe-commits mailing list