[cfe-commits] [PATCH] Find comment attached to any redeclaration

Douglas Gregor dgregor at apple.com
Tue Aug 7 16:43:50 PDT 2012


On Aug 7, 2012, at 4:37 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> Hello,
> 
> This patch changes the way we attach comments to declarations by not
> only looking at the declaration itself, but also walking the
> redeclaration chain: the previous declaration might have had a
> documentation comment.
> 
> Please review.


  RawComment *RC = NULL;
+  for (Decl::redecl_iterator I = D->redecls_begin(),
+                             E = D->redecls_end();
+       I != E; ++I) {
+    RC = getRawCommentForDeclNoCache(*I);
+    // If we found a comment, it should be a documentation comment.
+    assert(!RC || RC->isDocumentation());
+    if (RC)
+      break;
+  }

This uncached search seems a bit pessimistic. Why not peek into the cache for each of the redeclarations, to avoid repeatedly performing the unchanged search. Then, when we actually do find a raw comment attached to one of the declarations, update the cache for each of the redeclarations to point at that same raw comment?

	- Doug



More information about the cfe-commits mailing list