]> granicus.if.org Git - clang/commitdiff
Factor out a check for block commands (that implicitly start a new paragraph) into...
authorDmitri Gribenko <gribozavr@gmail.com>
Fri, 29 Jun 2012 18:19:20 +0000 (18:19 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Fri, 29 Jun 2012 18:19:20 +0000 (18:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159444 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CommentBriefParser.cpp

index 4040a999249bd0de85f6dbea7028997ed3b1bf00..a56d79bda75e0ea7eccfd33107f3edb7c0640e0b 100644 (file)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/AST/CommentBriefParser.h"
+#include "llvm/ADT/StringSwitch.h"
 
 namespace clang {
 namespace comments {
@@ -38,6 +39,21 @@ void cleanupBrief(std::string &S) {
 
   S.resize(O - S.begin());
 }
+
+bool isBlockCommand(StringRef Name) {
+  return llvm::StringSwitch<bool>(Name)
+      .Case("brief", true)
+      .Case("result", true)
+      .Case("return", true)
+      .Case("returns", true)
+      .Case("author", true)
+      .Case("authors", true)
+      .Case("pre", true)
+      .Case("post", true)
+      .Case("param", true)
+      .Case("arg", true)
+      .Default(false);
+}
 } // unnamed namespace
 
 std::string BriefParser::Parse() {
@@ -61,9 +77,8 @@ std::string BriefParser::Parse() {
         ConsumeToken();
         continue;
       }
-      // Check if this command implicitly starts a new paragraph.
-      if (Name == "param" || Name == "result" || Name == "return" ||
-          Name == "returns") {
+      // Block commands implicitly start a new paragraph.
+      if (isBlockCommand(Name)) {
         // We found an implicit paragraph end.
         InFirstParagraph = false;
         if (InBrief) {