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 @@ -50,6 +50,10 @@ UnusedUsingDeclsCheck::UnusedUsingDeclsCheck(StringRef Name,
5050 HeaderFileExtensions (Context->getHeaderFileExtensions ()) {}
5151
5252void UnusedUsingDeclsCheck::registerMatchers (MatchFinder *Finder) {
53+ // We don't emit warnings on unused-using-decls from headers, so bail out if
54+ // the main file is a header.
55+ if (utils::isFileExtension (getCurrentMainFile (), HeaderFileExtensions))
56+ return ;
5357 Finder->addMatcher (usingDecl (isExpansionInMainFile ()).bind (" using" ), this );
5458 auto DeclMatcher = hasDeclaration (namedDecl ().bind (" used" ));
5559 Finder->addMatcher (loc (templateSpecializationType (DeclMatcher)), this );
@@ -82,12 +86,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
8286void UnusedUsingDeclsCheck::check (const MatchFinder::MatchResult &Result) {
8387 if (Result.Context ->getDiagnostics ().hasUncompilableErrorOccurred ())
8488 return ;
85- // We don't emit warnings on unused-using-decls from headers, so bail out if
86- // the main file is a header.
87- if (auto MainFile = Result.SourceManager ->getFileEntryRefForID (
88- Result.SourceManager ->getMainFileID ());
89- utils::isFileExtension (MainFile->getName (), HeaderFileExtensions))
90- return ;
9189
9290 if (const auto *Using = Result.Nodes .getNodeAs <UsingDecl>(" using" )) {
9391 // Ignores using-declarations defined in macros.
You can’t perform that action at this time.
0 commit comments