[clang-tools-extra] r243871 - Replace callback-if with isExpansionInMainFile as suggested in post

Daniel Jasper djasper at google.com
Mon Aug 3 03:52:27 PDT 2015


Author: djasper
Date: Mon Aug  3 05:52:27 2015
New Revision: 243871

URL: http://llvm.org/viewvc/llvm-project?rev=243871&view=rev
Log:
Replace callback-if with isExpansionInMainFile as suggested in post
commit review.

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp?rev=243871&r1=243870&r2=243871&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp Mon Aug  3 05:52:27 2015
@@ -22,17 +22,15 @@ const ast_matchers::internal::VariadicDy
     Decl, NamespaceAliasDecl> namespaceAliasDecl;
 
 void UnusedAliasDeclsCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(namespaceAliasDecl().bind("alias"), this);
+  // We cannot do anything about headers (yet), as the alias declarations
+  // used in one header could be used by some other translation unit.
+  Finder->addMatcher(namespaceAliasDecl(isExpansionInMainFile()).bind("alias"),
+                     this);
   Finder->addMatcher(nestedNameSpecifier().bind("nns"), this);
 }
 
 void UnusedAliasDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *AliasDecl = Result.Nodes.getNodeAs<Decl>("alias")) {
-    // We cannot do anything about headers (yet), as the alias declarations used
-    // in one header could be used by some other translation unit.
-    if (!Result.SourceManager->isInMainFile(AliasDecl->getLocation()))
-      return;
-
     FoundDecls[AliasDecl] = CharSourceRange::getCharRange(
         AliasDecl->getLocStart(),
         Lexer::findLocationAfterToken(





More information about the cfe-commits mailing list