diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-20 17:01:34 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-20 17:01:34 +0000 |
commit | 77369eead6050f5d47bc621e02b1c48173921c1a (patch) | |
tree | 725c4ace3e48fc340b49118ac88b1fcb13fa7599 /clang/lib/AST/CommentBriefParser.cpp | |
parent | e6c562c0510ae16ad69fdbf2515ef451e23c4b0f (diff) | |
download | bcm5719-llvm-77369eead6050f5d47bc621e02b1c48173921c1a.tar.gz bcm5719-llvm-77369eead6050f5d47bc621e02b1c48173921c1a.zip |
CommentBriefParser: use \returns if we can't find the \brief or just a plain
paragraph.
llvm-svn: 160550
Diffstat (limited to 'clang/lib/AST/CommentBriefParser.cpp')
-rw-r--r-- | clang/lib/AST/CommentBriefParser.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/clang/lib/AST/CommentBriefParser.cpp b/clang/lib/AST/CommentBriefParser.cpp index a6bf33edd41..7b7e8d59657 100644 --- a/clang/lib/AST/CommentBriefParser.cpp +++ b/clang/lib/AST/CommentBriefParser.cpp @@ -53,14 +53,18 @@ bool isBlockCommand(StringRef Name) { } // unnamed namespace std::string BriefParser::Parse() { - std::string Paragraph; + std::string FirstParagraphOrBrief; + std::string ReturnsParagraph; bool InFirstParagraph = true; bool InBrief = false; + bool InReturns = false; while (Tok.isNot(tok::eof)) { if (Tok.is(tok::text)) { if (InFirstParagraph || InBrief) - Paragraph += Tok.getText(); + FirstParagraphOrBrief += Tok.getText(); + else if (InReturns) + ReturnsParagraph += Tok.getText(); ConsumeToken(); continue; } @@ -68,11 +72,15 @@ std::string BriefParser::Parse() { if (Tok.is(tok::command)) { StringRef Name = Tok.getCommandName(); if (Name == "brief" || Name == "short") { - Paragraph.clear(); + FirstParagraphOrBrief.clear(); InBrief = true; ConsumeToken(); continue; } + if (Name == "result" || Name == "return" || Name == "returns") { + InReturns = true; + ReturnsParagraph += "Returns "; + } // Block commands implicitly start a new paragraph. if (isBlockCommand(Name)) { // We found an implicit paragraph end. @@ -84,13 +92,16 @@ std::string BriefParser::Parse() { if (Tok.is(tok::newline)) { if (InFirstParagraph || InBrief) - Paragraph += ' '; + FirstParagraphOrBrief += ' '; + else if (InReturns) + ReturnsParagraph += ' '; ConsumeToken(); if (Tok.is(tok::newline)) { ConsumeToken(); // We found a paragraph end. InFirstParagraph = false; + InReturns = false; if (InBrief) break; } @@ -101,8 +112,12 @@ std::string BriefParser::Parse() { ConsumeToken(); } - cleanupBrief(Paragraph); - return Paragraph; + cleanupBrief(FirstParagraphOrBrief); + if (!FirstParagraphOrBrief.empty()) + return FirstParagraphOrBrief; + + cleanupBrief(ReturnsParagraph); + return ReturnsParagraph; } BriefParser::BriefParser(Lexer &L) : L(L) |