[clang] [clang] Prioritze decl comments from macro expansion site (PR #65481)

Ben Barham via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 15:16:27 PDT 2023


================
@@ -592,19 +524,22 @@ void ASTContext::attachCommentsToJustParsedDecls(ArrayRef<Decl *> Decls,
 
     D = &adjustDeclToTemplate(*D);
 
-    const SourceLocation DeclLoc = getDeclLocForCommentSearch(D, SourceMgr);
+    const auto DeclLocs = getDeclLocsForCommentSearch(D, SourceMgr);
 
-    if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
-      continue;
+    for (const auto DeclLoc : DeclLocs) {
+      if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
+        continue;
 
-    if (DeclRawComments.count(D) > 0)
-      continue;
+      if (DeclRawComments.count(D) > 0)
+        continue;
----------------
bnbarham wrote:

This can be pulled out of the loop

https://github.com/llvm/llvm-project/pull/65481


More information about the cfe-commits mailing list