[all-commits] [llvm/llvm-project] 8bb54d: Allow getRawCommentForDecl to find comments in macros

Dana Jansens via All-commits all-commits at lists.llvm.org
Thu Jan 26 01:13:13 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8bb54da5da3194b71b54f70c6cc55485cf2623b0
      https://github.com/llvm/llvm-project/commit/8bb54da5da3194b71b54f70c6cc55485cf2623b0
  Author: Dana Jansens <danakj at orodu.net>
  Date:   2023-01-26 (Thu, 26 Jan 2023)

  Changed paths:
    M clang/lib/AST/ASTContext.cpp
    M clang/test/Index/annotate-comments-objc.m

  Log Message:
  -----------
  Allow getRawCommentForDecl to find comments in macros

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())

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D142560




More information about the All-commits mailing list