diff options
author | Sam McCall <sam.mccall@gmail.com> | 2019-11-13 21:30:31 +0100 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-11-18 11:09:23 +0100 |
commit | a433e7141fb3f697e6430437ee73b19076603c1b (patch) | |
tree | dabfdb927350a788d2ed2df1d4da7778f3adebeb /clang/lib/AST/ASTContext.cpp | |
parent | 2d739f98d8a53e38bf9faa88cdb6b0c2a363fb77 (diff) | |
download | bcm5719-llvm-a433e7141fb3f697e6430437ee73b19076603c1b.tar.gz bcm5719-llvm-a433e7141fb3f697e6430437ee73b19076603c1b.zip |
[AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.
Summary:
Semantically they're the same thing, and it's important when the underlying
struct is anonymous.
There doesn't seem to be a problem attaching the same comment to multiple things
as it already happens with `/** doc */ int a, b;`
This affects an Index test but the results look better (name present, USR points
to the typedef).
Fixes https://github.com/clangd/clangd/issues/189
Reviewers: kadircet, lh123
Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70203
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cda51ec755a..6a15f99eb7d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -163,7 +163,9 @@ static SourceLocation getDeclLocForCommentSearch(const Decl *D, if (isa<ObjCMethodDecl>(D) || isa<ObjCContainerDecl>(D) || isa<ObjCPropertyDecl>(D) || isa<RedeclarableTemplateDecl>(D) || - isa<ClassTemplateSpecializationDecl>(D)) + isa<ClassTemplateSpecializationDecl>(D) || + // Allow association with Y across {} in `typedef struct X {} Y`. + isa<TypedefDecl>(D)) return D->getBeginLoc(); else { const SourceLocation DeclLoc = D->getLocation(); |