1 //===--- CommentCommandTraits.h - Comment command properties ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the class that provides information about comment
13 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_AST_COMMENT_COMMAND_TRAITS_H
17 #define LLVM_CLANG_AST_COMMENT_COMMAND_TRAITS_H
19 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/Support/Allocator.h"
23 #include "llvm/Support/ErrorHandling.h"
28 /// \brief Information about a single command.
30 /// When reordering, adding or removing members please update the corresponding
33 unsigned getID() const {
39 /// Name of the command that ends the verbatim block.
40 const char *EndCommandName;
44 /// Number of word-like arguments for a given block command, except for
45 /// \\param and \\tparam commands -- these have special argument parsers.
48 /// True if this command is a inline command (of any kind).
49 unsigned IsInlineCommand : 1;
51 /// True if this command is a block command (of any kind).
52 unsigned IsBlockCommand : 1;
54 /// True if this command is introducing a brief documentation
55 /// paragraph (\\brief or an alias).
56 unsigned IsBriefCommand : 1;
58 /// True if this command is \\returns or an alias.
59 unsigned IsReturnsCommand : 1;
61 /// True if this command is introducing documentation for a function
62 /// parameter (\\param or an alias).
63 unsigned IsParamCommand : 1;
65 /// True if this command is introducing documentation for
66 /// a template parameter (\\tparam or an alias).
67 unsigned IsTParamCommand : 1;
69 /// True if this command is \\deprecated or an alias.
70 unsigned IsDeprecatedCommand : 1;
72 /// True if we don't want to warn about this command being passed an empty
73 /// paragraph. Meaningful only for block commands.
74 unsigned IsEmptyParagraphAllowed : 1;
76 /// \brief True if this command is a verbatim-like block command.
78 /// A verbatim-like block command eats every character (except line starting
79 /// decorations) until matching end command is seen or comment end is hit.
80 unsigned IsVerbatimBlockCommand : 1;
82 /// \brief True if this command is an end command for a verbatim-like block.
83 unsigned IsVerbatimBlockEndCommand : 1;
85 /// \brief True if this command is a verbatim line command.
87 /// A verbatim-like line command eats everything until a newline is seen or
88 /// comment end is hit.
89 unsigned IsVerbatimLineCommand : 1;
91 /// \brief True if this command contains a declaration for the entity being
96 /// \fn void f(int a);
98 unsigned IsDeclarationCommand : 1;
100 /// \brief True if this command is unknown. This \c CommandInfo object was
101 /// created during parsing.
102 unsigned IsUnknownCommand : 1;
105 /// This class provides information about commands that can be used
107 class CommandTraits {
109 CommandTraits(llvm::BumpPtrAllocator &Allocator);
111 /// \returns a CommandInfo object for a given command name or
112 /// NULL if no CommandInfo object exists for this command.
113 const CommandInfo *getCommandInfoOrNULL(StringRef Name) const;
115 const CommandInfo *getCommandInfo(StringRef Name) const {
116 if (const CommandInfo *Info = getCommandInfoOrNULL(Name))
118 llvm_unreachable("the command should be known");
121 const CommandInfo *getCommandInfo(unsigned CommandID) const;
123 const CommandInfo *registerUnknownCommand(StringRef CommandName);
125 /// \returns a CommandInfo object for a given command name or
126 /// NULL if \c Name is not a builtin command.
127 static const CommandInfo *getBuiltinCommandInfo(StringRef Name);
129 /// \returns a CommandInfo object for a given command ID or
130 /// NULL if \c CommandID is not a builtin command.
131 static const CommandInfo *getBuiltinCommandInfo(unsigned CommandID);
134 CommandTraits(const CommandTraits &) LLVM_DELETED_FUNCTION;
135 void operator=(const CommandTraits &) LLVM_DELETED_FUNCTION;
137 const CommandInfo *getRegisteredCommandInfo(StringRef Name) const;
138 const CommandInfo *getRegisteredCommandInfo(unsigned CommandID) const;
142 /// Allocator for CommandInfo objects.
143 llvm::BumpPtrAllocator &Allocator;
145 SmallVector<CommandInfo *, 4> RegisteredCommands;
148 } // end namespace comments
149 } // end namespace clang