Author: fjahanian
Date: Wed Jul 24 17:58:51 2013
New Revision: 187085

URL: http://llvm.org/viewvc/llvm-project?rev=187085&view=rev
Log:
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

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=187085&r1=187084&r2=187085&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 24 17:58:51 2013
@@ -133,8 +133,14 @@ RawComment *ASTContext::getRawCommentFor
       isa<RedeclarableTemplateDecl>(D) ||
       isa<ClassTemplateSpecializationDecl>(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<TypedefDecl>(D))
+      DeclLoc = D->getLocStart();
+  }
 
   // If the declaration doesn't map directly to a location in a file, we
   // can't find the comment.

Modified: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp?rev=187085&r1=187084&r2=187085&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp (original)
+++ cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp Wed Jul 24 17:58:51 
2013
@@ -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=[<Function file="{{[^"]+}}comment-to-html-xml-conversion.cpp" 
line="[[@LINE-1]]" 
column="6"><Name>comment_to_xml_conversion_todo_4</Name><USR>c:@F@comment_to_xml_conversion_todo_4#</USR><Declaration>void
 comment_to_xml_conversion_todo_4()</Declaration><Abstract><Para> Aaa. 
</Para></Abstract><Discussion><Para kind="todo"> Bbb. </Para><Para kind="todo"> 
Ccc.</Para></Discussion></Function>]
 
+// 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
 


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to