clang  14.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
clang::Parser Class Reference

Parser - This implements a parser for the C family of languages. More...

#include "clang/Parse/Parser.h"

Inheritance diagram for clang::Parser:
Inheritance graph
[legend]
Collaboration diagram for clang::Parser:
Collaboration graph
[legend]

Classes

struct  ConditionDeclarationOrInitStatementState
 
class  MultiParseScope
 Introduces zero or more scopes for parsing. More...
 
class  ObjCTypeParamListScope
 Class to handle popping type parameters when leaving the scope. More...
 
struct  OpenMPVarListDataTy
 Data used for parsing list of variables in OpenMP clauses. More...
 
class  ParseScope
 ParseScope - Introduces a new scope for parsing. More...
 
struct  ReenterClassScopeRAII
 Utility to re-enter a class scope while parsing its late-parsed components. More...
 
struct  ReenterTemplateScopeRAII
 Utility to re-enter a possibly-templated scope while parsing its late-parsed components. More...
 
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< DeclGroupRefDeclGroupPtrTy
 
typedef OpaquePtr< TemplateNameTemplateTy
 
typedef SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
 
typedef Sema::FullExprArg FullExprArg
 

Public Member Functions

 Parser (Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
 
 ~Parser () override
 
const LangOptionsgetLangOpts () const
 
const TargetInfogetTargetInfo () const
 
PreprocessorgetPreprocessor () const
 
SemagetActions () const
 
AttributeFactorygetAttrFactory ()
 
const TokengetCurToken () const
 
ScopegetCurScope () const
 
void incrementMSManglingNumber () const
 
DeclgetObjCDeclContext () const
 
void Initialize ()
 Initialize - Warm up the parser. More...
 
bool ParseFirstTopLevelDecl (DeclGroupPtrTy &Result)
 Parse the first top-level declaration in a translation unit. More...
 
bool ParseTopLevelDecl (DeclGroupPtrTy &Result, bool IsFirstDecl=false)
 ParseTopLevelDecl - Parse one top-level declaration. More...
 
bool ParseTopLevelDecl ()
 
SourceLocation ConsumeToken ()
 ConsumeToken - Consume the current 'peek token' and lex the next one. More...
 
bool TryConsumeToken (tok::TokenKind Expected)
 
bool TryConsumeToken (tok::TokenKind Expected, SourceLocation &Loc)
 
SourceLocation ConsumeAnyToken (bool ConsumeCodeCompletionTok=false)
 ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type. More...
 
SourceLocation getEndOfPreviousToken ()
 
IdentifierInfogetNullabilityKeyword (NullabilityKind nullability)
 Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind. More...
 
const TokenNextToken ()
 NextToken - This peeks ahead one token and returns it without consuming it. More...
 
bool TryAnnotateTypeOrScopeToken ()
 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. More...
 
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec (CXXScopeSpec &SS, bool IsNewScope)
 Try to annotate a type or scope token, having already parsed an optional scope specifier. More...
 
bool TryAnnotateCXXScopeToken (bool EnteringContext=false)
 TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and template-ids. More...
 
bool MightBeCXXScopeToken ()
 
bool TryAnnotateOptionalCXXScopeToken (bool EnteringContext=false)
 
void EnterScope (unsigned ScopeFlags)
 EnterScope - Start a new scope. More...
 
void ExitScope ()
 ExitScope - Pop a scope off the scope stack. More...
 
unsigned ReenterTemplateScopes (MultiParseScope &S, Decl *D)
 Re-enter the template scopes for a declaration that might be a template. More...
 
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))
 SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch is specified). More...
 
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))
 SkipUntil - Read tokens until we get to the specified token, then consume it (unless no flag StopBeforeMatch). More...
 
void SkipMalformedDecl ()
 SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a simple-declaration. More...
 
ExprResult ParseExpression (TypeCastState isTypeCast=NotTypeCast)
 Simple precedence-based parser for binary/ternary operators. More...
 
ExprResult ParseConstantExpressionInExprEvalContext (TypeCastState isTypeCast=NotTypeCast)
 
ExprResult ParseConstantExpression (TypeCastState isTypeCast=NotTypeCast)
 
ExprResult ParseCaseExpression (SourceLocation CaseLoc)
 
ExprResult ParseConstraintExpression ()
 Parse a constraint-expression. More...
 
ExprResult ParseConstraintLogicalAndExpression (bool IsTrailingRequiresClause)
 Parse a constraint-logical-and-expression. More...
 
ExprResult ParseConstraintLogicalOrExpression (bool IsTrailingRequiresClause)
 Parse a constraint-logical-or-expression. More...
 
ExprResult ParseAssignmentExpression (TypeCastState isTypeCast=NotTypeCast)
 Parse an expr that doesn't include (top-level) commas. More...
 
ExprResult ParseMSAsmIdentifier (llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
 Parse an identifier in an MS-style inline assembly block. More...
 
ExprResult ParseStringLiteralExpression (bool AllowUserDefinedLiteral=false)
 
TypeResult ParseTypeName (SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
 ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt]. More...
 
ExprResult ParseOpenMPParensExpr (StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
 Parses simple expression in parens for single-expression clauses of OpenMP constructs. More...
 
bool ParseOpenMPVarList (OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr * > &Vars, OpenMPVarListDataTy &Data)
 Parses clauses with list. More...
 
bool ParseUnqualifiedId (CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
 Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity. More...
 
bool parseMapperModifier (OpenMPVarListDataTy &Data)
 Parses the mapper modifier in map, to, and from clauses. More...
 
bool parseMapTypeModifiers (OpenMPVarListDataTy &Data)
 Parses map-type-modifiers in map clause. More...
 
- Public Member Functions inherited from clang::CodeCompletionHandler
virtual ~CodeCompletionHandler ()
 

Static Public Member Functions

static TypeResult getTypeAnnotation (const Token &Tok)
 getTypeAnnotation - Read a parsed type out of an annotation token. More...
 

Public Attributes

SourceLocation MisleadingIndentationElseLoc
 The location of the first statement inside an else that might have a missleading indentation. More...
 

Friends

class ColonProtectionRAIIObject
 
class ParsingOpenMPDirectiveRAII
 
class InMessageExpressionRAIIObject
 
class PoisonSEHIdentifiersRAIIObject
 
class ObjCDeclContextSwitch
 
class ParenBraceBracketBalancer
 
class BalancedDelimiterTracker
 
constexpr friend SkipUntilFlags operator| (SkipUntilFlags L, SkipUntilFlags R)
 

Detailed Description

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 60 of file Parser.h.

Member Typedef Documentation

◆ DeclGroupPtrTy

Definition at line 453 of file Parser.h.

◆ FullExprArg

Definition at line 458 of file Parser.h.

◆ TemplateParameterLists

Definition at line 456 of file Parser.h.

◆ TemplateTy

Definition at line 454 of file Parser.h.

Member Enumeration Documentation

◆ SkipUntilFlags

Control flags for SkipUntil functions.

Enumerator
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 1183 of file Parser.h.

◆ TypeCastState

TypeCastState - State whether an expression is or may be a type cast.

Enumerator
NotTypeCast 
MaybeTypeCast 
IsTypeCast 

Definition at line 1731 of file Parser.h.

Constructor & Destructor Documentation

◆ Parser()

Parser::Parser ( Preprocessor PP,
Sema Actions,
bool  SkipFunctionBodies 
)

◆ ~Parser()

Parser::~Parser ( )
override

Member Function Documentation

◆ ConsumeAnyToken()

SourceLocation clang::Parser::ConsumeAnyToken ( bool  ConsumeCodeCompletionTok = false)
inline

ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.

This should only be used in cases where the type of the token really isn't known, e.g. in error recovery.

Definition at line 510 of file Parser.h.

References ConsumeToken(), clang::Token::is(), and clang::Token::isAnnotation().

Referenced by ParseMSAsmIdentifier(), SkipMalformedDecl(), and SkipUntil().

◆ ConsumeToken()

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, annotation tokens and balanced tokens must be handled using the specific consume methods. Returns the location of the consumed token.

Definition at line 482 of file Parser.h.

References clang::Token::getLocation(), and clang::Preprocessor::Lex().

Referenced by ConsumeAnyToken(), Initialize(), clang::Parser::ConditionDeclarationOrInitStatementState::markNotExpression(), ParseConstraintLogicalAndExpression(), ParseConstraintLogicalOrExpression(), ParseMSAsmIdentifier(), ParseTopLevelDecl(), ParseUnqualifiedId(), SkipMalformedDecl(), SkipUntil(), TryAnnotateTypeOrScopeToken(), and TryAnnotateTypeOrScopeTokenAfterScopeSpec().

◆ Diag() [1/3]

DiagnosticBuilder Parser::Diag ( const Token Tok,
unsigned  DiagID 
)

Definition at line 77 of file Parser.cpp.

References Diag(), and clang::Token::getLocation().

◆ Diag() [2/3]

DiagnosticBuilder Parser::Diag ( SourceLocation  Loc,
unsigned  DiagID 
)

◆ Diag() [3/3]

DiagnosticBuilder clang::Parser::Diag ( unsigned  DiagID)
inline

Definition at line 1171 of file Parser.h.

References Diag().

◆ EnterScope()

void Parser::EnterScope ( unsigned  ScopeFlags)

EnterScope - Start a new scope.

Definition at line 404 of file Parser.cpp.

References getCurScope(), and clang::Scope::Init().

Referenced by clang::Parser::MultiParseScope::Enter(), Initialize(), and clang::Parser::ParseScope::ParseScope().

◆ ExitScope()

void Parser::ExitScope ( )

ExitScope - Pop a scope off the scope stack.

Definition at line 415 of file Parser.cpp.

References clang::Sema::ActOnPopScope(), getCurScope(), clang::Token::getLocation(), and clang::Scope::getParent().

Referenced by clang::Parser::ParseScope::Exit(), and clang::Parser::MultiParseScope::Exit().

◆ getActions()

Sema& clang::Parser::getActions ( ) const
inline

Definition at line 440 of file Parser.h.

◆ getAttrFactory()

AttributeFactory& clang::Parser::getAttrFactory ( )
inline

Definition at line 441 of file Parser.h.

◆ getCurScope()

Scope* clang::Parser::getCurScope ( ) const
inline

◆ getCurToken()

const Token& clang::Parser::getCurToken ( ) const
inline

Definition at line 443 of file Parser.h.

◆ getEndOfPreviousToken()

SourceLocation clang::Parser::getEndOfPreviousToken ( )
inline

Definition at line 528 of file Parser.h.

References clang::Preprocessor::getLocForEndOfToken().

◆ getLangOpts()

const LangOptions& clang::Parser::getLangOpts ( ) const
inline

◆ getNullabilityKeyword()

IdentifierInfo* clang::Parser::getNullabilityKeyword ( NullabilityKind  nullability)
inline

Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind.

Definition at line 534 of file Parser.h.

References clang::Sema::getNullabilityKeyword().

◆ getObjCDeclContext()

Decl* clang::Parser::getObjCDeclContext ( ) const
inline

Definition at line 449 of file Parser.h.

References clang::Sema::getObjCDeclContext().

◆ getPreprocessor()

Preprocessor& clang::Parser::getPreprocessor ( ) const
inline

Definition at line 439 of file Parser.h.

◆ getTargetInfo()

const TargetInfo& clang::Parser::getTargetInfo ( ) const
inline

Definition at line 438 of file Parser.h.

References clang::Preprocessor::getTargetInfo().

◆ getTypeAnnotation()

static TypeResult clang::Parser::getTypeAnnotation ( const Token Tok)
inlinestatic

getTypeAnnotation - Read a parsed type out of an annotation token.

Definition at line 798 of file Parser.h.

References clang::Token::getAnnotationValue(), clang::OpaquePtr< QualType >::getFromOpaquePtr(), and clang::TypeError().

◆ incrementMSManglingNumber()

void clang::Parser::incrementMSManglingNumber ( ) const
inline

Definition at line 445 of file Parser.h.

References clang::Sema::incrementMSManglingNumber().

Referenced by clang::Parser::ParseScope::ParseScope().

◆ Initialize()

void Parser::Initialize ( )

◆ MightBeCXXScopeToken()

bool clang::Parser::MightBeCXXScopeToken ( )
inline

Definition at line 847 of file Parser.h.

References clang::Token::is(), and NextToken().

Referenced by TryAnnotateCXXScopeToken(), and TryAnnotateOptionalCXXScopeToken().

◆ NextToken()

const Token& clang::Parser::NextToken ( )
inline

◆ ParseAssignmentExpression()

ExprResult Parser::ParseAssignmentExpression ( TypeCastState  isTypeCast = NotTypeCast)

◆ ParseCaseExpression()

ExprResult Parser::ParseCaseExpression ( SourceLocation  CaseLoc)

◆ ParseConstantExpression()

ExprResult Parser::ParseConstantExpression ( TypeCastState  isTypeCast = NotTypeCast)

◆ ParseConstantExpressionInExprEvalContext()

ExprResult Parser::ParseConstantExpressionInExprEvalContext ( TypeCastState  isTypeCast = NotTypeCast)

◆ ParseConstraintExpression()

ExprResult Parser::ParseConstraintExpression ( )

◆ ParseConstraintLogicalAndExpression()

ExprResult Parser::ParseConstraintLogicalAndExpression ( bool  IsTrailingRequiresClause)

◆ ParseConstraintLogicalOrExpression()

ExprResult Parser::ParseConstraintLogicalOrExpression ( bool  IsTrailingRequiresClause)

Parse a constraint-logical-or-expression.

///       C++2a[temp.constr.decl]p1
///       constraint-logical-or-expression:
///         constraint-logical-and-expression
///         constraint-logical-or-expression '||'
///             constraint-logical-and-expression
///
/// 

Definition at line 349 of file ParseExpr.cpp.

References clang::Sema::ActOnBinOp(), ConsumeToken(), clang::Sema::CorrectDelayedTyposInExpr(), clang::ExprError(), clang::ActionResult< PtrTy, CompressInvalid >::get(), getCurScope(), clang::Token::is(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), and ParseConstraintLogicalAndExpression().

◆ ParseExpression()

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
///
///       compare-expression: [C++20 expr.spaceship]
///         shift-expression
///         compare-expression '<=>' shift-expression
///
///       relational-expression: [C99 6.5.8]
///         compare-expression
///         relational-expression '<' compare-expression
///         relational-expression '>' compare-expression
///         relational-expression '<=' compare-expression
///         relational-expression '>=' compare-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 123 of file ParseExpr.cpp.

References clang::prec::Comma, and ParseAssignmentExpression().

◆ ParseFirstTopLevelDecl()

bool Parser::ParseFirstTopLevelDecl ( DeclGroupPtrTy Result)

Parse the first top-level declaration in a translation unit.

translation-unit: [C] external-declaration [C] translation-unit external-declaration [C++] top-level-declaration-seq[opt] [C++20] global-module-fragment[opt] module-declaration top-level-declaration-seq[opt] private-module-fragment[opt]

Note that in C, it is an error if there is no first declaration.

Definition at line 584 of file Parser.cpp.

References clang::Sema::ActOnStartOfTranslationUnit(), clang::CPlusPlus, Diag(), clang::Sema::getASTContext(), clang::ASTContext::getExternalSource(), getLangOpts(), IsHeaderFile(), and ParseTopLevelDecl().

◆ parseMapperModifier()

bool Parser::parseMapperModifier ( OpenMPVarListDataTy Data)

◆ parseMapTypeModifiers()

bool Parser::parseMapTypeModifiers ( OpenMPVarListDataTy Data)

Parses map-type-modifiers in map clause.

Parse map-type-modifiers in map clause.

map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) where, map-type-modifier ::= always | close | mapper(mapper-identifier)

map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list) where, map-type-modifier ::= always | close | mapper(mapper-identifier) | present

Definition at line 3839 of file ParseOpenMP.cpp.

References Diag(), clang::Token::getLocation(), clang::Token::is(), isMapModifier(), clang::Parser::OpenMPVarListDataTy::MapTypeModifiers, and clang::Parser::OpenMPVarListDataTy::MapTypeModifiersLoc.

◆ ParseMSAsmIdentifier()

ExprResult Parser::ParseMSAsmIdentifier ( llvm::SmallVectorImpl< Token > &  LineToks,
unsigned NumLineToksConsumed,
bool  IsUnevaluated 
)

◆ ParseOpenMPParensExpr()

ExprResult Parser::ParseOpenMPParensExpr ( StringRef  ClauseName,
SourceLocation RLoc,
bool  IsAddressOfOperand = false 
)

◆ ParseOpenMPVarList()

bool Parser::ParseOpenMPVarList ( OpenMPDirectiveKind  DKind,
OpenMPClauseKind  Kind,
SmallVectorImpl< Expr * > &  Vars,
OpenMPVarListDataTy Data 
)

Parses clauses with list.

Definition at line 4015 of file ParseOpenMP.cpp.

References clang::Sema::ActOnFinishFullExpr(), clang::Parser::OpenMPVarListDataTy::ColonLoc, clang::BalancedDelimiterTracker::consumeClose(), clang::BalancedDelimiterTracker::consumeOpen(), clang::Sema::CorrectDelayedTyposInExpr(), clang::CPlusPlus, clang::Scope::DeclScope, clang::Parser::OpenMPVarListDataTy::DepModOrTailExpr, Diag(), clang::BalancedDelimiterTracker::expectAndConsume(), clang::Parser::OpenMPVarListDataTy::ExtraModifier, clang::Parser::OpenMPVarListDataTy::ExtraModifierLoc, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::BalancedDelimiterTracker::getCloseLocation(), clang::Token::getLocation(), clang::Sema::GetNameFromUnqualifiedId(), clang::BalancedDelimiterTracker::getOpenLocation(), clang::getOpenMPSimpleClauseType(), clang::Token::is(), clang::Parser::OpenMPVarListDataTy::IsMapTypeImplicit, clang::Token::isNot(), clang::isOpenMPDistributeDirective(), clang::isOpenMPTaskLoopDirective(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::Parser::OpenMPVarListDataTy::MotionModifiers, clang::Parser::OpenMPVarListDataTy::MotionModifiersLoc, clang::OMPC_ADJUST_ARGS_unknown, clang::OMPC_DEPEND_unknown, clang::OMPC_LASTPRIVATE_unknown, clang::OMPC_MAP_unknown, clang::OMPC_MOTION_MODIFIER_unknown, clang::OMPC_REDUCTION_unknown, clang::Scope::OpenMPDirectiveScope, parseMapType(), ParseReductionId(), clang::Parser::OpenMPVarListDataTy::ReductionOrMapperId, clang::Parser::OpenMPVarListDataTy::ReductionOrMapperIdScopeSpec, and clang::Parser::OpenMPVarListDataTy::RLoc.

◆ ParseStringLiteralExpression()

ExprResult clang::Parser::ParseStringLiteralExpression ( bool  AllowUserDefinedLiteral = false)

◆ ParseTopLevelDecl() [1/2]

bool clang::Parser::ParseTopLevelDecl ( )
inline

Definition at line 472 of file Parser.h.

Referenced by ParseFirstTopLevelDecl().

◆ ParseTopLevelDecl() [2/2]

bool Parser::ParseTopLevelDecl ( DeclGroupPtrTy Result,
bool  IsFirstDecl = false 
)

◆ ParseTypeName()

TypeResult Parser::ParseTypeName ( SourceRange Range = nullptr,
DeclaratorContext  Context = DeclaratorContext::TypeName,
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 43 of file ParseDecl.cpp.

References clang::Sema::ActOnTypeName(), clang::DeclSpec::addAttributes(), getCurScope(), clang::DeclSpec::getRepAsDecl(), clang::Declarator::getSourceRange(), clang::Declarator::isInvalidType(), and clang::DeclSpec::isTypeSpecOwned().

◆ ParseUnqualifiedId()

bool Parser::ParseUnqualifiedId ( CXXScopeSpec SS,
ParsedType  ObjectType,
bool  ObjectHadErrors,
bool  EnteringContext,
bool  AllowDestructorName,
bool  AllowConstructorName,
bool  AllowDeductionGuide,
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
Parameters
SSThe nested-name-specifier that preceded this unqualified-id. If non-empty, then we are parsing the unqualified-id of a qualified-id.
ObjectTypeif this unqualified-id occurs within a member access expression, the type of the base object whose member is being accessed.
ObjectHadErrorsif this unqualified-id occurs within a member access expression, indicates whether the original subexpressions had any errors. When true, diagnostics for missing 'template' keyword will be supressed.
EnteringContextwhether we are entering the scope of the nested-name-specifier.
AllowDestructorNamewhether we allow parsing of a destructor name.
AllowConstructorNamewhether we allow parsing a constructor name.
AllowDeductionGuidewhether we allow parsing a deduction guide name.
Resulton a successful parse, contains the parsed unqualified-id.
Returns
true if parsing fails, false otherwise.

Definition at line 2782 of file ParseExprCXX.cpp.

References clang::Sema::ActOnTemplateName(), clang::CXXScopeSpec::clear(), ConsumeToken(), clang::CPlusPlus, clang::CPlusPlus17, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), Diag(), clang::Sema::getConstructorName(), getCurScope(), clang::Sema::getDestructorName(), clang::Sema::getDestructorTypeForDecltype(), clang::Token::getIdentifierInfo(), clang::Decl::getKind(), getLangOpts(), clang::Token::getLocation(), Id, clang::IK_LiteralOperatorId, clang::IK_OperatorFunctionId, clang::Token::is(), clang::Sema::isCurrentClassName(), clang::Sema::isDeductionGuideName(), clang::CXXScopeSpec::isEmpty(), clang::TemplateIdAnnotation::isInvalid(), clang::Token::isNot(), clang::CXXScopeSpec::isNotEmpty(), clang::CXXScopeSpec::isSet(), clang::SourceLocation::isValid(), clang::TemplateIdAnnotation::LAngleLoc, clang::TemplateIdAnnotation::Name, NextToken(), clang::TemplateIdAnnotation::RAngleLoc, clang::Sema::ShouldEnterDeclaratorScope(), clang::TemplateIdAnnotation::TemplateKWLoc, clang::TemplateIdAnnotation::TemplateNameLoc, and clang::TNK_Non_template.

Referenced by ParseMSAsmIdentifier().

◆ ReenterTemplateScopes()

unsigned Parser::ReenterTemplateScopes ( MultiParseScope S,
Decl D 
)

Re-enter the template scopes for a declaration that might be a template.

Re-enter a possible template scope, creating as many template parameter scopes as necessary.

Returns
The number of template parameter scopes entered.

Definition at line 28 of file ParseTemplate.cpp.

Referenced by clang::Parser::ReenterTemplateScopeRAII::ReenterTemplateScopeRAII().

◆ SkipMalformedDecl()

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 1891 of file ParseDecl.cpp.

References ConsumeAnyToken(), ConsumeToken(), clang::comments::tok::eof, clang::Token::getKind(), clang::Token::isAtStartOfLine(), clang::Token::isOneOf(), NextToken(), SkipUntil(), and TryConsumeToken().

◆ SkipUntil() [1/4]

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 278 of file Parser.cpp.

References ConsumeAnyToken(), ConsumeToken(), clang::comments::tok::eof, clang::Token::getKind(), HasFlagsSet(), clang::Token::is(), clang::Token::isNot(), SkipUntil(), StopAtCodeCompletion, StopAtSemi, and StopBeforeMatch.

◆ SkipUntil() [2/4]

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. Balances (), [], and {} delimiter tokens while skipping.

If SkipUntil finds the specified token, it returns true, otherwise it returns false.

Definition at line 1205 of file Parser.h.

Referenced by clang::BalancedDelimiterTracker::expectAndConsume(), clang::Parser::ConditionDeclarationOrInitStatementState::markNotExpression(), SkipMalformedDecl(), clang::BalancedDelimiterTracker::skipToEnd(), and SkipUntil().

◆ SkipUntil() [3/4]

bool clang::Parser::SkipUntil ( tok::TokenKind  T1,
tok::TokenKind  T2,
SkipUntilFlags  Flags = static_cast<SkipUntilFlags>(0) 
)
inline

Definition at line 1209 of file Parser.h.

References SkipUntil().

◆ SkipUntil() [4/4]

bool clang::Parser::SkipUntil ( tok::TokenKind  T1,
tok::TokenKind  T2,
tok::TokenKind  T3,
SkipUntilFlags  Flags = static_cast<SkipUntilFlags>(0) 
)
inline

Definition at line 1214 of file Parser.h.

References SkipUntil().

◆ TryAnnotateCXXScopeToken()

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 2080 of file Parser.cpp.

References clang::CPlusPlus, getLangOpts(), clang::CXXScopeSpec::isEmpty(), and MightBeCXXScopeToken().

Referenced by TryAnnotateOptionalCXXScopeToken().

◆ TryAnnotateOptionalCXXScopeToken()

bool clang::Parser::TryAnnotateOptionalCXXScopeToken ( bool  EnteringContext = false)
inline

Definition at line 853 of file Parser.h.

References MightBeCXXScopeToken(), and TryAnnotateCXXScopeToken().

◆ TryAnnotateTypeOrScopeToken()

bool Parser::TryAnnotateTypeOrScopeToken ( )

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 1851 of file Parser.cpp.

References clang::Sema::ActOnTypenameType(), clang::Preprocessor::AnnotateCachedTokens(), ConsumeToken(), clang::CPlusPlus, Diag(), clang::Preprocessor::EnterToken(), 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::Token::isEditorPlaceholder(), clang::CXXScopeSpec::isEmpty(), clang::TemplateIdAnnotation::isInvalid(), clang::TemplateIdAnnotation::LAngleLoc, clang::Preprocessor::Lex(), clang::TemplateIdAnnotation::mightBeType(), clang::TemplateIdAnnotation::Name, 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, TryAnnotateTypeOrScopeTokenAfterScopeSpec(), and clang::TypeError().

◆ TryAnnotateTypeOrScopeTokenAfterScopeSpec()

bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec ( CXXScopeSpec SS,
bool  IsNewScope 
)

◆ TryConsumeToken() [1/2]

bool clang::Parser::TryConsumeToken ( tok::TokenKind  Expected)
inline

◆ TryConsumeToken() [2/2]

bool clang::Parser::TryConsumeToken ( tok::TokenKind  Expected,
SourceLocation Loc 
)
inline

Definition at line 500 of file Parser.h.

References TryConsumeToken().

Friends And Related Function Documentation

◆ BalancedDelimiterTracker

friend class BalancedDelimiterTracker
friend

Definition at line 67 of file Parser.h.

◆ ColonProtectionRAIIObject

friend class ColonProtectionRAIIObject
friend

Definition at line 61 of file Parser.h.

◆ InMessageExpressionRAIIObject

friend class InMessageExpressionRAIIObject
friend

Definition at line 63 of file Parser.h.

◆ ObjCDeclContextSwitch

friend class ObjCDeclContextSwitch
friend

Definition at line 65 of file Parser.h.

◆ operator|

constexpr friend SkipUntilFlags operator| ( SkipUntilFlags  L,
SkipUntilFlags  R 
)
friend

Definition at line 1190 of file Parser.h.

◆ ParenBraceBracketBalancer

friend class ParenBraceBracketBalancer
friend

Definition at line 66 of file Parser.h.

◆ ParsingOpenMPDirectiveRAII

friend class ParsingOpenMPDirectiveRAII
friend

Definition at line 62 of file Parser.h.

◆ PoisonSEHIdentifiersRAIIObject

friend class PoisonSEHIdentifiersRAIIObject
friend

Definition at line 64 of file Parser.h.

Member Data Documentation

◆ MisleadingIndentationElseLoc

SourceLocation clang::Parser::MisleadingIndentationElseLoc

The location of the first statement inside an else that might have a missleading indentation.

If there is no MisleadingIndentationChecker on an else active, this location is invalid.

Definition at line 1229 of file Parser.h.


The documentation for this class was generated from the following files:
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::ast_matchers::expr
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchersInternal.cpp:890
x
IRgen optimization opportunities The common pattern of short x
Definition: README.txt:7
clang::transformer::name
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
Definition: RangeSelector.cpp:200