diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-27 01:17:34 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-06-27 01:17:34 +0000 |
commit | c0b8324d6f68dfc2221257cdb83e39b974431c0b (patch) | |
tree | 68c79affb6a1c87ccc2afd7a443bab6e598f798e /lib/AST/CommentBriefParser.cpp | |
parent | c2cda0284a3e80fa4b39b540f6c73782fa69fa6b (diff) |
Simplify logic in BriefParser::Parse(), per Jordan's comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/CommentBriefParser.cpp')
-rw-r--r-- | lib/AST/CommentBriefParser.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/AST/CommentBriefParser.cpp b/lib/AST/CommentBriefParser.cpp index 528fd2606f..2f67602b74 100644 --- a/lib/AST/CommentBriefParser.cpp +++ b/lib/AST/CommentBriefParser.cpp @@ -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)) { @@ -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) |