File indexing completed on 2026-05-10 08:36:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_CLANG_AST_COMMENTCOMMANDTRAITS_H
0016 #define LLVM_CLANG_AST_COMMENTCOMMANDTRAITS_H
0017
0018 #include "clang/Basic/CommentOptions.h"
0019 #include "clang/Basic/LLVM.h"
0020 #include "llvm/ADT/SmallVector.h"
0021 #include "llvm/ADT/StringRef.h"
0022 #include "llvm/Support/Allocator.h"
0023 #include "llvm/Support/ErrorHandling.h"
0024
0025 namespace clang {
0026 namespace comments {
0027
0028
0029
0030
0031
0032 struct CommandInfo {
0033 unsigned getID() const {
0034 return ID;
0035 }
0036
0037 const char *Name;
0038
0039
0040 const char *EndCommandName;
0041
0042
0043 enum { NumCommandIDBits = 20 };
0044
0045
0046 unsigned ID : NumCommandIDBits;
0047
0048
0049
0050 unsigned NumArgs : 4;
0051
0052
0053 LLVM_PREFERRED_TYPE(bool)
0054 unsigned IsInlineCommand : 1;
0055
0056
0057 LLVM_PREFERRED_TYPE(bool)
0058 unsigned IsBlockCommand : 1;
0059
0060
0061
0062 LLVM_PREFERRED_TYPE(bool)
0063 unsigned IsBriefCommand : 1;
0064
0065
0066 LLVM_PREFERRED_TYPE(bool)
0067 unsigned IsReturnsCommand : 1;
0068
0069
0070
0071 LLVM_PREFERRED_TYPE(bool)
0072 unsigned IsParamCommand : 1;
0073
0074
0075
0076 LLVM_PREFERRED_TYPE(bool)
0077 unsigned IsTParamCommand : 1;
0078
0079
0080 LLVM_PREFERRED_TYPE(bool)
0081 unsigned IsThrowsCommand : 1;
0082
0083
0084 LLVM_PREFERRED_TYPE(bool)
0085 unsigned IsDeprecatedCommand : 1;
0086
0087
0088 LLVM_PREFERRED_TYPE(bool)
0089 unsigned IsHeaderfileCommand : 1;
0090
0091
0092 LLVM_PREFERRED_TYPE(bool)
0093 unsigned IsParCommand : 1;
0094
0095
0096
0097 LLVM_PREFERRED_TYPE(bool)
0098 unsigned IsEmptyParagraphAllowed : 1;
0099
0100
0101
0102
0103
0104 LLVM_PREFERRED_TYPE(bool)
0105 unsigned IsVerbatimBlockCommand : 1;
0106
0107
0108 LLVM_PREFERRED_TYPE(bool)
0109 unsigned IsVerbatimBlockEndCommand : 1;
0110
0111
0112
0113
0114
0115 LLVM_PREFERRED_TYPE(bool)
0116 unsigned IsVerbatimLineCommand : 1;
0117
0118
0119
0120
0121
0122
0123
0124
0125 LLVM_PREFERRED_TYPE(bool)
0126 unsigned IsDeclarationCommand : 1;
0127
0128
0129 LLVM_PREFERRED_TYPE(bool)
0130 unsigned IsFunctionDeclarationCommand : 1;
0131
0132
0133
0134 LLVM_PREFERRED_TYPE(bool)
0135 unsigned IsRecordLikeDetailCommand : 1;
0136
0137
0138 LLVM_PREFERRED_TYPE(bool)
0139 unsigned IsRecordLikeDeclarationCommand : 1;
0140
0141
0142
0143 LLVM_PREFERRED_TYPE(bool)
0144 unsigned IsUnknownCommand : 1;
0145 };
0146
0147
0148
0149 class CommandTraits {
0150 public:
0151 enum KnownCommandIDs {
0152 #define COMMENT_COMMAND(NAME) KCI_##NAME,
0153 #include "clang/AST/CommentCommandList.inc"
0154 #undef COMMENT_COMMAND
0155 KCI_Last
0156 };
0157
0158 CommandTraits(llvm::BumpPtrAllocator &Allocator,
0159 const CommentOptions &CommentOptions);
0160
0161 void registerCommentOptions(const CommentOptions &CommentOptions);
0162
0163
0164
0165 const CommandInfo *getCommandInfoOrNULL(StringRef Name) const;
0166
0167 const CommandInfo *getCommandInfo(StringRef Name) const {
0168 if (const CommandInfo *Info = getCommandInfoOrNULL(Name))
0169 return Info;
0170 llvm_unreachable("the command should be known");
0171 }
0172
0173 const CommandInfo *getTypoCorrectCommandInfo(StringRef Typo) const;
0174
0175 const CommandInfo *getCommandInfo(unsigned CommandID) const;
0176
0177 const CommandInfo *registerUnknownCommand(StringRef CommandName);
0178
0179 const CommandInfo *registerBlockCommand(StringRef CommandName);
0180
0181
0182
0183 static const CommandInfo *getBuiltinCommandInfo(StringRef Name);
0184
0185
0186
0187 static const CommandInfo *getBuiltinCommandInfo(unsigned CommandID);
0188
0189 private:
0190 CommandTraits(const CommandTraits &) = delete;
0191 void operator=(const CommandTraits &) = delete;
0192
0193 const CommandInfo *getRegisteredCommandInfo(StringRef Name) const;
0194 const CommandInfo *getRegisteredCommandInfo(unsigned CommandID) const;
0195
0196 CommandInfo *createCommandInfoWithName(StringRef CommandName);
0197
0198 unsigned NextID;
0199
0200
0201 llvm::BumpPtrAllocator &Allocator;
0202
0203 SmallVector<CommandInfo *, 4> RegisteredCommands;
0204 };
0205
0206 }
0207 }
0208
0209 #endif
0210