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,
51
51
HeaderFileExtensions (Context->getHeaderFileExtensions ()) {}
52
52
53
53
void 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 ;
54
58
Finder->addMatcher (usingDecl (isExpansionInMainFile ()).bind (" using" ), this );
55
59
auto DeclMatcher = hasDeclaration (namedDecl ().bind (" used" ));
56
60
Finder->addMatcher (loc (templateSpecializationType (DeclMatcher)), this );
@@ -83,12 +87,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
83
87
void UnusedUsingDeclsCheck::check (const MatchFinder::MatchResult &Result) {
84
88
if (Result.Context ->getDiagnostics ().hasUncompilableErrorOccurred ())
85
89
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 ;
92
90
93
91
if (const auto *Using = Result.Nodes .getNodeAs <UsingDecl>(" using" )) {
94
92
// Ignores using-declarations defined in macros.
You can’t perform that action at this time.
0 commit comments