14 #ifndef LLVM_CLANG_PARSE_PARSER_H 15 #define LLVM_CLANG_PARSE_PARSER_H 27 #include "llvm/ADT/SmallVector.h" 28 #include "llvm/Support/Compiler.h" 29 #include "llvm/Support/PrettyStackTrace.h" 30 #include "llvm/Support/SaveAndRestore.h" 37 class BalancedDelimiterTracker;
38 class CorrectionCandidateCallback;
40 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;
77 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
78 unsigned short MisplacedModuleBeginCount = 0;
87 enum { ScopeCacheSize = 16 };
88 unsigned NumCachedScopes;
89 Scope *ScopeCache[ScopeCacheSize];
95 *Ident___exception_code,
96 *Ident_GetExceptionCode;
99 *Ident___exception_info,
100 *Ident_GetExceptionInfo;
103 *Ident___abnormal_termination,
104 *Ident_AbnormalTermination;
147 *Ident_generated_declaration;
156 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
158 std::unique_ptr<PragmaHandler> AlignHandler;
159 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
160 std::unique_ptr<PragmaHandler> OptionsHandler;
161 std::unique_ptr<PragmaHandler> PackHandler;
162 std::unique_ptr<PragmaHandler> MSStructHandler;
163 std::unique_ptr<PragmaHandler> UnusedHandler;
164 std::unique_ptr<PragmaHandler> WeakHandler;
165 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
166 std::unique_ptr<PragmaHandler> FPContractHandler;
167 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
168 std::unique_ptr<PragmaHandler> OpenMPHandler;
169 std::unique_ptr<PragmaHandler> PCSectionHandler;
170 std::unique_ptr<PragmaHandler> MSCommentHandler;
171 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
172 std::unique_ptr<PragmaHandler> MSPointersToMembers;
173 std::unique_ptr<PragmaHandler> MSVtorDisp;
174 std::unique_ptr<PragmaHandler> MSInitSeg;
175 std::unique_ptr<PragmaHandler> MSDataSeg;
176 std::unique_ptr<PragmaHandler> MSBSSSeg;
177 std::unique_ptr<PragmaHandler> MSConstSeg;
178 std::unique_ptr<PragmaHandler> MSCodeSeg;
179 std::unique_ptr<PragmaHandler> MSSection;
180 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
181 std::unique_ptr<PragmaHandler> MSIntrinsic;
182 std::unique_ptr<PragmaHandler> MSOptimize;
183 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
184 std::unique_ptr<PragmaHandler> OptimizeHandler;
185 std::unique_ptr<PragmaHandler> LoopHintHandler;
186 std::unique_ptr<PragmaHandler> UnrollHintHandler;
187 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
188 std::unique_ptr<PragmaHandler> FPHandler;
189 std::unique_ptr<PragmaHandler> STDCFENVHandler;
190 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
191 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
192 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
194 std::unique_ptr<CommentHandler> CommentSemaHandler;
200 bool GreaterThanIsOperator;
213 bool InMessageExpression;
216 unsigned TemplateParameterDepth;
219 class TemplateParameterDepthRAII {
221 unsigned AddedLevels;
223 explicit TemplateParameterDepthRAII(
unsigned &Depth)
224 : Depth(Depth), AddedLevels(0) {}
226 ~TemplateParameterDepthRAII() {
227 Depth -= AddedLevels;
234 void addDepth(
unsigned D) {
238 unsigned getDepth()
const {
return Depth; }
261 struct AngleBracketTracker {
264 enum Priority :
unsigned short {
271 SpaceBeforeLess = 0x0,
273 NoSpaceBeforeLess = 0x1,
275 LLVM_MARK_AS_BITMASK_ENUM( DependentName)
285 return P.ParenCount == ParenCount && P.BracketCount == BracketCount &&
286 P.BraceCount == BraceCount;
290 return isActive(P) || P.ParenCount > ParenCount ||
291 P.BracketCount > BracketCount || P.BraceCount > BraceCount;
304 if (!Locs.empty() && Locs.back().isActive(P)) {
305 if (Locs.back().Priority <= Prio) {
306 Locs.back().TemplateName = TemplateName;
307 Locs.back().LessLoc = LessLoc;
308 Locs.back().Priority = Prio;
311 Locs.push_back({TemplateName, LessLoc, Prio,
312 P.ParenCount, P.BracketCount, P.BraceCount});
320 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
327 if (!Locs.empty() && Locs.back().isActive(P))
333 AngleBracketTracker AngleBrackets;
342 bool ParsingInObjCContainer;
348 bool SkipFunctionBodies;
405 assert(!isTokenSpecial() &&
406 "Should consume special tokens with Consume*Token");
409 return PrevTokLocation;
413 if (Tok.
isNot(Expected))
415 assert(!isTokenSpecial() &&
416 "Should consume special tokens with Consume*Token");
425 Loc = PrevTokLocation;
434 return ConsumeParen();
435 if (isTokenBracket())
436 return ConsumeBracket();
438 return ConsumeBrace();
439 if (isTokenStringLiteral())
440 return ConsumeStringToken();
441 if (Tok.
is(tok::code_completion))
442 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
443 : handleUnexpectedCodeCompletionToken();
445 return ConsumeAnnotationToken();
466 bool isTokenParen()
const {
467 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
470 bool isTokenBracket()
const {
471 return Tok.
isOneOf(tok::l_square, tok::r_square);
474 bool isTokenBrace()
const {
475 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
478 bool isTokenStringLiteral()
const {
482 bool isTokenSpecial()
const {
483 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
484 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
489 bool isTokenEqualOrEqualTypo();
493 void UnconsumeToken(
Token &Consumed) {
511 assert(isTokenParen() &&
"wrong consume method");
512 if (Tok.
getKind() == tok::l_paren)
514 else if (ParenCount) {
515 AngleBrackets.clear(*
this);
520 return PrevTokLocation;
526 assert(isTokenBracket() &&
"wrong consume method");
527 if (Tok.
getKind() == tok::l_square)
529 else if (BracketCount) {
530 AngleBrackets.clear(*
this);
536 return PrevTokLocation;
542 assert(isTokenBrace() &&
"wrong consume method");
543 if (Tok.
getKind() == tok::l_brace)
545 else if (BraceCount) {
546 AngleBrackets.clear(*
this);
552 return PrevTokLocation;
560 assert(isTokenStringLiteral() &&
561 "Should only consume string literals with this method");
564 return PrevTokLocation;
573 assert(Tok.
is(tok::code_completion));
576 return PrevTokLocation;
588 void cutOffParsing() {
599 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
600 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
610 void initializePragmaHandlers();
613 void resetPragmaHandlers();
616 void HandlePragmaUnused();
620 void HandlePragmaVisibility();
624 void HandlePragmaPack();
628 void HandlePragmaMSStruct();
632 void HandlePragmaMSComment();
634 void HandlePragmaMSPointersToMembers();
636 void HandlePragmaMSVtorDisp();
638 void HandlePragmaMSPragma();
639 bool HandlePragmaMSSection(StringRef PragmaName,
641 bool HandlePragmaMSSegment(StringRef PragmaName,
643 bool HandlePragmaMSInitSeg(StringRef PragmaName,
648 void HandlePragmaAlign();
652 void HandlePragmaDump();
656 void HandlePragmaWeak();
660 void HandlePragmaWeakAlias();
664 void HandlePragmaRedefineExtname();
668 void HandlePragmaFPContract();
672 void HandlePragmaFP();
676 void HandlePragmaOpenCLExtension();
684 bool HandlePragmaLoopHint(
LoopHint &Hint);
686 bool ParsePragmaAttributeSubjectMatchRuleSet(
690 void HandlePragmaAttribute();
699 const Token &GetLookAheadToken(
unsigned N) {
742 enum AnnotatedNameKind {
755 TryAnnotateName(
bool IsAddressOfOperand,
756 std::unique_ptr<CorrectionCandidateCallback> CCC =
nullptr);
759 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
765 const char *&PrevSpec,
unsigned &DiagID,
775 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
781 bool TryAltiVecVectorToken() {
784 return TryAltiVecVectorTokenOutOfLine();
787 bool TryAltiVecVectorTokenOutOfLine();
789 const char *&PrevSpec,
unsigned &DiagID,
795 bool isObjCInstancetype() {
799 if (!Ident_instancetype)
809 bool TryKeywordIdentFallback(
bool DisableKeyword);
825 class TentativeParsingAction {
828 size_t PrevTentativelyDeclaredIdentifierCount;
829 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
833 explicit TentativeParsingAction(
Parser& p) :
P(p) {
835 PrevTentativelyDeclaredIdentifierCount =
836 P.TentativelyDeclaredIdentifiers.size();
837 PrevParenCount = P.ParenCount;
838 PrevBracketCount = P.BracketCount;
839 PrevBraceCount = P.BraceCount;
844 assert(isActive &&
"Parsing action was finished!");
845 P.TentativelyDeclaredIdentifiers.resize(
846 PrevTentativelyDeclaredIdentifierCount);
851 assert(isActive &&
"Parsing action was finished!");
854 P.TentativelyDeclaredIdentifiers.resize(
855 PrevTentativelyDeclaredIdentifierCount);
856 P.ParenCount = PrevParenCount;
857 P.BracketCount = PrevBracketCount;
858 P.BraceCount = PrevBraceCount;
861 ~TentativeParsingAction() {
862 assert(!isActive &&
"Forgot to call Commit or Revert!");
867 class RevertingTentativeParsingAction
868 :
private Parser::TentativeParsingAction {
870 RevertingTentativeParsingAction(
Parser &
P)
871 : Parser::TentativeParsingAction(P) {}
872 ~RevertingTentativeParsingAction() { Revert(); }
887 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
906 unsigned Diag = diag::err_expected,
907 StringRef DiagMsg =
"");
914 bool ExpectAndConsumeSemi(
unsigned DiagID);
920 InstanceVariableList = 2,
921 AfterMemberFunctionDefinition = 3
925 void ConsumeExtraSemi(ExtraSemiKind Kind,
unsigned TST =
TST_unspecified);
933 bool expectIdentifier();
955 bool BeforeCompoundStmt =
false)
957 if (EnteredScope && !BeforeCompoundStmt)
960 if (BeforeCompoundStmt)
963 this->Self =
nullptr;
989 class ParseScopeFlags {
992 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
993 void operator=(
const ParseScopeFlags &) =
delete;
996 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1007 return Diag(Tok, DiagID);
1028 static_cast<unsigned>(R));
1041 return SkipUntil(llvm::makeArrayRef(T), Flags);
1064 struct ParsingClass;
1074 class LateParsedDeclaration {
1076 virtual ~LateParsedDeclaration();
1078 virtual void ParseLexedMethodDeclarations();
1079 virtual void ParseLexedMemberInitializers();
1080 virtual void ParseLexedMethodDefs();
1081 virtual void ParseLexedAttributes();
1086 class LateParsedClass :
public LateParsedDeclaration {
1088 LateParsedClass(
Parser *
P, ParsingClass *
C);
1089 ~LateParsedClass()
override;
1091 void ParseLexedMethodDeclarations()
override;
1092 void ParseLexedMemberInitializers()
override;
1093 void ParseLexedMethodDefs()
override;
1094 void ParseLexedAttributes()
override;
1098 ParsingClass *Class;
1107 struct LateParsedAttribute :
public LateParsedDeclaration {
1116 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1118 void ParseLexedAttributes()
override;
1120 void addDecl(
Decl *D) { Decls.push_back(D); }
1124 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1126 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1128 bool parseSoon() {
return ParseSoon; }
1137 struct LexedMethod :
public LateParsedDeclaration {
1148 : Self(P), D(MD), TemplateScope(
false) {}
1150 void ParseLexedMethodDefs()
override;
1157 struct LateParsedDefaultArgument {
1158 explicit LateParsedDefaultArgument(
Decl *
P,
1159 std::unique_ptr<CachedTokens> Toks =
nullptr)
1160 : Param(P), Toks(std::move(Toks)) { }
1169 std::unique_ptr<CachedTokens> Toks;
1176 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1177 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1178 : Self(P), Method(M), TemplateScope(
false),
1179 ExceptionSpecTokens(
nullptr) {}
1181 void ParseLexedMethodDeclarations()
override;
1208 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1210 : Self(P), Field(FD) { }
1212 void ParseLexedMemberInitializers()
override;
1235 struct ParsingClass {
1236 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1237 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1238 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1242 bool TopLevelClass : 1;
1247 bool TemplateScope : 1;
1250 bool IsInterface : 1;
1253 Decl *TagOrTemplate;
1258 LateParsedDeclarationsContainer LateParsedDeclarations;
1264 std::stack<ParsingClass *> ClassStack;
1266 ParsingClass &getCurrentClass() {
1267 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1268 return *ClassStack.top();
1272 class ParsingClassDefinition {
1278 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1280 :
P(P), Popped(
false),
1281 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1286 assert(!Popped &&
"Nested class has already been popped");
1288 P.PopParsingClass(State);
1291 ~ParsingClassDefinition() {
1293 P.PopParsingClass(State);
1300 struct ParsedTemplateInfo {
1301 ParsedTemplateInfo()
1302 :
Kind(NonTemplate), TemplateParams(
nullptr), TemplateLoc() { }
1304 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1305 bool isSpecialization,
1306 bool lastParameterListWasEmpty =
false)
1307 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1308 TemplateParams(TemplateParams),
1309 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1313 :
Kind(ExplicitInstantiation), TemplateParams(
nullptr),
1314 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1315 LastParameterListWasEmpty(
false){ }
1324 ExplicitSpecialization,
1326 ExplicitInstantiation
1331 TemplateParameterLists *TemplateParams;
1342 bool LastParameterListWasEmpty;
1347 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1351 static void LateTemplateParserCleanupCallback(
void *P);
1354 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1355 void DeallocateParsedClasses(ParsingClass *Class);
1358 enum CachedInitKind {
1359 CIK_DefaultArgument,
1360 CIK_DefaultInitializer
1366 const ParsedTemplateInfo &TemplateInfo,
1369 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1370 void ParseLexedAttributes(ParsingClass &Class);
1371 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1372 bool EnterScope,
bool OnDefinition);
1373 void ParseLexedAttribute(LateParsedAttribute &LA,
1374 bool EnterScope,
bool OnDefinition);
1375 void ParseLexedMethodDeclarations(ParsingClass &Class);
1376 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1377 void ParseLexedMethodDefs(ParsingClass &Class);
1378 void ParseLexedMethodDef(LexedMethod &LM);
1379 void ParseLexedMemberInitializers(ParsingClass &Class);
1380 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1381 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1382 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1383 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1388 bool ConsumeFinalToken =
true) {
1389 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1394 bool ConsumeFinalToken =
true);
1411 void clearListOnly() {
1419 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1421 bool isDeclarationAfterDeclarator();
1423 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1424 ParsedAttributesWithRange &attrs,
1427 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1431 void SkipFunctionBody();
1433 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1434 LateParsedAttrList *LateParsedAttrs =
nullptr);
1435 void ParseKNRParamDeclarations(Declarator &D);
1443 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs);
1444 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1457 bool RBraceMissing);
1458 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1463 bool WarnOnDeclarations,
1464 bool ForObjCContainer,
1467 bool consumeLastToken);
1472 void parseObjCTypeArgsOrProtocolQualifiers(
1481 bool consumeLastToken,
1482 bool warnOnIncompleteProtocols);
1486 void parseObjCTypeArgsAndProtocolQualifiers(
1495 bool consumeLastToken);
1505 bool consumeLastToken,
1510 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1513 struct ObjCImplParsingDataRAII {
1518 LateParsedObjCMethodContainer LateParsedObjCMethods;
1520 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1521 :
P(parser), Dcl(D), HasCFunction(
false) {
1522 P.CurParsedObjCImpl =
this;
1525 ~ObjCImplParsingDataRAII();
1528 bool isFinished()
const {
return Finished; }
1533 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1534 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1536 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc);
1537 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1545 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1546 objc_nonnull, objc_nullable, objc_null_unspecified,
1551 bool isTokIdentifier_in()
const;
1555 void ParseObjCMethodRequirement();
1556 Decl *ParseObjCMethodPrototype(
1558 bool MethodDefinition =
true);
1561 bool MethodDefinition=
true);
1564 Decl *ParseObjCMethodDefinition();
1587 unsigned &NumLineToksConsumed,
1588 bool IsUnevaluated);
1597 ExprResult ParseCastExpression(
bool isUnaryExpression,
1598 bool isAddressOfOperand,
1601 bool isVectorLiteral =
false);
1602 ExprResult ParseCastExpression(
bool isUnaryExpression,
1603 bool isAddressOfOperand =
false,
1605 bool isVectorLiteral =
false);
1608 bool isNotExpressionStart();
1612 bool isPostfixExpressionSuffixStart() {
1614 return (K == tok::l_square || K == tok::l_paren ||
1615 K == tok::period || K == tok::arrow ||
1616 K == tok::plusplus || K == tok::minusminus);
1620 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1622 const Token &OpToken);
1623 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1624 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1625 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1630 ExprResult ParseUnaryExprOrTypeTraitExpression();
1642 bool ParseExpressionList(
1645 llvm::function_ref<
void()> Completer = llvm::function_ref<
void()>());
1654 enum ParenParseOption {
1661 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1662 bool stopIfCastExpr,
1668 ParenParseOption &ExprType,
ParsedType &CastTy,
1674 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1676 ExprResult ParseGenericSelectionExpression();
1686 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1688 bool areTokensAdjacent(
const Token &A,
const Token &B);
1690 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1696 bool EnteringContext,
1697 bool *MayBePseudoDestructor =
nullptr,
1698 bool IsTypename =
false,
1700 bool OnlyNamespace =
false);
1709 bool *SkippedInits =
nullptr);
1711 ExprResult ParseLambdaExpressionAfterIntroducer(
1758 bool MayBeFollowedByDirectInit);
1771 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1773 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1779 void ParseDirectNewDeclarator(Declarator &D);
1781 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1803 if (Tok.
isNot(tok::l_brace))
1805 return ParseBraceInitializer();
1807 bool MayBeDesignationStart();
1809 ExprResult ParseInitializerWithPotentialDesignator();
1829 bool isSimpleObjCMessageExpression();
1834 Expr *ReceiverExpr);
1835 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1838 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1852 bool AllowOpenMPStandalone =
false);
1853 enum AllowedConstructsKind {
1857 ACK_StatementsOpenMPNonStandalone,
1859 ACK_StatementsOpenMPAnyExecutable
1862 ParseStatementOrDeclaration(StmtVector &Stmts, AllowedConstructsKind Allowed,
1864 StmtResult ParseStatementOrDeclarationAfterAttributes(
1866 AllowedConstructsKind Allowed,
1868 ParsedAttributesWithRange &Attrs);
1870 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs);
1871 StmtResult ParseCaseStatement(
bool MissingCase =
false,
1874 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
1875 StmtResult ParseCompoundStatement(
bool isStmtExpr,
1876 unsigned ScopeFlags);
1877 void ParseCompoundStatementLeadingPragmas();
1878 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
1879 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
1894 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
1895 AllowedConstructsKind Allowed,
1897 ParsedAttributesWithRange &Attrs);
1901 enum IfExistsBehavior {
1913 struct IfExistsCondition {
1928 IfExistsBehavior Behavior;
1931 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
1932 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
1933 void ParseMicrosoftIfExistsExternalDeclaration();
1937 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
1948 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
1974 enum class DeclSpecContext {
1979 DSC_alias_declaration,
1982 DSC_template_type_arg,
1983 DSC_objc_method_result,
1989 static bool isTypeSpecifier(DeclSpecContext DSC) {
1991 case DeclSpecContext::DSC_normal:
1992 case DeclSpecContext::DSC_template_param:
1993 case DeclSpecContext::DSC_class:
1994 case DeclSpecContext::DSC_top_level:
1995 case DeclSpecContext::DSC_objc_method_result:
1996 case DeclSpecContext::DSC_condition:
1999 case DeclSpecContext::DSC_template_type_arg:
2000 case DeclSpecContext::DSC_type_specifier:
2001 case DeclSpecContext::DSC_trailing:
2002 case DeclSpecContext::DSC_alias_declaration:
2005 llvm_unreachable(
"Missing DeclSpecContext case");
2010 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2012 case DeclSpecContext::DSC_normal:
2013 case DeclSpecContext::DSC_template_param:
2014 case DeclSpecContext::DSC_class:
2015 case DeclSpecContext::DSC_top_level:
2016 case DeclSpecContext::DSC_condition:
2017 case DeclSpecContext::DSC_type_specifier:
2020 case DeclSpecContext::DSC_objc_method_result:
2021 case DeclSpecContext::DSC_template_type_arg:
2022 case DeclSpecContext::DSC_trailing:
2023 case DeclSpecContext::DSC_alias_declaration:
2026 llvm_unreachable(
"Missing DeclSpecContext case");
2031 struct ForRangeInit {
2035 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2040 ParsedAttributesWithRange &attrs);
2043 ParsedAttributesWithRange &attrs,
2045 ForRangeInit *FRI =
nullptr);
2049 ForRangeInit *FRI =
nullptr);
2050 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2051 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2052 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2053 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2055 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2056 ForRangeInit *FRI =
nullptr);
2064 bool trySkippingFunctionBody();
2067 const ParsedTemplateInfo &TemplateInfo,
2069 ParsedAttributesWithRange &Attrs);
2072 void ParseDeclarationSpecifiers(
2074 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2076 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2077 LateParsedAttrList *LateAttrs =
nullptr);
2078 bool DiagnoseMissingSemiAfterTagDefinition(
2080 LateParsedAttrList *LateAttrs =
nullptr);
2082 void ParseSpecifierQualifierList(
2084 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2090 const ParsedTemplateInfo &TemplateInfo,
2096 void ParseStructDeclaration(
2100 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2101 bool isTypeSpecifierQualifier();
2106 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2111 bool isKnownToBeDeclarationSpecifier() {
2113 return isCXXDeclarationSpecifier() == TPResult::True;
2114 return isDeclarationSpecifier(
true);
2120 bool isDeclarationStatement() {
2122 return isCXXDeclarationStatement();
2123 return isDeclarationSpecifier(
true);
2130 bool isForInitDeclaration() {
2132 return isCXXSimpleDeclaration(
true);
2133 return isDeclarationSpecifier(
true);
2137 bool isForRangeIdentifier();
2141 bool isStartOfObjCClassMessageMissingOpenBracket();
2146 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2150 enum TentativeCXXTypeIdContext {
2153 TypeIdAsTemplateArgument
2160 bool isTypeIdInParens(
bool &isAmbiguous) {
2162 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2163 isAmbiguous =
false;
2164 return isTypeSpecifierQualifier();
2166 bool isTypeIdInParens() {
2168 return isTypeIdInParens(isAmbiguous);
2174 bool isTypeIdUnambiguously() {
2177 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2178 return isTypeSpecifierQualifier();
2184 bool isCXXDeclarationStatement();
2191 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2200 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2203 enum class ConditionOrInitStatement {
2212 ConditionOrInitStatement
2213 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt);
2215 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2216 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2218 return isCXXTypeId(Context, isAmbiguous);
2223 enum class TPResult {
2224 True, False, Ambiguous, Error
2247 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2248 bool *HasMissingTypename =
nullptr);
2253 bool isCXXDeclarationSpecifierAType();
2267 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2268 TPResult TryParseTypeofSpecifier();
2269 TPResult TryParseProtocolQualifiers();
2270 TPResult TryParsePtrOperatorSeq();
2271 TPResult TryParseOperatorId();
2272 TPResult TryParseInitDeclaratorList();
2273 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2274 bool mayHaveDirectInit =
false);
2276 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2277 bool VersusTemplateArg =
false);
2278 TPResult TryParseFunctionDeclarator();
2279 TPResult TryParseBracketDeclarator();
2280 TPResult TryConsumeDeclarationSpecifier();
2287 Decl **OwnedType =
nullptr,
2294 bool standardAttributesAllowed()
const {
2296 return LO.DoubleSquareBracketAttributes;
2301 bool CheckProhibitedCXX11Attribute() {
2302 assert(Tok.
is(tok::l_square));
2303 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2305 return DiagnoseProhibitedCXX11Attribute();
2308 bool DiagnoseProhibitedCXX11Attribute();
2309 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2311 if (!standardAttributesAllowed())
2314 Tok.
isNot(tok::kw_alignas))
2316 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2318 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2321 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2325 void ProhibitAttributes(ParsedAttributesWithRange &Attrs,
2327 if (Attrs.Range.isInvalid())
2329 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2333 void ProhibitAttributes(ParsedAttributesViewWithRange &Attrs,
2335 if (Attrs.Range.isInvalid())
2337 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2338 Attrs.clearListOnly();
2340 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2346 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2356 void DiagnoseAndSkipCXX11Attributes();
2368 void MaybeParseGNUAttributes(Declarator &D,
2369 LateParsedAttrList *LateAttrs =
nullptr) {
2370 if (Tok.
is(tok::kw___attribute)) {
2373 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2379 LateParsedAttrList *LateAttrs =
nullptr) {
2380 if (Tok.
is(tok::kw___attribute))
2381 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2385 LateParsedAttrList *LateAttrs =
nullptr,
2386 Declarator *D =
nullptr);
2400 void MaybeParseCXX11Attributes(Declarator &D) {
2401 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2402 ParsedAttributesWithRange attrs(AttrFactory);
2404 ParseCXX11Attributes(attrs, &endLoc);
2410 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2411 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2412 ParseCXX11Attributes(attrsWithRange, endLoc);
2416 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2418 bool OuterMightBeMessageSend =
false) {
2419 if (standardAttributesAllowed() &&
2420 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2421 ParseCXX11Attributes(attrs, endLoc);
2426 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2441 ParseMicrosoftAttributes(attrs, endLoc);
2449 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2450 ParseMicrosoftDeclSpecs(Attrs,
End);
2458 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2469 return ParseOpenCLUnrollHintAttribute(Attrs);
2477 VersionTuple ParseVersionTuple(
SourceRange &Range);
2489 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2497 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2519 void ParseTypeofSpecifier(
DeclSpec &DS);
2521 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2524 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2525 void ParseAtomicSpecifier(
DeclSpec &DS);
2534 return isCXX11VirtSpecifier(Tok);
2536 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2539 bool isCXX11FinalKeyword()
const;
2544 class DeclaratorScopeObj {
2551 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2553 void EnterDeclaratorScope() {
2554 assert(!EnteredScope &&
"Already entered the scope!");
2555 assert(SS.
isSet() &&
"C++ scope was not set!");
2557 CreatedScope =
true;
2561 EnteredScope =
true;
2564 ~DeclaratorScopeObj() {
2566 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2575 void ParseDeclarator(Declarator &D);
2577 typedef void (
Parser::*DirectDeclParseFunction)(Declarator&);
2578 void ParseDeclaratorInternal(Declarator &D,
2579 DirectDeclParseFunction DirectDeclParser);
2581 enum AttrRequirements {
2582 AR_NoAttributesParsed = 0,
2583 AR_GNUAttributesParsedAndRejected = 1 << 0,
2584 AR_GNUAttributesParsed = 1 << 1,
2585 AR_CXX11AttributesParsed = 1 << 2,
2586 AR_DeclspecAttributesParsed = 1 << 3,
2587 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2588 AR_CXX11AttributesParsed |
2589 AR_DeclspecAttributesParsed,
2590 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2591 AR_DeclspecAttributesParsed
2594 void ParseTypeQualifierListOpt(
2595 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2596 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2598 void ParseDirectDeclarator(Declarator &D);
2599 void ParseDecompositionDeclarator(Declarator &D);
2600 void ParseParenDeclarator(Declarator &D);
2601 void ParseFunctionDeclarator(Declarator &D,
2605 bool RequiresArg =
false);
2606 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2608 bool isFunctionDeclaratorIdentifierList();
2609 void ParseFunctionDeclaratorIdentifierList(
2612 void ParseParameterDeclarationClause(
2617 void ParseBracketDeclarator(Declarator &D);
2618 void ParseMisplacedBracketDeclarator(Declarator &D);
2624 enum CXX11AttributeKind {
2626 CAK_NotAttributeSpecifier,
2628 CAK_AttributeSpecifier,
2631 CAK_InvalidAttributeSpecifier
2634 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2635 bool OuterMightBeMessageSend =
false);
2637 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2642 void ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc,
2643 std::vector<IdentifierInfo *> &Ident,
2644 std::vector<SourceLocation> &NamespaceLoc,
2649 Decl *ParseExportDeclaration();
2650 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2658 struct UsingDeclarator {
2673 const ParsedTemplateInfo &TemplateInfo,
2677 Decl *ParseAliasDeclarationAfterDeclarator(
2689 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2691 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2693 DeclSpecContext DSC,
2694 ParsedAttributesWithRange &Attributes);
2701 ParsedAttributesWithRange &Attrs,
2706 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
2709 LateParsedAttrList &LateAttrs);
2710 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
2712 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2714 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2716 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2719 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2721 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
2728 void ParseBaseClause(
Decl *ClassDecl);
2736 bool EnteringContext,
2739 bool AssumeTemplateId);
2740 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2747 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2751 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2756 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2759 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2768 bool ParseOpenMPSimpleVarList(
2772 bool AllowScopeSpecifier);
2781 ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed);
2848 bool IsMapTypeImplicit =
false;
2857 bool AllowDestructorName,
2858 bool AllowConstructorName,
2859 bool AllowDeductionGuide,
2877 Decl *ParseSingleDeclarationAfterTemplate(
2881 bool ParseTemplateParameters(
unsigned Depth,
2885 bool ParseTemplateParameterList(
unsigned Depth,
2887 bool isStartOfTemplateTypeParameter();
2888 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
2889 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
2890 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
2891 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
2894 bool AlreadyHasEllipsis,
2895 bool IdentifierHasName);
2896 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
2902 bool ConsumeLastToken,
2903 bool ObjCGenericList);
2904 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
2906 TemplateArgList &TemplateArgs,
2913 bool AllowTypeAnnotation =
true);
2914 void AnnotateTemplateIdTokenAsType(
bool IsClassName =
false);
2915 bool IsTemplateArgumentList(
unsigned Skip = 0);
2916 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
2928 DeclGroupPtrTy ParseModuleDecl();
2930 bool parseMisplacedModuleImport();
2931 bool tryParseMisplacedModuleImport() {
2933 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
2934 Kind == tok::annot_module_include)
2935 return parseMisplacedModuleImport();
2939 bool ParseModuleName(
2955 void CodeCompleteDirective(
bool InConditional)
override;
2956 void CodeCompleteInConditionalExclusion()
override;
2957 void CodeCompleteMacroName(
bool IsDefinition)
override;
2958 void CodeCompletePreprocessorExpression()
override;
2960 unsigned ArgumentIndex)
override;
2961 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.
DeclarationNameInfo ReductionId
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 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)) {...
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
Captures information about "declaration specifiers" specific to Objective-C.
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.
SourceLocation DepLinMapLoc
void setCodeCompletionReached()
Note that we hit the code-completion point.
void ActOnObjCReenterContainerContext(DeclContext *DC)
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
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
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
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
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()
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
Expr - 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.
CXXScopeSpec ReductionIdScopeSpec
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
OpenMPClauseKind
OpenMP clauses.
Represents a C++ template name within the type system.
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.
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
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.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
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.
Syntax
The style used to specify an attribute.
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)
OpenMPDirectiveKind
OpenMP directives.
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
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.
Scope * getCurScope() const
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
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.
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.
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...
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
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.
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))
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 ':'.
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.