File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ UnusedUsingDeclsCheck::UnusedUsingDeclsCheck(StringRef Name,
5151 HeaderFileExtensions (Context->getHeaderFileExtensions ()) {}
5252
5353void UnusedUsingDeclsCheck::registerMatchers (MatchFinder *Finder) {
54+ // We don't emit warnings on unused-using-decls from headers, so bail out if
55+ // the main file is a header.
56+ if (utils::isFileExtension (getCurrentMainFile (), HeaderFileExtensions))
57+ return ;
5458 Finder->addMatcher (usingDecl (isExpansionInMainFile ()).bind (" using" ), this );
5559 auto DeclMatcher = hasDeclaration (namedDecl ().bind (" used" ));
5660 Finder->addMatcher (loc (templateSpecializationType (DeclMatcher)), this );
@@ -83,12 +87,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
8387void UnusedUsingDeclsCheck::check (const MatchFinder::MatchResult &Result) {
8488 if (Result.Context ->getDiagnostics ().hasUncompilableErrorOccurred ())
8589 return ;
86- // We don't emit warnings on unused-using-decls from headers, so bail out if
87- // the main file is a header.
88- if (auto MainFile = Result.SourceManager ->getFileEntryRefForID (
89- Result.SourceManager ->getMainFileID ());
90- utils::isFileExtension (MainFile->getName (), HeaderFileExtensions))
91- return ;
9290
9391 if (const auto *Using = Result.Nodes .getNodeAs <UsingDecl>(" using" )) {
9492 // Ignores using-declarations defined in macros.
You can’t perform that action at this time.
0 commit comments