diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index d95f010a6fb2..93a522457e7a 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -3563,8 +3563,12 @@ CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment); * \li "para-returns" for \\returns paragraph and equivalent commands; * \li "word-returns" for the "Returns" word in \\returns paragraph. * - * Argument list is rendered as \
Aaa.
Bbb.
Returns Eee.
] +// CHECK: annotate-comments.cpp:292:6: FunctionDecl=comment_to_html_conversion_15:{{.*}} FullCommentAsHTML=[Aaa.
Bbb.
Returns Eee.
] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph IsWhitespace @@ -550,7 +550,7 @@ void comment_to_html_conversion_22(); // CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] // CHECK-NEXT: (CXComment_Paragraph // CHECK-NEXT: (CXComment_Text Text=[ Eee.]))))] -// CHECK: annotate-comments.cpp:295:6: FunctionDecl=comment_to_html_conversion_16:{{.*}} FullCommentAsHTML=[] +// CHECK: annotate-comments.cpp:295:6: FunctionDecl=comment_to_html_conversion_16:{{.*}} FullCommentAsHTML=[] // CHECK-NEXT: CommentAST=[ // CHECK-NEXT: (CXComment_FullComment // CHECK-NEXT: (CXComment_Paragraph diff --git a/clang/tools/libclang/CXComment.cpp b/clang/tools/libclang/CXComment.cpp index 8d01a4192f13..b0ed9bcc00ea 100644 --- a/clang/tools/libclang/CXComment.cpp +++ b/clang/tools/libclang/CXComment.cpp @@ -18,6 +18,7 @@ #include "clang/AST/CommentVisitor.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" using namespace clang; using namespace clang::cxstring; @@ -304,7 +305,8 @@ public: class CommentASTToHTMLConverter : public ConstCommentVisitor"; + Result << "
"; for (Comment::child_iterator I = C->child_begin(), E = C->child_end(); I != E; ++I) { visit(*I); } - Result += "
"; + Result << ""; } void CommentASTToHTMLConverter::visitBlockCommandComment( const BlockCommandComment *C) { StringRef CommandName = C->getCommandName(); if (CommandName == "brief" || CommandName == "short") { - Result += ""; + Result << "
"; visitNonStandaloneParagraphComment(C->getParagraph()); - Result += "
"; + Result << ""; return; } if (CommandName == "returns" || CommandName == "return") { - Result += ""; - Result += "Returns "; + Result << "
" + "Returns "; visitNonStandaloneParagraphComment(C->getParagraph()); - Result += "
"; + Result << ""; return; } // We don't know anything about this command. Just render the paragraph. @@ -450,12 +434,24 @@ void CommentASTToHTMLConverter::visitBlockCommandComment( void CommentASTToHTMLConverter::visitParamCommandComment( const ParamCommandComment *C) { - Result += ""; + Result << ""; } void CommentASTToHTMLConverter::visitVerbatimBlockLineComment( @@ -480,9 +476,9 @@ void CommentASTToHTMLConverter::visitVerbatimBlockLineComment( void CommentASTToHTMLConverter::visitVerbatimLineComment( const VerbatimLineComment *C) { - Result += ""; for (unsigned i = 0; i != NumLines; ++i) { appendToResultWithHTMLEscaping(C->getText(i)); if (i + 1 != NumLines) - Result.append("\n"); + Result << '\n'; } - Result += ""; + Result << "
"; + Result << ""; } void CommentASTToHTMLConverter::visitFullComment(const FullComment *C) { @@ -566,9 +562,9 @@ void CommentASTToHTMLConverter::visitFullComment(const FullComment *C) { if (Brief) visit(Brief); else if (FirstParagraph) { - Result += ""; appendToResultWithHTMLEscaping(C->getText()); - Result += ""; + Result << "
"; + Result << "
"; visitNonStandaloneParagraphComment(FirstParagraph); - Result += "
"; + Result << ""; FirstParagraphIsBrief = true; } @@ -580,14 +576,16 @@ void CommentASTToHTMLConverter::visitFullComment(const FullComment *C) { } if (Params.size() != 0) { - Result += "