From: Fariborz Jahanian Date: Wed, 24 Jul 2013 22:58:51 +0000 (+0000) Subject: Documentation parsing: if typedef name is being declared X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ceaa1ecfa3a8c2cd851bda94b135318e83ba560a;p=clang Documentation parsing: if typedef name is being declared via a macro, try using declaration's starting location. This is improvement over not having a valid location and dropping comment altogether. // rdar://14348912 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187085 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 8a252f8e73..8e7b13eff0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -133,8 +133,14 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const { isa(D) || isa(D)) DeclLoc = D->getLocStart(); - else + else { DeclLoc = D->getLocation(); + // If location of the typedef name is in a macro, it is because being + // declared via a macro. Try using declaration's starting location + // as the "declaration location". + if (DeclLoc.isMacroID() && isa(D)) + DeclLoc = D->getLocStart(); + } // If the declaration doesn't map directly to a location in a file, we // can't find the comment. diff --git a/test/Index/comment-to-html-xml-conversion.cpp b/test/Index/comment-to-html-xml-conversion.cpp index b70259ad12..ed25c503ae 100644 --- a/test/Index/comment-to-html-xml-conversion.cpp +++ b/test/Index/comment-to-html-xml-conversion.cpp @@ -811,5 +811,16 @@ void comment_to_xml_conversion_todo_3(); void comment_to_xml_conversion_todo_4(); // CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-1]]:6: FunctionDecl=comment_to_xml_conversion_todo_4:{{.*}} FullCommentAsXML=[comment_to_xml_conversion_todo_4c:@F@comment_to_xml_conversion_todo_4#void comment_to_xml_conversion_todo_4() Aaa. Bbb. Ccc.] +// rdar://14348912 +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type + +/**! Documentation comment */ +typedef NS_ENUM(int, Color) { Red, Green, Blue }; +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-1]]:22: TypedefDecl=Color:[[@LINE-1]]:22 +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[! Documentation comment ])))] + #endif