16 #ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
17 #define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
28 #define LIST_TOKEN_TYPES \
29 TYPE(ArrayInitializerLSquare) \
30 TYPE(ArraySubscriptLSquare) \
31 TYPE(AttributeParen) \
32 TYPE(BinaryOperator) \
36 TYPE(ConditionalExpr) \
37 TYPE(ConflictAlternative) \
40 TYPE(CtorInitializerColon) \
41 TYPE(CtorInitializerComma) \
42 TYPE(DesignatedInitializerPeriod) \
45 TYPE(FunctionAnnotationRParen) \
46 TYPE(FunctionDeclarationName) \
47 TYPE(FunctionLBrace) \
48 TYPE(FunctionTypeLParen) \
49 TYPE(ImplicitStringLiteral) \
50 TYPE(InheritanceColon) \
51 TYPE(InlineASMBrace) \
52 TYPE(InlineASMColon) \
53 TYPE(JavaAnnotation) \
54 TYPE(JsComputedPropertyName) \
57 TYPE(JsTypeOptionalQuestion) \
60 TYPE(LeadingJavaAnnotation) \
62 TYPE(MacroBlockBegin) \
64 TYPE(ObjCBlockLBrace) \
65 TYPE(ObjCBlockLParen) \
68 TYPE(ObjCMethodExpr) \
69 TYPE(ObjCMethodSpecifier) \
71 TYPE(ObjCStringLiteral) \
72 TYPE(OverloadedOperator) \
73 TYPE(OverloadedOperatorLParen) \
74 TYPE(PointerOrReference) \
75 TYPE(PureVirtualSpecifier) \
76 TYPE(RangeBasedForLoopColon) \
80 TYPE(TemplateCloser) \
81 TYPE(TemplateOpener) \
82 TYPE(TemplateString) \
83 TYPE(TrailingAnnotation) \
84 TYPE(TrailingReturnArrow) \
85 TYPE(TrailingUnaryOperator) \
90 #define TYPE(X) TT_##X,
196 std::unique_ptr<TokenRole>
Role;
290 template <
typename A,
typename B>
bool isOneOf(A K1, B K2)
const {
291 return is(K1) ||
is(K2);
293 template <
typename A,
typename B,
typename... Ts>
297 template <
typename T>
bool isNot(T
Kind)
const {
return !
is(Kind); }
306 return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private) &&
307 (!ColonRequired || (
Next &&
Next->
is(tok::colon)));
322 return isOneOf(tok::l_paren, tok::l_brace, tok::l_square,
327 return isOneOf(tok::r_paren, tok::r_brace, tok::r_square,
333 return isOneOf(tok::arrow, tok::period, tok::arrowstar) &&
334 !
isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow,
343 case tok::minusminus:
347 case tok::kw_alignof:
360 return is(tok::comment) &&
372 case tok::kw_alignof:
373 case tok::kw_alignas:
374 case tok::kw_decltype:
375 case tok::kw_noexcept:
376 case tok::kw_static_assert:
377 case tok::kw___attribute:
400 while (Tok && Tok->
is(tok::comment))
408 while (Tok && Tok->
is(tok::comment))
416 return is(TT_ArrayInitializerLSquare) ||
433 class ContinuationIndenter;
480 bool DryRun)
override;
483 bool DryRun)
override;
487 Commas.push_back(Token);
493 struct ColumnFormat {
509 const ColumnFormat *getColumnFormat(
unsigned RemainingCharacters)
const;
521 bool HasNestedBracedList;
SourceLocation getEnd() const
The base class of the type hierarchy.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token...
One of these records is kept for each identifier that is lexed.
Token - This structure provides full information about a lexed token.
tok::TokenKind getKind() const
Implements an efficient mapping from strings to IdentifierInfo nodes.
PPKeywordKind
Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines and computes precedence levels for binary/ternary operators.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
A trivial tuple used to represent a source range.
IdentifierInfo * getIdentifierInfo() const
tok::PPKeywordKind getPPKeywordID() const
Return the preprocessor keyword ID for this identifier.