aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-06-28 00:01:41 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-06-28 00:01:41 +0000
commitf199b9cd4af562029a3c7b82c4672819b2c39e70 (patch)
tree90933040a34d37d931eecdebe8c8bf1e508e583b
parentaf505c58222a87058fa4ac26cd8da27c141eec42 (diff)
Teach \brief parser about commands that start a new paragraph implicitly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159309 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/CommentBriefParser.cpp26
-rw-r--r--test/Index/annotate-comments.cpp6
2 files changed, 25 insertions, 7 deletions
diff --git a/lib/AST/CommentBriefParser.cpp b/lib/AST/CommentBriefParser.cpp
index 2f67602b74..f647309246 100644
--- a/lib/AST/CommentBriefParser.cpp
+++ b/lib/AST/CommentBriefParser.cpp
@@ -16,7 +16,6 @@ std::string BriefParser::Parse() {
std::string Paragraph;
bool InFirstParagraph = true;
bool InBrief = false;
- bool BriefDone = false;
while (Tok.isNot(tok::eof)) {
if (Tok.is(tok::text)) {
@@ -26,11 +25,24 @@ std::string BriefParser::Parse() {
continue;
}
- if (!BriefDone && Tok.is(tok::command) && Tok.getCommandName() == "brief") {
- Paragraph.clear();
- InBrief = true;
- ConsumeToken();
- continue;
+ if (Tok.is(tok::command)) {
+ StringRef Name = Tok.getCommandName();
+ if (Name == "brief") {
+ Paragraph.clear();
+ InBrief = true;
+ ConsumeToken();
+ continue;
+ }
+ // Check if this command implicitly starts a new paragraph.
+ if (Name == "param" || Name == "result" || Name == "return" ||
+ Name == "returns") {
+ // We found an implicit paragraph end.
+ InFirstParagraph = false;
+ if (InBrief) {
+ InBrief = false;
+ break;
+ }
+ }
}
if (Tok.is(tok::newline)) {
@@ -44,7 +56,7 @@ std::string BriefParser::Parse() {
InFirstParagraph = false;
if (InBrief) {
InBrief = false;
- BriefDone = true;
+ break;
}
}
continue;
diff --git a/test/Index/annotate-comments.cpp b/test/Index/annotate-comments.cpp
index cb0630b739..59ffa88348 100644
--- a/test/Index/annotate-comments.cpp
+++ b/test/Index/annotate-comments.cpp
@@ -198,6 +198,11 @@ void isdoxy45(void);
#define FOO
void notdoxy46(void);
+/// IS_DOXYGEN_START Aaa bbb
+/// \param ccc
+/// \returns ddd IS_DOXYGEN_END
+void isdoxy47(int);
+
#endif
// RUN: rm -rf %t
@@ -265,4 +270,5 @@ void notdoxy46(void);
// CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[ IS_DOXYGEN_START Aaa bbb\n ccc.\n]
// CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[\n Ddd eee.\n Fff.\n]
+// CHECK: annotate-comments.cpp:204:6: FunctionDecl=isdoxy47:{{.*}} BriefComment=[ IS_DOXYGEN_START Aaa bbb\n ]