diff --git a/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tidy/misc/UnusedUsingDeclsCheck.cpp index 8a70e16..5fbc041 100644 --- a/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ b/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -35,6 +35,10 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { const auto *TargetDecl = Using->shadow_begin()->getTargetDecl()->getCanonicalDecl(); + // Ignores using-declarations defined in macros. + if (TargetDecl->getLocation().isMacroID()) + return; + // Ignores using-declarations defined in class definition. if (isa(TargetDecl->getDeclContext())) return; diff --git a/test/clang-tidy/misc-unused-using-decls.cpp b/test/clang-tidy/misc-unused-using-decls.cpp index 47917a8..15538a8 100644 --- a/test/clang-tidy/misc-unused-using-decls.cpp +++ b/test/clang-tidy/misc-unused-using-decls.cpp @@ -70,6 +70,14 @@ using n::UnusedFunc; // UnusedFunc using n::cout; using n::endl; +#define DEFINE_INT(name) \ + namespace INT { \ + static const int _##name = 1; \ + } \ + using INT::_##name +DEFINE_INT(test); +#undef DEFIND_INT + // ----- Usages ----- void f(B b); void g() {