llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: Paul Kirth (ilovepi)

<details>
<summary>Changes</summary>

In Fuchsia, we have several files that take over 2 hours for this check to run, 
where as it only takes 8 seconds to finish without the RedundantTypenameCheck.  
We can avoid this exponential behavior by limiting the use of hasAncestor to 
typeLocs for the types that are actually used in the checking logic.

With this patch, the wall time for the check with --enable-profile goes from 
6724 seconds (about 2 hours) to down to a reasonable 0.1753 seconds.

---
Full diff: https://github.com/llvm/llvm-project/pull/170540.diff


1 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp (+7-3) 


``````````diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
index 5f2519ce9d5c3..f8e576e2a14d7 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
@@ -18,9 +18,13 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::readability {
 
 void RedundantTypenameCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(typeLoc(unless(hasAncestor(decl(isInstantiated()))))
-                         .bind("nonDependentTypeLoc"),
-                     this);
+  Finder->addMatcher(
+      typeLoc(loc(TypeMatcher(anyOf(typedefType(), tagType(),
+                                    deducedTemplateSpecializationType(),
+                                    templateSpecializationType()))),
+              unless(hasAncestor(decl(isInstantiated()))))
+          .bind("nonDependentTypeLoc"),
+      this);
 
   if (!getLangOpts().CPlusPlus20)
     return;

``````````

</details>


https://github.com/llvm/llvm-project/pull/170540
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to