13 #ifndef LLVM_CLANG_PARSE_PARSER_H 14 #define LLVM_CLANG_PARSE_PARSER_H 26 #include "llvm/ADT/SmallVector.h" 27 #include "llvm/Support/Compiler.h" 28 #include "llvm/Support/PrettyStackTrace.h" 29 #include "llvm/Support/SaveAndRestore.h" 36 class BalancedDelimiterTracker;
37 class CorrectionCandidateCallback;
39 class DiagnosticBuilder;
42 class ParsingDeclRAIIObject;
43 class ParsingDeclSpec;
44 class ParsingDeclarator;
45 class ParsingFieldDeclarator;
46 class ColonProtectionRAIIObject;
47 class InMessageExpressionRAIIObject;
48 class PoisonSEHIdentifiersRAIIObject;
50 class ObjCTypeParamList;
51 class ObjCTypeParameter;
82 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
83 unsigned short MisplacedModuleBeginCount = 0;
92 enum { ScopeCacheSize = 16 };
93 unsigned NumCachedScopes;
94 Scope *ScopeCache[ScopeCacheSize];
100 *Ident___exception_code,
101 *Ident_GetExceptionCode;
104 *Ident___exception_info,
105 *Ident_GetExceptionInfo;
108 *Ident___abnormal_termination,
109 *Ident_AbnormalTermination;
152 *Ident_generated_declaration;
165 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
167 std::unique_ptr<PragmaHandler> AlignHandler;
168 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
169 std::unique_ptr<PragmaHandler> OptionsHandler;
170 std::unique_ptr<PragmaHandler> PackHandler;
171 std::unique_ptr<PragmaHandler> MSStructHandler;
172 std::unique_ptr<PragmaHandler> UnusedHandler;
173 std::unique_ptr<PragmaHandler> WeakHandler;
174 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
175 std::unique_ptr<PragmaHandler> FPContractHandler;
176 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
177 std::unique_ptr<PragmaHandler> OpenMPHandler;
178 std::unique_ptr<PragmaHandler> PCSectionHandler;
179 std::unique_ptr<PragmaHandler> MSCommentHandler;
180 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
181 std::unique_ptr<PragmaHandler> MSPointersToMembers;
182 std::unique_ptr<PragmaHandler> MSVtorDisp;
183 std::unique_ptr<PragmaHandler> MSInitSeg;
184 std::unique_ptr<PragmaHandler> MSDataSeg;
185 std::unique_ptr<PragmaHandler> MSBSSSeg;
186 std::unique_ptr<PragmaHandler> MSConstSeg;
187 std::unique_ptr<PragmaHandler> MSCodeSeg;
188 std::unique_ptr<PragmaHandler> MSSection;
189 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
190 std::unique_ptr<PragmaHandler> MSIntrinsic;
191 std::unique_ptr<PragmaHandler> MSOptimize;
192 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
193 std::unique_ptr<PragmaHandler> OptimizeHandler;
194 std::unique_ptr<PragmaHandler> LoopHintHandler;
195 std::unique_ptr<PragmaHandler> UnrollHintHandler;
196 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
197 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
198 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
199 std::unique_ptr<PragmaHandler> FPHandler;
200 std::unique_ptr<PragmaHandler> STDCFENVHandler;
201 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
202 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
203 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
205 std::unique_ptr<CommentHandler> CommentSemaHandler;
211 bool GreaterThanIsOperator;
220 bool OpenMPDirectiveParsing =
false;
227 bool InMessageExpression;
232 bool CalledSignatureHelp =
false;
235 unsigned TemplateParameterDepth;
238 class TemplateParameterDepthRAII {
240 unsigned AddedLevels;
242 explicit TemplateParameterDepthRAII(
unsigned &Depth)
243 : Depth(Depth), AddedLevels(0) {}
245 ~TemplateParameterDepthRAII() {
246 Depth -= AddedLevels;
253 void addDepth(
unsigned D) {
257 void setAddedDepth(
unsigned D) {
258 Depth = Depth - AddedLevels + D;
262 unsigned getDepth()
const {
return Depth; }
263 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
286 struct AngleBracketTracker {
296 SpaceBeforeLess = 0x0,
298 NoSpaceBeforeLess = 0x1,
300 LLVM_MARK_AS_BITMASK_ENUM( DependentName)
310 return P.ParenCount == ParenCount && P.BracketCount == BracketCount &&
311 P.BraceCount == BraceCount;
315 return isActive(P) || P.ParenCount > ParenCount ||
316 P.BracketCount > BracketCount || P.BraceCount > BraceCount;
329 if (!Locs.empty() && Locs.back().isActive(P)) {
330 if (Locs.back().Priority <= Prio) {
331 Locs.back().TemplateName = TemplateName;
332 Locs.back().LessLoc = LessLoc;
333 Locs.back().Priority = Prio;
336 Locs.push_back({TemplateName, LessLoc, Prio,
337 P.ParenCount, P.BracketCount, P.BraceCount});
345 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
352 if (!Locs.empty() && Locs.back().isActive(P))
358 AngleBracketTracker AngleBrackets;
367 bool ParsingInObjCContainer;
373 bool SkipFunctionBodies;
381 enum class ParsedStmtContext {
384 AllowDeclarationsInC = 0x1,
386 AllowStandaloneOpenMPDirectives = 0x2,
393 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
395 LLVM_MARK_AS_BITMASK_ENUM(InStmtExpr)
453 assert(!isTokenSpecial() &&
454 "Should consume special tokens with Consume*Token");
457 return PrevTokLocation;
461 if (Tok.
isNot(Expected))
463 assert(!isTokenSpecial() &&
464 "Should consume special tokens with Consume*Token");
473 Loc = PrevTokLocation;
482 return ConsumeParen();
483 if (isTokenBracket())
484 return ConsumeBracket();
486 return ConsumeBrace();
487 if (isTokenStringLiteral())
488 return ConsumeStringToken();
489 if (Tok.
is(tok::code_completion))
490 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
491 : handleUnexpectedCodeCompletionToken();
493 return ConsumeAnnotationToken();
514 bool isTokenParen()
const {
515 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
518 bool isTokenBracket()
const {
519 return Tok.
isOneOf(tok::l_square, tok::r_square);
522 bool isTokenBrace()
const {
523 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
526 bool isTokenStringLiteral()
const {
530 bool isTokenSpecial()
const {
531 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
532 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
537 bool isTokenEqualOrEqualTypo();
541 void UnconsumeToken(
Token &Consumed) {
559 assert(isTokenParen() &&
"wrong consume method");
560 if (Tok.
getKind() == tok::l_paren)
562 else if (ParenCount) {
563 AngleBrackets.clear(*
this);
568 return PrevTokLocation;
574 assert(isTokenBracket() &&
"wrong consume method");
575 if (Tok.
getKind() == tok::l_square)
577 else if (BracketCount) {
578 AngleBrackets.clear(*
this);
584 return PrevTokLocation;
590 assert(isTokenBrace() &&
"wrong consume method");
591 if (Tok.
getKind() == tok::l_brace)
593 else if (BraceCount) {
594 AngleBrackets.clear(*
this);
600 return PrevTokLocation;
608 assert(isTokenStringLiteral() &&
609 "Should only consume string literals with this method");
612 return PrevTokLocation;
621 assert(Tok.
is(tok::code_completion));
624 return PrevTokLocation;
636 void cutOffParsing() {
647 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
648 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
658 void initializePragmaHandlers();
661 void resetPragmaHandlers();
664 void HandlePragmaUnused();
668 void HandlePragmaVisibility();
672 void HandlePragmaPack();
676 void HandlePragmaMSStruct();
680 void HandlePragmaMSComment();
682 void HandlePragmaMSPointersToMembers();
684 void HandlePragmaMSVtorDisp();
686 void HandlePragmaMSPragma();
687 bool HandlePragmaMSSection(StringRef PragmaName,
689 bool HandlePragmaMSSegment(StringRef PragmaName,
691 bool HandlePragmaMSInitSeg(StringRef PragmaName,
696 void HandlePragmaAlign();
700 void HandlePragmaDump();
704 void HandlePragmaWeak();
708 void HandlePragmaWeakAlias();
712 void HandlePragmaRedefineExtname();
716 void HandlePragmaFPContract();
720 void HandlePragmaFEnvAccess();
724 void HandlePragmaFP();
728 void HandlePragmaOpenCLExtension();
736 bool HandlePragmaLoopHint(
LoopHint &Hint);
738 bool ParsePragmaAttributeSubjectMatchRuleSet(
742 void HandlePragmaAttribute();
751 const Token &GetLookAheadToken(
unsigned N) {
810 return Tok.
is(tok::identifier) || Tok.
is(tok::coloncolon) ||
811 (Tok.
is(tok::annot_template_id) &&
813 Tok.
is(tok::kw_decltype) || Tok.
is(tok::kw___super);
820 enum AnnotatedNameKind {
835 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
841 const char *&PrevSpec,
unsigned &DiagID,
851 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
857 bool TryAltiVecVectorToken() {
860 return TryAltiVecVectorTokenOutOfLine();
863 bool TryAltiVecVectorTokenOutOfLine();
865 const char *&PrevSpec,
unsigned &DiagID,
871 bool isObjCInstancetype() {
875 if (!Ident_instancetype)
885 bool TryKeywordIdentFallback(
bool DisableKeyword);
901 class TentativeParsingAction {
905 size_t PrevTentativelyDeclaredIdentifierCount;
906 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
910 explicit TentativeParsingAction(
Parser& p) :
P(p) {
911 PrevPreferredType = P.PreferredType;
913 PrevTentativelyDeclaredIdentifierCount =
914 P.TentativelyDeclaredIdentifiers.size();
915 PrevParenCount = P.ParenCount;
916 PrevBracketCount = P.BracketCount;
917 PrevBraceCount = P.BraceCount;
922 assert(isActive &&
"Parsing action was finished!");
923 P.TentativelyDeclaredIdentifiers.resize(
924 PrevTentativelyDeclaredIdentifierCount);
929 assert(isActive &&
"Parsing action was finished!");
931 P.PreferredType = PrevPreferredType;
933 P.TentativelyDeclaredIdentifiers.resize(
934 PrevTentativelyDeclaredIdentifierCount);
935 P.ParenCount = PrevParenCount;
936 P.BracketCount = PrevBracketCount;
937 P.BraceCount = PrevBraceCount;
940 ~TentativeParsingAction() {
941 assert(!isActive &&
"Forgot to call Commit or Revert!");
946 class RevertingTentativeParsingAction
947 :
private Parser::TentativeParsingAction {
949 RevertingTentativeParsingAction(
Parser &
P)
950 : Parser::TentativeParsingAction(P) {}
951 ~RevertingTentativeParsingAction() { Revert(); }
966 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
985 unsigned Diag = diag::err_expected,
986 StringRef DiagMsg =
"");
993 bool ExpectAndConsumeSemi(
unsigned DiagID);
999 InstanceVariableList = 2,
1000 AfterMemberFunctionDefinition = 3
1012 bool expectIdentifier();
1034 bool BeforeCompoundStmt =
false)
1036 if (EnteredScope && !BeforeCompoundStmt)
1039 if (BeforeCompoundStmt)
1042 this->Self =
nullptr;
1068 class ParseScopeFlags {
1071 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1072 void operator=(
const ParseScopeFlags &) =
delete;
1075 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1086 return Diag(Tok, DiagID);
1107 static_cast<unsigned>(R));
1120 return SkipUntil(llvm::makeArrayRef(T), Flags);
1148 struct ParsingClass;
1158 class LateParsedDeclaration {
1160 virtual ~LateParsedDeclaration();
1162 virtual void ParseLexedMethodDeclarations();
1163 virtual void ParseLexedMemberInitializers();
1164 virtual void ParseLexedMethodDefs();
1165 virtual void ParseLexedAttributes();
1166 virtual void ParseLexedPragmas();
1171 class LateParsedClass :
public LateParsedDeclaration {
1173 LateParsedClass(
Parser *
P, ParsingClass *
C);
1174 ~LateParsedClass()
override;
1176 void ParseLexedMethodDeclarations()
override;
1177 void ParseLexedMemberInitializers()
override;
1178 void ParseLexedMethodDefs()
override;
1179 void ParseLexedAttributes()
override;
1180 void ParseLexedPragmas()
override;
1184 ParsingClass *Class;
1193 struct LateParsedAttribute :
public LateParsedDeclaration {
1203 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1205 void ParseLexedAttributes()
override;
1207 void addDecl(
Decl *D) { Decls.push_back(D); }
1214 class LateParsedPragma :
public LateParsedDeclaration {
1221 : Self(P), AS(AS) {}
1223 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1227 void ParseLexedPragmas()
override;
1231 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1233 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1235 bool parseSoon() {
return ParseSoon; }
1244 struct LexedMethod :
public LateParsedDeclaration {
1255 : Self(P), D(MD), TemplateScope(
false) {}
1257 void ParseLexedMethodDefs()
override;
1264 struct LateParsedDefaultArgument {
1265 explicit LateParsedDefaultArgument(
Decl *
P,
1266 std::unique_ptr<CachedTokens> Toks =
nullptr)
1267 : Param(P), Toks(
std::move(Toks)) { }
1276 std::unique_ptr<CachedTokens> Toks;
1283 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1284 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1285 : Self(P), Method(M), TemplateScope(
false),
1286 ExceptionSpecTokens(nullptr) {}
1288 void ParseLexedMethodDeclarations()
override;
1315 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1317 : Self(P), Field(FD) { }
1319 void ParseLexedMemberInitializers()
override;
1342 struct ParsingClass {
1343 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1344 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1345 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1349 bool TopLevelClass : 1;
1354 bool TemplateScope : 1;
1357 bool IsInterface : 1;
1360 Decl *TagOrTemplate;
1365 LateParsedDeclarationsContainer LateParsedDeclarations;
1371 std::stack<ParsingClass *> ClassStack;
1373 ParsingClass &getCurrentClass() {
1374 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1375 return *ClassStack.top();
1379 class ParsingClassDefinition {
1385 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1387 : P(P), Popped(
false),
1388 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1393 assert(!Popped &&
"Nested class has already been popped");
1395 P.PopParsingClass(State);
1398 ~ParsingClassDefinition() {
1400 P.PopParsingClass(State);
1407 struct ParsedTemplateInfo {
1408 ParsedTemplateInfo()
1409 : Kind(NonTemplate), TemplateParams(nullptr), TemplateLoc() { }
1411 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1412 bool isSpecialization,
1413 bool lastParameterListWasEmpty =
false)
1414 : Kind(isSpecialization? ExplicitSpecialization : Template),
1415 TemplateParams(TemplateParams),
1416 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1420 : Kind(ExplicitInstantiation), TemplateParams(nullptr),
1421 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1422 LastParameterListWasEmpty(
false){ }
1431 ExplicitSpecialization,
1433 ExplicitInstantiation
1438 TemplateParameterLists *TemplateParams;
1449 bool LastParameterListWasEmpty;
1454 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1458 static
void LateTemplateParserCleanupCallback(
void *P);
1460 Sema::ParsingClassState
1461 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1462 void DeallocateParsedClasses(ParsingClass *Class);
1463 void PopParsingClass(
Sema::ParsingClassState);
1465 enum CachedInitKind {
1466 CIK_DefaultArgument,
1467 CIK_DefaultInitializer
1473 const ParsedTemplateInfo &TemplateInfo,
1476 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1477 void ParseLexedAttributes(ParsingClass &Class);
1478 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1479 bool EnterScope,
bool OnDefinition);
1480 void ParseLexedAttribute(LateParsedAttribute &LA,
1481 bool EnterScope,
bool OnDefinition);
1482 void ParseLexedMethodDeclarations(ParsingClass &Class);
1483 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1484 void ParseLexedMethodDefs(ParsingClass &Class);
1485 void ParseLexedMethodDef(LexedMethod &LM);
1486 void ParseLexedMemberInitializers(ParsingClass &Class);
1487 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1488 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1489 void ParseLexedPragmas(ParsingClass &Class);
1490 void ParseLexedPragma(LateParsedPragma &LP);
1491 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1492 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1497 bool ConsumeFinalToken =
true) {
1498 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1503 bool ConsumeFinalToken =
true);
1520 void clearListOnly() {
1528 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1530 bool isDeclarationAfterDeclarator();
1532 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1533 ParsedAttributesWithRange &attrs,
1536 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1540 void SkipFunctionBody();
1542 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1543 LateParsedAttrList *LateParsedAttrs =
nullptr);
1544 void ParseKNRParamDeclarations(
Declarator &D);
1547 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1551 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs);
1552 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1565 bool RBraceMissing);
1566 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1571 bool WarnOnDeclarations,
1572 bool ForObjCContainer,
1575 bool consumeLastToken);
1580 void parseObjCTypeArgsOrProtocolQualifiers(
1589 bool consumeLastToken,
1590 bool warnOnIncompleteProtocols);
1594 void parseObjCTypeArgsAndProtocolQualifiers(
1603 bool consumeLastToken);
1613 bool consumeLastToken,
1618 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1621 struct ObjCImplParsingDataRAII {
1626 LateParsedObjCMethodContainer LateParsedObjCMethods;
1628 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1629 : P(parser), Dcl(D), HasCFunction(
false) {
1630 P.CurParsedObjCImpl =
this;
1633 ~ObjCImplParsingDataRAII();
1636 bool isFinished()
const {
return Finished; }
1641 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1642 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1644 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
1646 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1654 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1655 objc_nonnull, objc_nullable, objc_null_unspecified,
1660 bool isTokIdentifier_in()
const;
1664 void ParseObjCMethodRequirement();
1665 Decl *ParseObjCMethodPrototype(
1667 bool MethodDefinition =
true);
1670 bool MethodDefinition=
true);
1673 Decl *ParseObjCMethodDefinition();
1699 unsigned &NumLineToksConsumed,
1700 bool IsUnevaluated);
1710 enum CastParseKind {
1715 ExprResult ParseCastExpression(CastParseKind ParseKind,
1716 bool isAddressOfOperand,
1719 bool isVectorLiteral =
false,
1720 bool *NotPrimaryExpression =
nullptr);
1721 ExprResult ParseCastExpression(CastParseKind ParseKind,
1722 bool isAddressOfOperand =
false,
1724 bool isVectorLiteral =
false,
1725 bool *NotPrimaryExpression =
nullptr);
1728 bool isNotExpressionStart();
1732 bool isPostfixExpressionSuffixStart() {
1734 return (K == tok::l_square || K == tok::l_paren ||
1735 K == tok::period || K == tok::arrow ||
1736 K == tok::plusplus || K == tok::minusminus);
1740 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1742 const Token &OpToken);
1743 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1744 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1745 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1750 ExprResult ParseUnaryExprOrTypeTraitExpression();
1764 llvm::function_ref<
void()> ExpressionStarts =
1765 llvm::function_ref<
void()>());
1774 enum ParenParseOption {
1781 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1782 bool stopIfCastExpr,
1788 ParenParseOption &ExprType,
ParsedType &CastTy,
1794 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1796 ExprResult ParseGenericSelectionExpression();
1805 Token &Replacement);
1806 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1808 bool areTokensAdjacent(
const Token &A,
const Token &B);
1810 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1815 bool EnteringContext,
1816 bool *MayBePseudoDestructor =
nullptr,
1817 bool IsTypename =
false,
1819 bool OnlyNamespace =
false,
1820 bool InUsingDeclaration =
false);
1826 enum class LambdaIntroducerTentativeParse {
1844 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1894 bool MayBeFollowedByDirectInit);
1907 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1909 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1915 void ParseDirectNewDeclarator(
Declarator &D);
1917 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1922 struct ForRangeInfo;
1926 ForRangeInfo *FRI =
nullptr);
1937 void ParseTrailingRequiresClause(
Declarator &D);
1947 if (Tok.
isNot(tok::l_brace))
1949 return ParseBraceInitializer();
1951 bool MayBeDesignationStart();
1953 ExprResult ParseInitializerWithPotentialDesignator();
1973 bool isSimpleObjCMessageExpression();
1978 Expr *ReceiverExpr);
1979 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1982 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1997 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
1999 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2001 StmtResult ParseStatementOrDeclarationAfterAttributes(
2003 ParsedStmtContext StmtCtx,
2005 ParsedAttributesWithRange &Attrs);
2006 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2007 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs,
2008 ParsedStmtContext StmtCtx);
2009 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2010 bool MissingCase =
false,
2012 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2013 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2014 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2015 unsigned ScopeFlags);
2016 void ParseCompoundStatementLeadingPragmas();
2017 bool ConsumeNullStmt(StmtVector &Stmts);
2018 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2019 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2034 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
2035 ParsedStmtContext StmtCtx,
2037 ParsedAttributesWithRange &Attrs);
2041 enum IfExistsBehavior {
2053 struct IfExistsCondition {
2068 IfExistsBehavior Behavior;
2071 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2072 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
2073 void ParseMicrosoftIfExistsExternalDeclaration();
2077 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2088 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2102 ParsedStmtContext StmtCtx);
2115 enum class DeclSpecContext {
2120 DSC_alias_declaration,
2123 DSC_template_type_arg,
2124 DSC_objc_method_result,
2130 static bool isTypeSpecifier(DeclSpecContext DSC) {
2132 case DeclSpecContext::DSC_normal:
2133 case DeclSpecContext::DSC_template_param:
2134 case DeclSpecContext::DSC_class:
2135 case DeclSpecContext::DSC_top_level:
2136 case DeclSpecContext::DSC_objc_method_result:
2137 case DeclSpecContext::DSC_condition:
2140 case DeclSpecContext::DSC_template_type_arg:
2141 case DeclSpecContext::DSC_type_specifier:
2142 case DeclSpecContext::DSC_trailing:
2143 case DeclSpecContext::DSC_alias_declaration:
2146 llvm_unreachable(
"Missing DeclSpecContext case");
2151 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2153 case DeclSpecContext::DSC_normal:
2154 case DeclSpecContext::DSC_template_param:
2155 case DeclSpecContext::DSC_class:
2156 case DeclSpecContext::DSC_top_level:
2157 case DeclSpecContext::DSC_condition:
2158 case DeclSpecContext::DSC_type_specifier:
2161 case DeclSpecContext::DSC_objc_method_result:
2162 case DeclSpecContext::DSC_template_type_arg:
2163 case DeclSpecContext::DSC_trailing:
2164 case DeclSpecContext::DSC_alias_declaration:
2167 llvm_unreachable(
"Missing DeclSpecContext case");
2172 struct ForRangeInit {
2176 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2178 struct ForRangeInfo : ForRangeInit {
2184 ParsedAttributesWithRange &attrs,
2188 ParsedAttributesWithRange &attrs,
bool RequireSemi,
2189 ForRangeInit *FRI =
nullptr,
2194 ForRangeInit *FRI =
nullptr);
2196 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2197 bool ParseAsmAttributesAfterDeclarator(
Declarator &D);
2198 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2200 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2201 ForRangeInit *FRI =
nullptr);
2209 bool trySkippingFunctionBody();
2212 const ParsedTemplateInfo &TemplateInfo,
2214 ParsedAttributesWithRange &Attrs);
2217 void ParseDeclarationSpecifiers(
2219 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2221 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2222 LateParsedAttrList *LateAttrs =
nullptr);
2223 bool DiagnoseMissingSemiAfterTagDefinition(
2225 LateParsedAttrList *LateAttrs =
nullptr);
2227 void ParseSpecifierQualifierList(
2229 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2235 const ParsedTemplateInfo &TemplateInfo,
2241 void ParseStructDeclaration(
2245 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2246 bool isTypeSpecifierQualifier();
2251 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2256 bool isKnownToBeDeclarationSpecifier() {
2258 return isCXXDeclarationSpecifier() == TPResult::True;
2259 return isDeclarationSpecifier(
true);
2265 bool isDeclarationStatement() {
2267 return isCXXDeclarationStatement();
2268 return isDeclarationSpecifier(
true);
2275 bool isForInitDeclaration() {
2279 return isCXXSimpleDeclaration(
true);
2280 return isDeclarationSpecifier(
true);
2284 bool isForRangeIdentifier();
2288 bool isStartOfObjCClassMessageMissingOpenBracket();
2293 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2297 enum TentativeCXXTypeIdContext {
2300 TypeIdAsTemplateArgument
2307 bool isTypeIdInParens(
bool &isAmbiguous) {
2309 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2310 isAmbiguous =
false;
2311 return isTypeSpecifierQualifier();
2313 bool isTypeIdInParens() {
2315 return isTypeIdInParens(isAmbiguous);
2321 bool isTypeIdUnambiguously() {
2324 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2325 return isTypeSpecifierQualifier();
2331 bool isCXXDeclarationStatement();
2338 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2347 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2350 enum class ConditionOrInitStatement {
2360 ConditionOrInitStatement
2361 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2362 bool CanBeForRangeDecl);
2364 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2365 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2367 return isCXXTypeId(Context, isAmbiguous);
2372 enum class TPResult {
2373 True, False, Ambiguous, Error
2396 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2397 bool *InvalidAsDeclSpec =
nullptr);
2402 bool isCXXDeclarationSpecifierAType();
2407 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2412 TPResult isExplicitBool();
2426 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2427 TPResult TryParseTypeofSpecifier();
2428 TPResult TryParseProtocolQualifiers();
2429 TPResult TryParsePtrOperatorSeq();
2430 TPResult TryParseOperatorId();
2431 TPResult TryParseInitDeclaratorList();
2432 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2433 bool mayHaveDirectInit =
false);
2435 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2436 bool VersusTemplateArg =
false);
2437 TPResult TryParseFunctionDeclarator();
2438 TPResult TryParseBracketDeclarator();
2439 TPResult TryConsumeDeclarationSpecifier();
2446 Decl **OwnedType =
nullptr,
2453 bool standardAttributesAllowed()
const {
2455 return LO.DoubleSquareBracketAttributes;
2460 bool CheckProhibitedCXX11Attribute() {
2461 assert(Tok.
is(tok::l_square));
2462 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2464 return DiagnoseProhibitedCXX11Attribute();
2467 bool DiagnoseProhibitedCXX11Attribute();
2468 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2470 if (!standardAttributesAllowed())
2473 Tok.
isNot(tok::kw_alignas))
2475 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2477 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2480 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2484 void ProhibitAttributes(ParsedAttributesWithRange &Attrs,
2486 if (Attrs.Range.isInvalid())
2488 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2492 void ProhibitAttributes(ParsedAttributesViewWithRange &Attrs,
2494 if (Attrs.Range.isInvalid())
2496 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2497 Attrs.clearListOnly();
2499 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2505 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2515 void DiagnoseAndSkipCXX11Attributes();
2528 LateParsedAttrList *LateAttrs =
nullptr) {
2529 if (Tok.
is(tok::kw___attribute)) {
2532 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2538 LateParsedAttrList *LateAttrs =
nullptr) {
2539 if (Tok.
is(tok::kw___attribute))
2540 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2544 LateParsedAttrList *LateAttrs =
nullptr,
2559 void MaybeParseCXX11Attributes(
Declarator &D) {
2560 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2561 ParsedAttributesWithRange attrs(AttrFactory);
2563 ParseCXX11Attributes(attrs, &endLoc);
2569 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2570 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2571 ParseCXX11Attributes(attrsWithRange, endLoc);
2575 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2577 bool OuterMightBeMessageSend =
false) {
2578 if (standardAttributesAllowed() &&
2579 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2580 ParseCXX11Attributes(attrs, endLoc);
2585 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2600 ParseMicrosoftAttributes(attrs, endLoc);
2608 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2609 ParseMicrosoftDeclSpecs(Attrs,
End);
2617 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2628 return ParseOpenCLUnrollHintAttribute(Attrs);
2636 VersionTuple ParseVersionTuple(
SourceRange &Range);
2648 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2656 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2678 void ParseTypeofSpecifier(
DeclSpec &DS);
2680 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2683 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2684 void ParseAtomicSpecifier(
DeclSpec &DS);
2693 return isCXX11VirtSpecifier(Tok);
2695 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2698 bool isCXX11FinalKeyword()
const;
2703 class DeclaratorScopeObj {
2710 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2712 void EnterDeclaratorScope() {
2713 assert(!EnteredScope &&
"Already entered the scope!");
2714 assert(SS.
isSet() &&
"C++ scope was not set!");
2716 CreatedScope =
true;
2720 EnteredScope =
true;
2723 ~DeclaratorScopeObj() {
2725 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2738 DirectDeclParseFunction DirectDeclParser);
2740 enum AttrRequirements {
2741 AR_NoAttributesParsed = 0,
2742 AR_GNUAttributesParsedAndRejected = 1 << 0,
2743 AR_GNUAttributesParsed = 1 << 1,
2744 AR_CXX11AttributesParsed = 1 << 2,
2745 AR_DeclspecAttributesParsed = 1 << 3,
2746 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2747 AR_CXX11AttributesParsed |
2748 AR_DeclspecAttributesParsed,
2749 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2750 AR_DeclspecAttributesParsed
2753 void ParseTypeQualifierListOpt(
2754 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2755 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2758 void ParseDecompositionDeclarator(
Declarator &D);
2764 bool RequiresArg =
false);
2765 void InitCXXThisScopeForDeclaratorIfRelevant(
2768 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2770 bool isFunctionDeclaratorIdentifierList();
2771 void ParseFunctionDeclaratorIdentifierList(
2774 void ParseParameterDeclarationClause(
2780 void ParseMisplacedBracketDeclarator(
Declarator &D);
2786 enum CXX11AttributeKind {
2788 CAK_NotAttributeSpecifier,
2790 CAK_AttributeSpecifier,
2793 CAK_InvalidAttributeSpecifier
2796 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2797 bool OuterMightBeMessageSend =
false);
2799 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2805 struct InnerNamespaceInfo {
2818 Decl *ParseExportDeclaration();
2819 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2827 struct UsingDeclarator {
2842 const ParsedTemplateInfo &TemplateInfo,
2846 Decl *ParseAliasDeclarationAfterDeclarator(
2858 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2860 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2862 DeclSpecContext DSC,
2863 ParsedAttributesWithRange &Attributes);
2870 ParsedAttributesWithRange &Attrs,
2876 ParseCXXMemberDeclaratorBeforeInitializer(
Declarator &DeclaratorInfo,
2879 LateParsedAttrList &LateAttrs);
2880 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
Declarator &D,
2882 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2884 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2886 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2889 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2891 void HandleMemberFunctionDeclDelays(
Declarator& DeclaratorInfo,
2898 void ParseBaseClause(
Decl *ClassDecl);
2906 bool EnteringContext,
2909 bool AssumeTemplateId);
2910 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2917 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2927 void ParseOMPDeclareVariantClauses(DeclGroupPtrTy Ptr,
CachedTokens &Toks,
2930 DeclGroupPtrTy ParseOMPDeclareTargetClauses();
2935 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2940 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2943 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2959 bool ParseOpenMPSimpleVarList(
2963 bool AllowScopeSpecifier);
2968 ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx);
3023 bool IsAddressOfOperand =
false);
3032 int ExtraModifier = -1;
3038 bool IsMapTypeImplicit =
false;
3047 bool AllowDestructorName,
3048 bool AllowConstructorName,
3049 bool AllowDeductionGuide,
3073 Decl *ParseSingleDeclarationAfterTemplate(
3077 bool ParseTemplateParameters(
unsigned Depth,
3081 bool ParseTemplateParameterList(
unsigned Depth,
3083 TPResult isStartOfTemplateTypeParameter();
3084 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3085 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3086 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3087 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3088 bool isTypeConstraintAnnotation();
3089 bool TryAnnotateTypeConstraint();
3091 ParseConstrainedTemplateTypeParameter(
unsigned Depth,
unsigned Position);
3094 bool AlreadyHasEllipsis,
3095 bool IdentifierHasName);
3096 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
3102 bool ConsumeLastToken,
3103 bool ObjCGenericList);
3104 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3106 TemplateArgList &TemplateArgs,
3113 bool AllowTypeAnnotation =
true,
3116 bool IsClassName =
false);
3117 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
3128 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3133 DeclGroupPtrTy ParseModuleDecl(
bool IsFirstDecl);
3135 bool parseMisplacedModuleImport();
3136 bool tryParseMisplacedModuleImport() {
3138 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3139 Kind == tok::annot_module_include)
3140 return parseMisplacedModuleImport();
3144 bool ParseModuleName(
3160 void CodeCompleteDirective(
bool InConditional)
override;
3161 void CodeCompleteInConditionalExclusion()
override;
3162 void CodeCompleteMacroName(
bool IsDefinition)
override;
3163 void CodeCompletePreprocessorExpression()
override;
3165 unsigned ArgumentIndex)
override;
3166 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3167 void CodeCompleteNaturalLanguage()
override;
Sema::FullExprArg FullExprArg
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind...
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
ParseScope - Introduces a new scope for parsing.
SourceLocation getEndOfPreviousToken()
void Initialize()
Initialize - Warm up the parser.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Class to handle popping type parameters when leaving the scope.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
NullabilityKind
Describes the nullability of a particular type.
bool Pop(InterpState &S, CodePtr OpPC)
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)) {...
DeclarationNameInfo ReductionOrMapperId
Decl - This represents one declaration (or definition), e.g.
Syntax
The style used to specify an attribute.
RAII object used to inform the actions that we're currently parsing a declaration.
Captures information about "declaration specifiers" specific to Objective-C.
SmallVector< OpenMPMapModifierKind, OMPMapClause::NumberOfModifiers > MapTypeModifiers
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
void setCodeCompletionReached()
Note that we hit the code-completion point.
void ActOnObjCReenterContainerContext(DeclContext *DC)
bool MightBeCXXScopeToken()
Represents a variable declaration or definition.
Information about one declarator, including the parsed type information and the identifier.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token...
TypeSpecifierType
Specifies the kind of type.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
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 ...
Information about a template-id annotation token.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
SourceLocation getAnnotationEndLoc() const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
const TargetInfo & getTargetInfo() const
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
Defines some OpenMP-specific enums and functions.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
void * getAsOpaquePtr() const
SourceLocation MisleadingIndentationElseLoc
The location of the first statement inside an else that might have a missleading indentation.
Represents a C++ unqualified-id that has been parsed.
friend constexpr SkipUntilFlags operator|(SkipUntilFlags L, SkipUntilFlags R)
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
bool TryConsumeToken(tok::TokenKind Expected, SourceLocation &Loc)
Decl * getObjCDeclContext() const
Concrete class used by the front-end to report problems and issues.
void incrementMSManglingNumber() const
void takeAllFrom(ParsedAttributes &attrs)
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
void CommitBacktrackedTokens()
Disable the last EnableBacktrackAtThisPos call.
Scope - A scope is a transient data structure that is used while parsing the program.
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
AttributeFactory & getAttrFactory()
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
SourceLocation DepLinMapLastLoc
bool isActiveOrNested(Parser &P) const
void incrementMSManglingNumber() const
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
CompoundStmt - This represents a group of statements like { stmt stmt }.
A class for parsing a declarator.
void Backtrack()
Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously c...
Scope * getCurScope() const
Retrieve the parser's current scope.
Exposes information about the current target.
void setAnnotationValue(void *val)
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
unsigned short ParenCount
This represents one expression.
void EnableBacktrackAtThisPos()
From the point that this method is called, and until CommitBacktrackedTokens() or Backtrack() is call...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Sema & getActions() const
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
const Token & getCurToken() const
OpaquePtr< TemplateName > TemplateTy
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
OpenMPClauseKind
OpenMP clauses.
void startOpenMPLoop()
If the current region is a loop-based region, mark the start of the loop construct.
Represents a C++ template name within the type system.
Keeps track of expected type during expression parsing.
A class for parsing a field declarator.
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Provides LLVM's BitmaskEnum facility to enumeration types declared in namespace clang.
Preprocessor & getPreprocessor() const
Defines and computes precedence levels for binary/ternary operators.
SmallVector< SourceLocation, OMPMapClause::NumberOfModifiers > MapTypeModifiersLoc
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
This file defines OpenMP AST classes for clauses.
const LangOptions & getLangOpts() const
A class for parsing a DeclSpec.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Represents the parsed form of a C++ template argument.
Encodes a location in the source.
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
DiagnosticBuilder Diag(unsigned DiagID)
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr *> &Vars, OpenMPVarListDataTy &Data)
Parses clauses with list.
Represents the declaration of a struct/union/class/enum.
void ExitScope()
ExitScope - Pop a scope off the scope stack.
IdentifierInfo * getIdentifierInfo() const
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext=false)
A tentative parsing action that can also revert token annotations.
void Lex(Token &Result)
Lex the next token for this preprocessor.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
This is a basic class for representing single OpenMP clause.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Represents a C++11 virt-specifier-seq.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
Scope * getCurScope() const
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
Defines various enumerations that describe declaration and type specifiers.
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
bool isNot(tok::TokenKind K) const
ParseScope(Parser *Self, unsigned ScopeFlags, bool EnteredScope=true, bool BeforeCompoundStmt=false)
bool isActive(Parser &P) const
static bool isInvalid(LocType Loc, bool *Invalid)
Dataflow Directional Tag Classes.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
The name of a declaration.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SkipUntilFlags
Control flags for SkipUntil functions.
Data used for parsing list of variables in OpenMP clauses.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static const TST TST_unspecified
Encapsulates the data about a macro definition (e.g.
CXXScopeSpec ReductionOrMapperIdScopeSpec
const TargetInfo & getTargetInfo() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
bool isSet() const
Deprecated.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Decl * getObjCDeclContext() const
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Represents a complete lambda introducer.
Activates OpenMP parsing mode to preseve OpenMP specific annotation tokens.
bool parseMapTypeModifiers(OpenMPVarListDataTy &Data)
Parses map-type-modifiers in map clause.
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
bool parseMapperModifier(OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
Contains a late templated function.
Loop optimization hint for loop and unroll pragmas.
AngleBracketTracker::Priority Priority
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Callback handler that receives notifications when performing code completion within the preprocessor...
void * getAnnotationValue() const
static OpaquePtr getFromOpaquePtr(void *P)
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
Attr - This represents one attribute.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result)
Parse the first top-level declaration in a translation unit.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Stop skipping at specified token, but don't skip the token itself.