[PATCH] D142560: Allow getRawCommentForDecl to find comments in macros

Dana Jansens via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 08:56:52 PST 2023


danakj created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
danakj requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The key part of getRawCommentForDecl() required to find a comment
is determining where to look for it. The location of the decl
itself is usually right, except when macros get involved. The
comment in the macro is stored in RawCommentList at the spelling
location of the decl, not at the place where the decl comes into
being as the macro is instantiated.

getDeclLocForCommentSearch() already contained to branches to try
handle comments inside macros, and we are able to replace them
and handle more cases as well, by returning the spelling location
of the decl's begin location. That is:

  SourceMgr.getSpellingLoc(D->getBeginLoc())


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142560

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Index/annotate-comments-objc.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142560.492140.patch
Type: text/x-patch
Size: 5774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230125/74d98e6a/attachment-0001.bin>


More information about the cfe-commits mailing list