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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits