Skip to content

Commit

Permalink
Simplify logic in BriefParser::Parse(), per Jordan's comment.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159247 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
gribozavr committed Jun 27, 2012
1 parent c2cda02 commit c0b8324
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/AST/CommentBriefParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,29 @@ namespace clang {
namespace comments {

std::string BriefParser::Parse() {
std::string FirstParagraph;
std::string Brief;
std::string Paragraph;
bool InFirstParagraph = true;
bool InBrief = false;
bool BriefDone = false;

while (Tok.isNot(tok::eof)) {
if (Tok.is(tok::text)) {
if (InFirstParagraph)
FirstParagraph += Tok.getText();
if (InBrief)
Brief += Tok.getText();
if (InFirstParagraph || InBrief)
Paragraph += Tok.getText();
ConsumeToken();
continue;
}

if (!BriefDone && Tok.is(tok::command) && Tok.getCommandName() == "brief") {
Paragraph.clear();
InBrief = true;
ConsumeToken();
continue;
}

if (Tok.is(tok::newline)) {
if (InFirstParagraph)
FirstParagraph += '\n';
if (InBrief)
Brief += '\n';
if (InFirstParagraph || InBrief)
Paragraph += '\n';
ConsumeToken();

if (Tok.is(tok::newline)) {
Expand All @@ -58,10 +54,7 @@ std::string BriefParser::Parse() {
ConsumeToken();
}

if (Brief.size() > 0)
return Brief;

return FirstParagraph;
return Paragraph;
}

BriefParser::BriefParser(Lexer &L) : L(L)
Expand Down

0 comments on commit c0b8324

Please sign in to comment.