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())
What was the original motivation for the PR here? Was it the DECLARE_FUNCTIONS case above?
For this case, personally I would expect that something like:
Is far more common than the test case here. To put another way, the previous
Seems more reasonable to me than the hardcoded macro-name check. Even NS_*-wise there's also NS_ERROR_ENUM, NS_TYPED_ENUM, NS_TYPED_EXTENSIBLE_ENUM, NS_CLOSED_ENUM.