================ @@ -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; + } + } ---------------- zyn0217 wrote:
Probably, we could move the logic to the lambda and just let the lambda return a nullptr when we're sure that `CanUseCommentlessCache` is false. This could save up the bool variable, WDYT? (And you can also leave a FIXME here suggesting the algorithm could be improved in that `LastCheckedRedecl` would become useful again once we have traversed past the CanoncialDecl even if `CanUseCommentlessCache` is false.) https://github.com/llvm/llvm-project/pull/108475 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits