llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Congcong Cai (HerrCai0907) <details> <summary>Changes</summary> skip header file before register AST Matchers it can avoid to matcher lots of ast node when lint header file --- Full diff: https://github.com/llvm/llvm-project/pull/123454.diff 1 Files Affected: - (modified) clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (+4-6) ``````````diff diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp index 1ff61bae46b1ed..ebf9e7c19ca842 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp @@ -50,6 +50,10 @@ UnusedUsingDeclsCheck::UnusedUsingDeclsCheck(StringRef Name, HeaderFileExtensions(Context->getHeaderFileExtensions()) {} void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) { + // We don't emit warnings on unused-using-decls from headers, so bail out if + // the main file is a header. + if (utils::isFileExtension(getCurrentMainFile(), HeaderFileExtensions)) + return; Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this); auto DeclMatcher = hasDeclaration(namedDecl().bind("used")); Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this); @@ -82,12 +86,6 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) { void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) { if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred()) return; - // We don't emit warnings on unused-using-decls from headers, so bail out if - // the main file is a header. - if (auto MainFile = Result.SourceManager->getFileEntryRefForID( - Result.SourceManager->getMainFileID()); - utils::isFileExtension(MainFile->getName(), HeaderFileExtensions)) - return; if (const auto *Using = Result.Nodes.getNodeAs<UsingDecl>("using")) { // Ignores using-declarations defined in macros. `````````` </details> https://github.com/llvm/llvm-project/pull/123454 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits