[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
Tue Aug 21 08:17:36 PDT 2018
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added a subscriber: xazax.hun.
It introduces some false positives which are non-trivial to fix.
Ignore running the check in C++17.
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,12 @@
}
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 ||
+ getLangOpts().CPlusPlus2a)
+ 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.161728.patch
Type: text/x-patch
Size: 1292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180821/1293c2da/attachment.bin>
More information about the cfe-commits
mailing list