================
@@ -179,103 +179,38 @@ static SourceLocation getDeclLocForCommentSearch(const 
Decl *D,
       isa<ClassTemplateSpecializationDecl>(D) ||
       // Allow association with Y across {} in `typedef struct X {} Y`.
       isa<TypedefDecl>(D))
-    return D->getBeginLoc();
+    return {D->getBeginLoc()};
----------------
bnbarham wrote:

Seems like this should also use the macro logic. In particular this has a `|| 
isa<TypedefDecl>(D)` and so the `TypedefDecl` case in `DeclLoc.isMacroID()` 
isn't actually used. Missing tests?

As far as I understand, the cases here are:
  - Use the beginning of the decl vs the identifier
  - Expansion + spelling of a macro for either of those locations if we're in a 
macro
  - Possibly something special for the NS_ENUM-like cases?

So we could instead do something like:
```
SmallVector<SourceLocation, 2> locations;
SourceLocation baseLocation;
if (isa<...>(D) || ...) {
  baseLocation = D->getBeginLoc();
} else {
  baseLocation = D->getLocation();
}

if (!DeclLoc.isMacroID()) {
  locations.emplace_back(baseLocation);
} else {
  // Maybe something special for the NS_ENUM case?
  locations.emplace_back(SourceMgr.getExpansionLoc(baseLocation), 
SourceMgr.getSpellingLoc(baseLocation));
}
```


https://github.com/llvm/llvm-project/pull/65481
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to