[clang] [AST] Iterate redecls starting from the canonical one in getRawCommentsForAnyRedecl() (PR #108475)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 20:58:38 PDT 2024


================
@@ -440,14 +440,23 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl(
 
   // Any redeclarations of D that we haven't checked for comments yet?
   // We can't use DenseMap::iterator directly since it'd get invalid.
-  auto LastCheckedRedecl = [this, CanonicalD]() -> const Decl * {
-    return CommentlessRedeclChains.lookup(CanonicalD);
-  }();
+  const Decl *LastCheckedRedecl = CommentlessRedeclChains.lookup(CanonicalD);
+  bool CanUseCommentlessCache = false;
+  if (LastCheckedRedecl) {
+    for (auto *Redecl : CanonicalD->redecls()) {
+      if (Redecl == D) {
+        CanUseCommentlessCache = true;
+        break;
+      }
+      if (Redecl == LastCheckedRedecl)
+        break;
+    }
+  }
----------------
HighCommander4 wrote:

Done, thanks

https://github.com/llvm/llvm-project/pull/108475


More information about the cfe-commits mailing list