[cfe-commits] r159444 - /cfe/trunk/lib/AST/CommentBriefParser.cpp

Dmitri Gribenko gribozavr at gmail.com
Fri Jun 29 11:19:20 PDT 2012


Author: gribozavr
Date: Fri Jun 29 13:19:20 2012
New Revision: 159444

URL: http://llvm.org/viewvc/llvm-project?rev=159444&view=rev
Log:
Factor out a check for block commands (that implicitly start a new paragraph) into a separate function.

Modified:
    cfe/trunk/lib/AST/CommentBriefParser.cpp

Modified: cfe/trunk/lib/AST/CommentBriefParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentBriefParser.cpp?rev=159444&r1=159443&r2=159444&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentBriefParser.cpp (original)
+++ cfe/trunk/lib/AST/CommentBriefParser.cpp Fri Jun 29 13:19:20 2012
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/AST/CommentBriefParser.h"
+#include "llvm/ADT/StringSwitch.h"
 
 namespace clang {
 namespace comments {
@@ -38,6 +39,21 @@
 
   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 @@
         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) {





More information about the cfe-commits mailing list