From: Dmitri Gribenko Date: Sat, 22 Jun 2013 23:03:37 +0000 (+0000) Subject: Comment parsing: followup to r184610: allow multiple \returns X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97e5bc2643dd1478ca10d1b9a6581f332801c958;p=clang Comment parsing: followup to r184610: allow multiple \returns Remove unneeded member in CommentSema, add a test for the XML schema (the schema already allowed multiple paragraphs in , but there were no tests for that), fix HTML generation (it is not allowed to have

inside

). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184652 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 753cae3e81..21d3add0ef 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -58,9 +58,6 @@ class Sema { /// AST node for the \\brief command and its aliases. const BlockCommandComment *BriefCommand; - /// AST node for the \\returns command and its aliases. - const BlockCommandComment *ReturnsCommand; - /// AST node for the \\headerfile command. const BlockCommandComment *HeaderfileCommand; diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 12b4876e30..00e47225c9 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -29,8 +29,7 @@ Sema::Sema(llvm::BumpPtrAllocator &Allocator, const SourceManager &SourceMgr, DiagnosticsEngine &Diags, CommandTraits &Traits, const Preprocessor *PP) : Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags), Traits(Traits), - PP(PP), ThisDeclInfo(NULL), BriefCommand(NULL), ReturnsCommand(NULL), - HeaderfileCommand(NULL) { + PP(PP), ThisDeclInfo(NULL), BriefCommand(NULL), HeaderfileCommand(NULL) { } void Sema::setDecl(const Decl *D) { @@ -623,11 +622,6 @@ void Sema::checkBlockCommandDuplicate(const BlockCommandComment *Command) { return; } PrevCommand = BriefCommand; - } else if (Info->IsReturnsCommand) { - if (!ReturnsCommand) - ReturnsCommand = Command; - PrevCommand = ReturnsCommand; - return; } else if (Info->IsHeaderfileCommand) { if (!HeaderfileCommand) { HeaderfileCommand = Command; diff --git a/test/Index/Inputs/CommentXML/valid-function-07.xml b/test/Index/Inputs/CommentXML/valid-function-07.xml index 89b8a0ca6f..9ff2f63d85 100644 --- a/test/Index/Inputs/CommentXML/valid-function-07.xml +++ b/test/Index/Inputs/CommentXML/valid-function-07.xml @@ -21,10 +21,13 @@ Ddd -Eee. - + + Eee. Fff - Ggg + + + Ggg + Hhh diff --git a/test/Index/comment-to-html-xml-conversion.cpp b/test/Index/comment-to-html-xml-conversion.cpp index 590643590f..78fd793deb 100644 --- a/test/Index/comment-to-html-xml-conversion.cpp +++ b/test/Index/comment-to-html-xml-conversion.cpp @@ -116,7 +116,7 @@ void comment_to_html_conversion_6(); /// \return Bbb. void comment_to_html_conversion_7(); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_7:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_7c:@F@comment_to_html_conversion_7#void comment_to_html_conversion_7() Aaa. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_7:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_7c:@F@comment_to_html_conversion_7#void comment_to_html_conversion_7() Aaa. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment @@ -133,7 +133,7 @@ void comment_to_html_conversion_7(); /// \returns Bbb. void comment_to_html_conversion_8(); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_8:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_8c:@F@comment_to_html_conversion_8#void comment_to_html_conversion_8() Aaa. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_8:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_8c:@F@comment_to_html_conversion_8#void comment_to_html_conversion_8() Aaa. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph @@ -149,7 +149,7 @@ void comment_to_html_conversion_8(); /// \result Bbb. void comment_to_html_conversion_9(); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_9:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_9c:@F@comment_to_html_conversion_9#void comment_to_html_conversion_9() Aaa. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_9:{{.*}} FullCommentAsHTML=[

Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_9c:@F@comment_to_html_conversion_9#void comment_to_html_conversion_9() Aaa. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph @@ -164,7 +164,7 @@ void comment_to_html_conversion_9(); /// \returns Bbb. void comment_to_html_conversion_10(); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_10:{{.*}} FullCommentAsHTML=[

Returns Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_10c:@F@comment_to_html_conversion_10#void comment_to_html_conversion_10() Aaa. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_10:{{.*}} FullCommentAsHTML=[

Returns Aaa.

Returns Bbb.

] FullCommentAsXML=[comment_to_html_conversion_10c:@F@comment_to_html_conversion_10#void comment_to_html_conversion_10() Aaa. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph IsWhitespace @@ -184,7 +184,7 @@ void comment_to_html_conversion_10(); /// \returns Ccc. void comment_to_html_conversion_11(); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_11:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

Returns Ccc.

] FullCommentAsXML=[comment_to_html_conversion_11c:@F@comment_to_html_conversion_11#void comment_to_html_conversion_11() Aaa. Ccc. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_11:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

Returns Ccc.

] FullCommentAsXML=[comment_to_html_conversion_11c:@F@comment_to_html_conversion_11#void comment_to_html_conversion_11() Aaa. Ccc. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph @@ -388,7 +388,7 @@ void comment_to_html_conversion_21(); /// \returns Eee. void comment_to_html_conversion_22(int x1, int x2); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_22:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

x1
Ccc.
x2
Ddd.

Returns Eee.

] FullCommentAsXML=[comment_to_html_conversion_22c:@F@comment_to_html_conversion_22#I#I#void comment_to_html_conversion_22(int x1, int x2) Aaa.x10in Ccc. x21in Ddd. Eee. Bbb.] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_html_conversion_22:{{.*}} FullCommentAsHTML=[

Aaa.

Bbb.

x1
Ccc.
x2
Ddd.

Returns Eee.

] FullCommentAsXML=[comment_to_html_conversion_22c:@F@comment_to_html_conversion_22#I#I#void comment_to_html_conversion_22(int x1, int x2) Aaa.x10in Ccc. x21in Ddd. Eee. Bbb.] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph IsWhitespace diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 27a13ab97c..8eb21a60a0 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -141,28 +141,28 @@ int test_duplicate_brief3(int); /// Bbb /// /// \return Ccc -int test_duplicate_returns1(int); +int test_multiple_returns1(int); /// \returns Aaa /// /// Bbb /// /// \returns Ccc -int test_duplicate_returns2(int); +int test_multiple_returns2(int); /// \result Aaa /// /// Bbb /// /// \result Ccc -int test_duplicate_returns3(int); +int test_multiple_returns3(int); /// \returns Aaa /// /// Bbb /// /// \return Ccc -int test_duplicate_returns4(int); +int test_multiple_returns4(int); // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index b96ca1c47f..583b850a44 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -787,10 +787,10 @@ void CommentASTToHTMLConverter::visitFullComment(const FullComment *C) { } if (Parts.Returns.size() != 0) { - Result << "
"; + Result << "
"; for (unsigned i = 0, e = Parts.Returns.size(); i != e; ++i) visit(Parts.Returns[i]); - Result << "
"; + Result << ""; } Result.flush();