clang API Documentation
#include <Parser.h>
Classes | |
class | DeclaratorScopeObj |
struct | ForRangeInit |
struct | IfExistsCondition |
Describes the condition of a Microsoft __if_exists or __if_not_exists block. | |
struct | LateParsedAttribute |
class | LateParsedAttrList |
class | LateParsedClass |
class | LateParsedDeclaration |
struct | LateParsedDefaultArgument |
struct | LateParsedMemberInitializer |
struct | LateParsedMethodDeclaration |
struct | LexedMethod |
class | ObjCDeclContextSwitch |
struct | ObjCImplParsingDataRAII |
struct | ParsedAttributesWithRange |
struct | ParsedTemplateInfo |
Contains information about any template-specific information that has been parsed prior to parsing declaration specifiers. | |
class | ParseScope |
class | ParseScopeFlags |
RAII object used to modify the scope flags for the current scope. | |
struct | ParsingClass |
Representation of a class that has been parsed, including any member function declarations or definitions that need to be parsed after the corresponding top-level class is complete. | |
class | ParsingClassDefinition |
RAII object used to manage the parsing of a class definition. | |
class | TemplateParameterDepthRAII |
RAII class that manages the template parameter depth. | |
class | TentativeParsingAction |
class | UnannotatedTentativeParsingAction |
A tentative parsing action that can also revert token annotations. More... | |
Public Types | |
enum | SkipUntilFlags { StopAtSemi = 1 << 0, StopBeforeMatch = 1 << 1, StopAtCodeCompletion = 1 << 2 } |
Control flags for SkipUntil functions. More... | |
enum | TypeCastState { NotTypeCast = 0, MaybeTypeCast, IsTypeCast } |
TypeCastState - State whether an expression is or may be a type cast. More... | |
typedef OpaquePtr< DeclGroupRef > | DeclGroupPtrTy |
typedef OpaquePtr< TemplateName > | TemplateTy |
typedef SmallVector < TemplateParameterList *, 4 > | TemplateParameterLists |
typedef Sema::FullExprArg | FullExprArg |
Public Member Functions | |
Parser (Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies) | |
~Parser () | |
const LangOptions & | getLangOpts () const |
const TargetInfo & | getTargetInfo () const |
Preprocessor & | getPreprocessor () const |
Sema & | getActions () const |
AttributeFactory & | getAttrFactory () |
const Token & | getCurToken () const |
Scope * | getCurScope () const |
void | incrementMSLocalManglingNumber () const |
Decl * | getObjCDeclContext () const |
void | Initialize () |
bool | ParseTopLevelDecl (DeclGroupPtrTy &Result) |
bool | ParseTopLevelDecl () |
SourceLocation | ConsumeToken () |
bool | TryConsumeToken (tok::TokenKind Expected) |
bool | TryConsumeToken (tok::TokenKind Expected, SourceLocation &Loc) |
const Token & | NextToken () |
bool | TryAnnotateTypeOrScopeToken (bool EnteringContext=false, bool NeedType=false) |
bool | TryAnnotateTypeOrScopeTokenAfterScopeSpec (bool EnteringContext, bool NeedType, CXXScopeSpec &SS, bool IsNewScope) |
Try to annotate a type or scope token, having already parsed an optional scope specifier. IsNewScope should be true unless the scope specifier was extracted from an existing tok::annot_cxxscope annotation. | |
bool | TryAnnotateCXXScopeToken (bool EnteringContext=false) |
void | EnterScope (unsigned ScopeFlags) |
EnterScope - Start a new scope. | |
void | ExitScope () |
ExitScope - Pop a scope off the scope stack. | |
DiagnosticBuilder | Diag (SourceLocation Loc, unsigned DiagID) |
DiagnosticBuilder | Diag (const Token &Tok, unsigned DiagID) |
DiagnosticBuilder | Diag (unsigned DiagID) |
bool | SkipUntil (tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0)) |
bool | SkipUntil (tok::TokenKind T1, tok::TokenKind T2, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0)) |
bool | SkipUntil (tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0)) |
bool | SkipUntil (ArrayRef< tok::TokenKind > Toks, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0)) |
void | SkipMalformedDecl () |
ExprResult | ParseExpression (TypeCastState isTypeCast=NotTypeCast) |
Simple precedence-based parser for binary/ternary operators. | |
ExprResult | ParseConstantExpression (TypeCastState isTypeCast=NotTypeCast) |
ExprResult | ParseAssignmentExpression (TypeCastState isTypeCast=NotTypeCast) |
Parse an expr that doesn't include (top-level) commas. | |
ExprResult | ParseMSAsmIdentifier (llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, void *Info, bool IsUnevaluated) |
TypeResult | ParseTypeName (SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr) |
bool | ParseUnqualifiedId (CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result) |
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity. | |
Static Public Member Functions | |
static ParsedType | getTypeAnnotation (Token &Tok) |
getTypeAnnotation - Read a parsed type out of an annotation token. | |
Friends | |
class | ColonProtectionRAIIObject |
class | InMessageExpressionRAIIObject |
class | PoisonSEHIdentifiersRAIIObject |
class | ObjCDeclContextSwitch |
class | ParenBraceBracketBalancer |
class | BalancedDelimiterTracker |
LLVM_CONSTEXPR SkipUntilFlags | operator| (SkipUntilFlags L, SkipUntilFlags R) |
Parser - This implements a parser for the C family of languages. After parsing units of the grammar, productions are invoked to handle whatever has been read.
Definition at line 54 of file Parse/Parser.h.
Definition at line 256 of file Parse/Parser.h.
Definition at line 261 of file Parse/Parser.h.
typedef SmallVector<TemplateParameterList *, 4> clang::Parser::TemplateParameterLists |
Definition at line 259 of file Parse/Parser.h.
Definition at line 257 of file Parse/Parser.h.
Control flags for SkipUntil functions.
StopAtSemi |
Stop skipping at semicolon |
StopBeforeMatch |
Stop skipping at specified token, but don't skip the token itself. |
StopAtCodeCompletion |
Stop at code completion. |
Definition at line 810 of file Parse/Parser.h.
TypeCastState - State whether an expression is or may be a type cast.
Definition at line 1300 of file Parse/Parser.h.
Parser::Parser | ( | Preprocessor & | PP, |
Sema & | Actions, | ||
bool | SkipFunctionBodies | ||
) |
Parser::~Parser | ( | ) |
Definition at line 402 of file Parse/Parser.cpp.
References clang::Preprocessor::clearCodeCompletionHandler(), getCurScope(), and clang::Preprocessor::removeCommentHandler().
SourceLocation clang::Parser::ConsumeToken | ( | ) | [inline] |
ConsumeToken - Consume the current 'peek token' and lex the next one. This does not work with special tokens: string literals, code completion and balanced tokens must be handled using the specific consume methods. Returns the location of the consumed token.
Definition at line 281 of file Parse/Parser.h.
References clang::Token::getLocation(), and clang::Preprocessor::Lex().
Referenced by Initialize(), ParseMSAsmIdentifier(), ParseOpenMPDirectiveKind(), ParseReductionId(), ParseTopLevelDecl(), ParseUnqualifiedId(), SkipMalformedDecl(), SkipUntil(), TryAnnotateTypeOrScopeToken(), and TryAnnotateTypeOrScopeTokenAfterScopeSpec().
DiagnosticBuilder Parser::Diag | ( | SourceLocation | Loc, |
unsigned | DiagID | ||
) |
Definition at line 74 of file Parse/Parser.cpp.
References clang::DiagnosticsEngine::Report().
Referenced by CheckArrayDesignatorSyntax(), Diag(), diagnoseDynamicExceptionSpecification(), FixDigraph(), clang::ParseAST(), ParseUnqualifiedId(), and TryAnnotateTypeOrScopeToken().
DiagnosticBuilder Parser::Diag | ( | const Token & | Tok, |
unsigned | DiagID | ||
) |
Definition at line 78 of file Parse/Parser.cpp.
References Diag(), and clang::Token::getLocation().
DiagnosticBuilder clang::Parser::Diag | ( | unsigned | DiagID | ) | [inline] |
Definition at line 798 of file Parse/Parser.h.
References Diag().
void Parser::EnterScope | ( | unsigned | ScopeFlags | ) |
EnterScope - Start a new scope.
Definition at line 352 of file Parse/Parser.cpp.
References getCurScope(), and clang::Scope::Init().
Referenced by Initialize(), and clang::Parser::ParseScope::ParseScope().
void Parser::ExitScope | ( | ) |
ExitScope - Pop a scope off the scope stack.
Definition at line 363 of file Parse/Parser.cpp.
References clang::Sema::ActOnPopScope(), getCurScope(), clang::Token::getLocation(), and clang::Scope::getParent().
Referenced by clang::Parser::ParseScope::Exit().
Sema& clang::Parser::getActions | ( | ) | const [inline] |
Definition at line 243 of file Parse/Parser.h.
Referenced by clang::ParseAST().
AttributeFactory& clang::Parser::getAttrFactory | ( | ) | [inline] |
Definition at line 244 of file Parse/Parser.h.
Scope* clang::Parser::getCurScope | ( | ) | const [inline] |
Definition at line 247 of file Parse/Parser.h.
References clang::Sema::getCurScope().
Referenced by EnterScope(), ExitScope(), Initialize(), ParseAssignmentExpression(), ParseTypeName(), ParseUnqualifiedId(), TryAnnotateTypeOrScopeToken(), TryAnnotateTypeOrScopeTokenAfterScopeSpec(), and ~Parser().
const Token& clang::Parser::getCurToken | ( | ) | const [inline] |
Definition at line 246 of file Parse/Parser.h.
Referenced by ParseOpenMPDirectiveKind(), and ParseReductionId().
const LangOptions& clang::Parser::getLangOpts | ( | ) | const [inline] |
Definition at line 240 of file Parse/Parser.h.
References clang::Preprocessor::getLangOpts().
Referenced by clang::BalancedDelimiterTracker::consumeOpen(), diagnoseDynamicExceptionSpecification(), Initialize(), ParseMSAsmIdentifier(), ParseTopLevelDecl(), ParseUnqualifiedId(), TryAnnotateCXXScopeToken(), TryAnnotateTypeOrScopeToken(), and TryAnnotateTypeOrScopeTokenAfterScopeSpec().
Decl* clang::Parser::getObjCDeclContext | ( | ) | const [inline] |
Definition at line 252 of file Parse/Parser.h.
References clang::Sema::getObjCDeclContext().
Preprocessor& clang::Parser::getPreprocessor | ( | ) | const [inline] |
Definition at line 242 of file Parse/Parser.h.
Referenced by ParseOpenMPDirectiveKind().
const TargetInfo& clang::Parser::getTargetInfo | ( | ) | const [inline] |
Definition at line 241 of file Parse/Parser.h.
References clang::Preprocessor::getTargetInfo().
static ParsedType clang::Parser::getTypeAnnotation | ( | Token & | Tok | ) | [inline, static] |
getTypeAnnotation - Read a parsed type out of an annotation token.
Definition at line 533 of file Parse/Parser.h.
References clang::Token::getAnnotationValue(), and clang::OpaquePtr< QualType >::getFromOpaquePtr().
void clang::Parser::incrementMSLocalManglingNumber | ( | ) | const [inline] |
Definition at line 248 of file Parse/Parser.h.
References clang::Sema::incrementMSLocalManglingNumber().
Referenced by clang::Parser::ParseScope::ParseScope().
void Parser::Initialize | ( | ) |
Initialize - Warm up the parser.
Definition at line 422 of file Parse/Parser.cpp.
References clang::Sema::ActOnTranslationUnitScope(), ConsumeToken(), clang::Scope::DeclScope, EnterScope(), clang::IdentifierTable::get(), getCurScope(), clang::Preprocessor::getIdentifierInfo(), clang::Preprocessor::getIdentifierTable(), getLangOpts(), clang::Sema::Initialize(), and clang::Preprocessor::SetPoisonReason().
Referenced by clang::ParseAST().
const Token& clang::Parser::NextToken | ( | ) | [inline] |
NextToken - This peeks ahead one token and returns it without consuming it.
Definition at line 528 of file Parse/Parser.h.
References clang::Preprocessor::LookAhead().
Referenced by ParseUnqualifiedId(), SkipMalformedDecl(), TryAnnotateCXXScopeToken(), TryAnnotateTypeOrScopeToken(), and TryAnnotateTypeOrScopeTokenAfterScopeSpec().
ExprResult Parser::ParseAssignmentExpression | ( | TypeCastState | isTypeCast = NotTypeCast | ) |
Parse an expr that doesn't include (top-level) commas.
Definition at line 157 of file ParseExpr.cpp.
References clang::prec::Assignment, clang::Sema::CodeCompleteOrdinaryName(), clang::ExprError(), getCurScope(), clang::Token::is(), and clang::Sema::PCC_Expression.
Referenced by ParseExpression().
ExprResult Parser::ParseConstantExpression | ( | TypeCastState | isTypeCast = NotTypeCast | ) |
Definition at line 195 of file ParseExpr.cpp.
References clang::Sema::ActOnConstantExpression(), clang::prec::Conditional, and clang::Sema::ConstantEvaluated.
ExprResult Parser::ParseExpression | ( | TypeCastState | isTypeCast = NotTypeCast | ) |
Simple precedence-based parser for binary/ternary operators.
Note: we diverge from the C99 grammar when parsing the assignment-expression production. C99 specifies that the LHS of an assignment operator should be parsed as a unary-expression, but consistency dictates that it be a conditional-expession. In practice, the important thing here is that the LHS of an assignment has to be an l-value, which productions between unary-expression and conditional-expression don't produce. Because we want consistency, we parse the LHS as a conditional-expression, then check for l-value-ness in semantic analysis stages.
/// pm-expression: [C++ 5.5] /// cast-expression /// pm-expression '.*' cast-expression /// pm-expression '->*' cast-expression /// /// multiplicative-expression: [C99 6.5.5] /// Note: in C++, apply pm-expression instead of cast-expression /// cast-expression /// multiplicative-expression '*' cast-expression /// multiplicative-expression '/' cast-expression /// multiplicative-expression '%' cast-expression /// /// additive-expression: [C99 6.5.6] /// multiplicative-expression /// additive-expression '+' multiplicative-expression /// additive-expression '-' multiplicative-expression /// /// shift-expression: [C99 6.5.7] /// additive-expression /// shift-expression '<<' additive-expression /// shift-expression '>>' additive-expression /// /// relational-expression: [C99 6.5.8] /// shift-expression /// relational-expression '<' shift-expression /// relational-expression '>' shift-expression /// relational-expression '<=' shift-expression /// relational-expression '>=' shift-expression /// /// equality-expression: [C99 6.5.9] /// relational-expression /// equality-expression '==' relational-expression /// equality-expression '!=' relational-expression /// /// AND-expression: [C99 6.5.10] /// equality-expression /// AND-expression '&' equality-expression /// /// exclusive-OR-expression: [C99 6.5.11] /// AND-expression /// exclusive-OR-expression '^' AND-expression /// /// inclusive-OR-expression: [C99 6.5.12] /// exclusive-OR-expression /// inclusive-OR-expression '|' exclusive-OR-expression /// /// logical-AND-expression: [C99 6.5.13] /// inclusive-OR-expression /// logical-AND-expression '&&' inclusive-OR-expression /// /// logical-OR-expression: [C99 6.5.14] /// logical-AND-expression /// logical-OR-expression '||' logical-AND-expression /// /// conditional-expression: [C99 6.5.15] /// logical-OR-expression /// logical-OR-expression '?' expression ':' conditional-expression /// [GNU] logical-OR-expression '?' ':' conditional-expression /// [C++] the third operand is an assignment-expression /// /// assignment-expression: [C99 6.5.16] /// conditional-expression /// unary-expression assignment-operator assignment-expression /// [C++] throw-expression [C++ 15] /// /// assignment-operator: one of /// = *= /= %= += -= <<= >>= &= ^= |= /// /// expression: [C99 6.5.17] /// assignment-expression ...[opt] /// expression ',' assignment-expression ...[opt] ///
Definition at line 120 of file ParseExpr.cpp.
References clang::prec::Comma, and ParseAssignmentExpression().
ExprResult Parser::ParseMSAsmIdentifier | ( | llvm::SmallVectorImpl< Token > & | LineToks, |
unsigned & | NumLineToksConsumed, | ||
void * | CastInfo, | ||
bool | IsUnevaluatedContext | ||
) |
Parse an identifier in an MS-style inline assembly block.
CastInfo | - a void* so that we don't have to teach Parser.h about the actual type. |
Definition at line 183 of file ParseStmtAsm.cpp.
References ConsumeToken(), clang::frontend::CPlusPlus, clang::Preprocessor::EnterTokenStream(), getLangOpts(), clang::Token::getLocation(), clang::Token::is(), clang::Sema::LookupInlineAsmIdentifier(), ParseUnqualifiedId(), clang::Token::setKind(), and clang::Token::startToken().
bool Parser::ParseTopLevelDecl | ( | DeclGroupPtrTy & | Result | ) |
ParseTopLevelDecl - Parse one top-level declaration. Returns true if the EOF was encountered.
ParseTopLevelDecl - Parse one top-level declaration, return whatever the action tells us to. This returns true if the EOF was encountered.
Definition at line 522 of file Parse/Parser.cpp.
References clang::Sema::ActOnEndOfTranslationUnit(), clang::Sema::ActOnModuleInclude(), ConsumeToken(), clang::comments::tok::eof, clang::Token::getAnnotationValue(), clang::Token::getKind(), getLangOpts(), clang::Token::getLocation(), clang::Token::is(), clang::Preprocessor::isIncrementalProcessingEnabled(), and clang::Sema::SetLateTemplateParser().
Referenced by clang::ParseAST().
bool clang::Parser::ParseTopLevelDecl | ( | ) | [inline] |
Definition at line 272 of file Parse/Parser.h.
TypeResult Parser::ParseTypeName | ( | SourceRange * | Range = nullptr , |
Declarator::TheContext | Context = Declarator::TypeNameContext , |
||
AccessSpecifier | AS = AS_none , |
||
Decl ** | OwnedType = nullptr , |
||
ParsedAttributes * | Attrs = nullptr |
||
) |
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt]
Called type-id in C++.
Definition at line 41 of file ParseDecl.cpp.
References clang::Sema::ActOnTypeName(), clang::DeclSpec::addAttributes(), getCurScope(), clang::ParsedAttributes::getList(), clang::DeclSpec::getRepAsDecl(), clang::Declarator::getSourceRange(), clang::Declarator::isInvalidType(), and clang::DeclSpec::isTypeSpecOwned().
bool Parser::ParseUnqualifiedId | ( | CXXScopeSpec & | SS, |
bool | EnteringContext, | ||
bool | AllowDestructorName, | ||
bool | AllowConstructorName, | ||
ParsedType | ObjectType, | ||
SourceLocation & | TemplateKWLoc, | ||
UnqualifiedId & | Result | ||
) |
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
unqualified-id: [C++ expr.prim.general] identifier operator-function-id conversion-function-id [C++0x] literal-operator-id [TODO] ~ class-name template-id
SS | The nested-name-specifier that preceded this unqualified-id. If non-empty, then we are parsing the unqualified-id of a qualified-id. |
EnteringContext | whether we are entering the scope of the nested-name-specifier. |
AllowDestructorName | whether we allow parsing of a destructor name. |
AllowConstructorName | whether we allow parsing a constructor name. |
ObjectType | if this unqualified-id occurs within a member access expression, the type of the base object whose member is being accessed. |
Result | on a successful parse, contains the parsed unqualified-id. |
Definition at line 2326 of file ParseExprCXX.cpp.
References clang::CXXScopeSpec::clear(), ConsumeToken(), clang::frontend::CPlusPlus, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), Diag(), getCurScope(), clang::Sema::getDestructorName(), clang::Sema::getDestructorType(), clang::Token::getIdentifierInfo(), clang::UnqualifiedId::getKind(), getLangOpts(), clang::Token::getLocation(), clang::Sema::getTypeName(), clang::UnqualifiedId::IK_LiteralOperatorId, clang::UnqualifiedId::IK_OperatorFunctionId, clang::Token::is(), clang::Sema::isCurrentClassName(), clang::CXXScopeSpec::isEmpty(), clang::Token::isNot(), clang::CXXScopeSpec::isSet(), clang::TemplateIdAnnotation::LAngleLoc, clang::TemplateIdAnnotation::Name, NextToken(), clang::TemplateIdAnnotation::RAngleLoc, clang::UnqualifiedId::setConstructorName(), clang::UnqualifiedId::setConstructorTemplateId(), clang::UnqualifiedId::setDestructorName(), clang::UnqualifiedId::setIdentifier(), clang::UnqualifiedId::setTemplateId(), clang::TemplateIdAnnotation::TemplateKWLoc, and clang::TemplateIdAnnotation::TemplateNameLoc.
Referenced by ParseMSAsmIdentifier(), and ParseReductionId().
void Parser::SkipMalformedDecl | ( | ) |
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a simple-declaration.
Skip until we reach something which seems like a sensible place to pick up parsing after a malformed declaration. This will sometimes stop sooner than SkipUntil(tok::r_brace) would, but will never stop later.
Definition at line 1504 of file ParseDecl.cpp.
References ConsumeToken(), clang::comments::tok::eof, clang::Token::getKind(), clang::Token::is(), clang::Token::isAtStartOfLine(), clang::Token::isObjCAtKeyword(), NextToken(), SkipUntil(), and TryConsumeToken().
bool clang::Parser::SkipUntil | ( | tok::TokenKind | T, |
SkipUntilFlags | Flags = static_cast<SkipUntilFlags>(0) |
||
) | [inline] |
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch is specified). Because we cannot guarantee that the token will ever occur, this skips to the next token, or to some likely good stopping point. If Flags has StopAtSemi flag, skipping will stop at a ';' character.
If SkipUntil finds the specified token, it returns true, otherwise it returns false.
Definition at line 831 of file Parse/Parser.h.
Referenced by SkipMalformedDecl(), and SkipUntil().
bool clang::Parser::SkipUntil | ( | tok::TokenKind | T1, |
tok::TokenKind | T2, | ||
SkipUntilFlags | Flags = static_cast<SkipUntilFlags>(0) |
||
) | [inline] |
Definition at line 835 of file Parse/Parser.h.
References SkipUntil().
bool clang::Parser::SkipUntil | ( | tok::TokenKind | T1, |
tok::TokenKind | T2, | ||
tok::TokenKind | T3, | ||
SkipUntilFlags | Flags = static_cast<SkipUntilFlags>(0) |
||
) | [inline] |
Definition at line 840 of file Parse/Parser.h.
References SkipUntil().
bool Parser::SkipUntil | ( | ArrayRef< tok::TokenKind > | Toks, |
SkipUntilFlags | Flags = static_cast<SkipUntilFlags>(0) |
||
) |
SkipUntil - Read tokens until we get to the specified token, then consume it (unless no flag StopBeforeMatch). Because we cannot guarantee that the token will ever occur, this skips to the next token, or to some likely good stopping point. If StopAtSemi is true, skipping will stop at a ';' character.
If SkipUntil finds the specified token, it returns true, otherwise it returns false.
Definition at line 232 of file Parse/Parser.cpp.
References ConsumeToken(), clang::comments::tok::eof, clang::Token::getKind(), HasFlagsSet(), clang::Token::is(), clang::Token::isNot(), SkipUntil(), StopAtCodeCompletion, StopAtSemi, and StopBeforeMatch.
bool Parser::TryAnnotateCXXScopeToken | ( | bool | EnteringContext = false | ) |
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and template-ids. This returns true if there was an error that could not be recovered from.
Note that this routine emits an error if you call it with ::new or ::delete as the current tokens, so only call it in contexts where these are invalid.
Definition at line 1680 of file Parse/Parser.cpp.
References clang::frontend::CPlusPlus, getLangOpts(), clang::Token::is(), clang::CXXScopeSpec::isEmpty(), and NextToken().
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C++) or a C++ scope specifier not followed by a typename, TryAnnotateTypeOrScopeToken will replace one or more tokens with a single annotation token representing the typename or C++ scope respectively. This simplifies handling of C++ scope specifiers and allows efficient backtracking without the need to re-parse and resolve nested-names and typenames. It will mainly be called when we expect to treat identifiers as typenames (if they are typenames). For example, in C we do not expect identifiers inside expressions to be treated as typenames so it will not be called for expressions in C. The benefit for C/ObjC is that a typename will be annotated and Actions.getTypeName will not be needed to be called again (e.g. getTypeName will not be called twice, once to check whether we have a declaration specifier, and another one to get the actual type inside ParseDeclarationSpecifiers).
This returns true if an error occurred.
Note that this routine emits an error if you call it with ::new or ::delete as the current tokens, so only call it in contexts where these are invalid.
Definition at line 1471 of file Parse/Parser.cpp.
References clang::Sema::ActOnTypenameType(), clang::Preprocessor::AnnotateCachedTokens(), ConsumeToken(), clang::frontend::CPlusPlus, Diag(), clang::Preprocessor::EnterToken(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Token::getAnnotationRange(), getCurScope(), clang::Token::getIdentifierInfo(), getLangOpts(), clang::Token::getLastLoc(), clang::Token::getLocation(), clang::CXXScopeSpec::getRange(), clang::TemplateIdAnnotation::getTemplateArgs(), clang::Token::is(), clang::Token::isAnnotation(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::CXXScopeSpec::isSet(), clang::TemplateIdAnnotation::Kind, clang::TemplateIdAnnotation::LAngleLoc, clang::Preprocessor::Lex(), NextToken(), clang::TemplateIdAnnotation::NumArgs, clang::TemplateIdAnnotation::RAngleLoc, clang::Token::setAnnotationEndLoc(), clang::Token::setKind(), clang::Token::setLocation(), clang::TemplateIdAnnotation::Template, clang::TemplateIdAnnotation::TemplateKWLoc, clang::TemplateIdAnnotation::TemplateNameLoc, clang::TNK_Dependent_template_name, clang::TNK_Type_template, and TryAnnotateTypeOrScopeTokenAfterScopeSpec().
bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec | ( | bool | EnteringContext, |
bool | NeedType, | ||
CXXScopeSpec & | SS, | ||
bool | IsNewScope | ||
) |
Try to annotate a type or scope token, having already parsed an optional scope specifier. IsNewScope
should be true
unless the scope specifier was extracted from an existing tok::annot_cxxscope annotation.
Definition at line 1584 of file Parse/Parser.cpp.
References clang::Preprocessor::AnnotateCachedTokens(), ConsumeToken(), clang::frontend::CPlusPlus, clang::CXXScopeSpec::getBeginLoc(), getCurScope(), clang::Token::getIdentifierInfo(), getLangOpts(), clang::Token::getLocation(), clang::Sema::getTypeName(), clang::Token::is(), clang::CXXScopeSpec::isEmpty(), clang::CXXScopeSpec::isNotEmpty(), clang::Sema::isTemplateName(), clang::TemplateIdAnnotation::Kind, NextToken(), clang::Token::setAnnotationEndLoc(), clang::UnqualifiedId::setIdentifier(), clang::Token::setIdentifierInfo(), clang::Token::setKind(), clang::Token::setLocation(), and clang::TNK_Type_template.
Referenced by TryAnnotateTypeOrScopeToken().
bool clang::Parser::TryConsumeToken | ( | tok::TokenKind | Expected | ) | [inline] |
Definition at line 289 of file Parse/Parser.h.
References clang::Token::getLocation(), clang::Token::isNot(), and clang::Preprocessor::Lex().
Referenced by SkipMalformedDecl(), and TryConsumeToken().
bool clang::Parser::TryConsumeToken | ( | tok::TokenKind | Expected, |
SourceLocation & | Loc | ||
) | [inline] |
Definition at line 299 of file Parse/Parser.h.
References TryConsumeToken().
friend class BalancedDelimiterTracker [friend] |
Definition at line 60 of file Parse/Parser.h.
friend class ColonProtectionRAIIObject [friend] |
Definition at line 55 of file Parse/Parser.h.
friend class InMessageExpressionRAIIObject [friend] |
Definition at line 56 of file Parse/Parser.h.
friend class ObjCDeclContextSwitch [friend] |
Definition at line 58 of file Parse/Parser.h.
LLVM_CONSTEXPR SkipUntilFlags operator| | ( | SkipUntilFlags | L, |
SkipUntilFlags | R | ||
) | [friend] |
Definition at line 817 of file Parse/Parser.h.
friend class ParenBraceBracketBalancer [friend] |
Definition at line 59 of file Parse/Parser.h.
friend class PoisonSEHIdentifiersRAIIObject [friend] |
Definition at line 57 of file Parse/Parser.h.