|
20 | 20 | //
|
21 | 21 | //===----------------------------------------------------------------------===//
|
22 | 22 | #include "Representation.h"
|
| 23 | +#include "llvm/ADT/StringMap.h" |
23 | 24 | #include "llvm/Support/Error.h"
|
24 | 25 | #include "llvm/Support/Path.h"
|
25 | 26 |
|
26 | 27 | namespace clang {
|
27 | 28 | namespace doc {
|
28 | 29 |
|
29 | 30 | CommentKind stringToCommentKind(llvm::StringRef KindStr) {
|
30 |
| - if (KindStr == "FullComment") |
31 |
| - return CommentKind::CK_FullComment; |
32 |
| - if (KindStr == "ParagraphComment") |
33 |
| - return CommentKind::CK_ParagraphComment; |
34 |
| - if (KindStr == "TextComment") |
35 |
| - return CommentKind::CK_TextComment; |
36 |
| - if (KindStr == "InlineCommandComment") |
37 |
| - return CommentKind::CK_InlineCommandComment; |
38 |
| - if (KindStr == "HTMLStartTagComment") |
39 |
| - return CommentKind::CK_HTMLStartTagComment; |
40 |
| - if (KindStr == "HTMLEndTagComment") |
41 |
| - return CommentKind::CK_HTMLEndTagComment; |
42 |
| - if (KindStr == "BlockCommandComment") |
43 |
| - return CommentKind::CK_BlockCommandComment; |
44 |
| - if (KindStr == "ParamCommandComment") |
45 |
| - return CommentKind::CK_ParamCommandComment; |
46 |
| - if (KindStr == "TParamCommandComment") |
47 |
| - return CommentKind::CK_TParamCommandComment; |
48 |
| - if (KindStr == "VerbatimBlockComment") |
49 |
| - return CommentKind::CK_VerbatimBlockComment; |
50 |
| - if (KindStr == "VerbatimBlockLineComment") |
51 |
| - return CommentKind::CK_VerbatimBlockLineComment; |
52 |
| - if (KindStr == "VerbatimLineComment") |
53 |
| - return CommentKind::CK_VerbatimLineComment; |
| 31 | + static const llvm::StringMap<CommentKind> KindMap = { |
| 32 | + {"FullComment", CommentKind::CK_FullComment}, |
| 33 | + {"ParagraphComment", CommentKind::CK_ParagraphComment}, |
| 34 | + {"TextComment", CommentKind::CK_TextComment}, |
| 35 | + {"InlineCommandComment", CommentKind::CK_InlineCommandComment}, |
| 36 | + {"HTMLStartTagComment", CommentKind::CK_HTMLStartTagComment}, |
| 37 | + {"HTMLEndTagComment", CommentKind::CK_HTMLEndTagComment}, |
| 38 | + {"BlockCommandComment", CommentKind::CK_BlockCommandComment}, |
| 39 | + {"ParamCommandComment", CommentKind::CK_ParamCommandComment}, |
| 40 | + {"TParamCommandComment", CommentKind::CK_TParamCommandComment}, |
| 41 | + {"VerbatimBlockComment", CommentKind::CK_VerbatimBlockComment}, |
| 42 | + {"VerbatimBlockLineComment", CommentKind::CK_VerbatimBlockLineComment}, |
| 43 | + {"VerbatimLineComment", CommentKind::CK_VerbatimLineComment}, |
| 44 | + }; |
| 45 | + |
| 46 | + auto It = KindMap.find(KindStr); |
| 47 | + if (It != KindMap.end()) { |
| 48 | + return It->second; |
| 49 | + } |
54 | 50 | return CommentKind::CK_Unknown;
|
55 | 51 | }
|
56 | 52 |
|
|
0 commit comments