Skip to content

Commit 025d518

Browse files
committed
Factor out a check for block commands (that implicitly start a new paragraph) into a separate function.
llvm-svn: 159444
1 parent e8cee12 commit 025d518

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

clang/lib/AST/CommentBriefParser.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include "clang/AST/CommentBriefParser.h"
11+
#include "llvm/ADT/StringSwitch.h"
1112

1213
namespace clang {
1314
namespace comments {
@@ -38,6 +39,21 @@ void cleanupBrief(std::string &S) {
3839

3940
S.resize(O - S.begin());
4041
}
42+
43+
bool isBlockCommand(StringRef Name) {
44+
return llvm::StringSwitch<bool>(Name)
45+
.Case("brief", true)
46+
.Case("result", true)
47+
.Case("return", true)
48+
.Case("returns", true)
49+
.Case("author", true)
50+
.Case("authors", true)
51+
.Case("pre", true)
52+
.Case("post", true)
53+
.Case("param", true)
54+
.Case("arg", true)
55+
.Default(false);
56+
}
4157
} // unnamed namespace
4258

4359
std::string BriefParser::Parse() {
@@ -61,9 +77,8 @@ std::string BriefParser::Parse() {
6177
ConsumeToken();
6278
continue;
6379
}
64-
// Check if this command implicitly starts a new paragraph.
65-
if (Name == "param" || Name == "result" || Name == "return" ||
66-
Name == "returns") {
80+
// Block commands implicitly start a new paragraph.
81+
if (isBlockCommand(Name)) {
6782
// We found an implicit paragraph end.
6883
InFirstParagraph = false;
6984
if (InBrief) {

0 commit comments

Comments
 (0)