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;
43 class ParsingDeclRAIIObject;
44 class ParsingDeclSpec;
45 class ParsingDeclarator;
46 class ParsingFieldDeclarator;
47 class ColonProtectionRAIIObject;
48 class InMessageExpressionRAIIObject;
49 class PoisonSEHIdentifiersRAIIObject;
51 class ObjCTypeParamList;
52 class ObjCTypeParameter;
78 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
79 unsigned short MisplacedModuleBeginCount = 0;
88 enum { ScopeCacheSize = 16 };
89 unsigned NumCachedScopes;
90 Scope *ScopeCache[ScopeCacheSize];
96 *Ident___exception_code,
97 *Ident_GetExceptionCode;
100 *Ident___exception_info,
101 *Ident_GetExceptionInfo;
104 *Ident___abnormal_termination,
105 *Ident_AbnormalTermination;
148 *Ident_generated_declaration;
157 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
159 std::unique_ptr<PragmaHandler> AlignHandler;
160 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
161 std::unique_ptr<PragmaHandler> OptionsHandler;
162 std::unique_ptr<PragmaHandler> PackHandler;
163 std::unique_ptr<PragmaHandler> MSStructHandler;
164 std::unique_ptr<PragmaHandler> UnusedHandler;
165 std::unique_ptr<PragmaHandler> WeakHandler;
166 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
167 std::unique_ptr<PragmaHandler> FPContractHandler;
168 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
169 std::unique_ptr<PragmaHandler> OpenMPHandler;
170 std::unique_ptr<PragmaHandler> PCSectionHandler;
171 std::unique_ptr<PragmaHandler> MSCommentHandler;
172 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
173 std::unique_ptr<PragmaHandler> MSPointersToMembers;
174 std::unique_ptr<PragmaHandler> MSVtorDisp;
175 std::unique_ptr<PragmaHandler> MSInitSeg;
176 std::unique_ptr<PragmaHandler> MSDataSeg;
177 std::unique_ptr<PragmaHandler> MSBSSSeg;
178 std::unique_ptr<PragmaHandler> MSConstSeg;
179 std::unique_ptr<PragmaHandler> MSCodeSeg;
180 std::unique_ptr<PragmaHandler> MSSection;
181 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
182 std::unique_ptr<PragmaHandler> MSIntrinsic;
183 std::unique_ptr<PragmaHandler> MSOptimize;
184 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
185 std::unique_ptr<PragmaHandler> OptimizeHandler;
186 std::unique_ptr<PragmaHandler> LoopHintHandler;
187 std::unique_ptr<PragmaHandler> UnrollHintHandler;
188 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
189 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
190 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
191 std::unique_ptr<PragmaHandler> FPHandler;
192 std::unique_ptr<PragmaHandler> STDCFENVHandler;
193 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
194 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
195 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
197 std::unique_ptr<CommentHandler> CommentSemaHandler;
203 bool GreaterThanIsOperator;
216 bool InMessageExpression;
221 bool CalledSignatureHelp =
false;
224 unsigned TemplateParameterDepth;
227 class TemplateParameterDepthRAII {
229 unsigned AddedLevels;
231 explicit TemplateParameterDepthRAII(
unsigned &Depth)
232 : Depth(Depth), AddedLevels(0) {}
234 ~TemplateParameterDepthRAII() {
235 Depth -= AddedLevels;
242 void addDepth(
unsigned D) {
246 unsigned getDepth()
const {
return Depth; }
269 struct AngleBracketTracker {
272 enum Priority :
unsigned short {
279 SpaceBeforeLess = 0x0,
281 NoSpaceBeforeLess = 0x1,
283 LLVM_MARK_AS_BITMASK_ENUM( DependentName)
293 return P.ParenCount == ParenCount && P.BracketCount == BracketCount &&
294 P.BraceCount == BraceCount;
298 return isActive(P) || P.ParenCount > ParenCount ||
299 P.BracketCount > BracketCount || P.BraceCount > BraceCount;
312 if (!Locs.empty() && Locs.back().isActive(P)) {
313 if (Locs.back().Priority <= Prio) {
314 Locs.back().TemplateName = TemplateName;
315 Locs.back().LessLoc = LessLoc;
316 Locs.back().Priority = Prio;
319 Locs.push_back({TemplateName, LessLoc, Prio,
320 P.ParenCount, P.BracketCount, P.BraceCount});
328 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
335 if (!Locs.empty() && Locs.back().isActive(P))
341 AngleBracketTracker AngleBrackets;
350 bool ParsingInObjCContainer;
356 bool SkipFunctionBodies;
366 bool isExprValueDiscarded();
418 assert(!isTokenSpecial() &&
419 "Should consume special tokens with Consume*Token");
422 return PrevTokLocation;
426 if (Tok.
isNot(Expected))
428 assert(!isTokenSpecial() &&
429 "Should consume special tokens with Consume*Token");
438 Loc = PrevTokLocation;
447 return ConsumeParen();
448 if (isTokenBracket())
449 return ConsumeBracket();
451 return ConsumeBrace();
452 if (isTokenStringLiteral())
453 return ConsumeStringToken();
454 if (Tok.
is(tok::code_completion))
455 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
456 : handleUnexpectedCodeCompletionToken();
458 return ConsumeAnnotationToken();
479 bool isTokenParen()
const {
480 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
483 bool isTokenBracket()
const {
484 return Tok.
isOneOf(tok::l_square, tok::r_square);
487 bool isTokenBrace()
const {
488 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
491 bool isTokenStringLiteral()
const {
495 bool isTokenSpecial()
const {
496 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
497 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
502 bool isTokenEqualOrEqualTypo();
506 void UnconsumeToken(
Token &Consumed) {
524 assert(isTokenParen() &&
"wrong consume method");
525 if (Tok.
getKind() == tok::l_paren)
527 else if (ParenCount) {
528 AngleBrackets.clear(*
this);
533 return PrevTokLocation;
539 assert(isTokenBracket() &&
"wrong consume method");
540 if (Tok.
getKind() == tok::l_square)
542 else if (BracketCount) {
543 AngleBrackets.clear(*
this);
549 return PrevTokLocation;
555 assert(isTokenBrace() &&
"wrong consume method");
556 if (Tok.
getKind() == tok::l_brace)
558 else if (BraceCount) {
559 AngleBrackets.clear(*
this);
565 return PrevTokLocation;
573 assert(isTokenStringLiteral() &&
574 "Should only consume string literals with this method");
577 return PrevTokLocation;
586 assert(Tok.
is(tok::code_completion));
589 return PrevTokLocation;
601 void cutOffParsing() {
612 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
613 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
623 void initializePragmaHandlers();
626 void resetPragmaHandlers();
629 void HandlePragmaUnused();
633 void HandlePragmaVisibility();
637 void HandlePragmaPack();
641 void HandlePragmaMSStruct();
645 void HandlePragmaMSComment();
647 void HandlePragmaMSPointersToMembers();
649 void HandlePragmaMSVtorDisp();
651 void HandlePragmaMSPragma();
652 bool HandlePragmaMSSection(StringRef PragmaName,
654 bool HandlePragmaMSSegment(StringRef PragmaName,
656 bool HandlePragmaMSInitSeg(StringRef PragmaName,
661 void HandlePragmaAlign();
665 void HandlePragmaDump();
669 void HandlePragmaWeak();
673 void HandlePragmaWeakAlias();
677 void HandlePragmaRedefineExtname();
681 void HandlePragmaFPContract();
685 void HandlePragmaFEnvAccess();
689 void HandlePragmaFP();
693 void HandlePragmaOpenCLExtension();
701 bool HandlePragmaLoopHint(
LoopHint &Hint);
703 bool ParsePragmaAttributeSubjectMatchRuleSet(
707 void HandlePragmaAttribute();
716 const Token &GetLookAheadToken(
unsigned N) {
759 enum AnnotatedNameKind {
772 TryAnnotateName(
bool IsAddressOfOperand,
773 std::unique_ptr<CorrectionCandidateCallback> CCC =
nullptr);
776 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
782 const char *&PrevSpec,
unsigned &DiagID,
792 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
798 bool TryAltiVecVectorToken() {
801 return TryAltiVecVectorTokenOutOfLine();
804 bool TryAltiVecVectorTokenOutOfLine();
806 const char *&PrevSpec,
unsigned &DiagID,
812 bool isObjCInstancetype() {
816 if (!Ident_instancetype)
826 bool TryKeywordIdentFallback(
bool DisableKeyword);
842 class TentativeParsingAction {
845 size_t PrevTentativelyDeclaredIdentifierCount;
846 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
850 explicit TentativeParsingAction(
Parser& p) :
P(p) {
852 PrevTentativelyDeclaredIdentifierCount =
853 P.TentativelyDeclaredIdentifiers.size();
854 PrevParenCount = P.ParenCount;
855 PrevBracketCount = P.BracketCount;
856 PrevBraceCount = P.BraceCount;
861 assert(isActive &&
"Parsing action was finished!");
862 P.TentativelyDeclaredIdentifiers.resize(
863 PrevTentativelyDeclaredIdentifierCount);
868 assert(isActive &&
"Parsing action was finished!");
871 P.TentativelyDeclaredIdentifiers.resize(
872 PrevTentativelyDeclaredIdentifierCount);
873 P.ParenCount = PrevParenCount;
874 P.BracketCount = PrevBracketCount;
875 P.BraceCount = PrevBraceCount;
878 ~TentativeParsingAction() {
879 assert(!isActive &&
"Forgot to call Commit or Revert!");
884 class RevertingTentativeParsingAction
885 :
private Parser::TentativeParsingAction {
887 RevertingTentativeParsingAction(
Parser &
P)
888 : Parser::TentativeParsingAction(P) {}
889 ~RevertingTentativeParsingAction() { Revert(); }
904 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
923 unsigned Diag = diag::err_expected,
924 StringRef DiagMsg =
"");
931 bool ExpectAndConsumeSemi(
unsigned DiagID);
937 InstanceVariableList = 2,
938 AfterMemberFunctionDefinition = 3
942 void ConsumeExtraSemi(ExtraSemiKind Kind,
unsigned TST =
TST_unspecified);
950 bool expectIdentifier();
972 bool BeforeCompoundStmt =
false)
974 if (EnteredScope && !BeforeCompoundStmt)
977 if (BeforeCompoundStmt)
980 this->Self =
nullptr;
1006 class ParseScopeFlags {
1009 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1010 void operator=(
const ParseScopeFlags &) =
delete;
1013 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1024 return Diag(Tok, DiagID);
1045 static_cast<unsigned>(R));
1058 return SkipUntil(llvm::makeArrayRef(T), Flags);
1081 struct ParsingClass;
1091 class LateParsedDeclaration {
1093 virtual ~LateParsedDeclaration();
1095 virtual void ParseLexedMethodDeclarations();
1096 virtual void ParseLexedMemberInitializers();
1097 virtual void ParseLexedMethodDefs();
1098 virtual void ParseLexedAttributes();
1103 class LateParsedClass :
public LateParsedDeclaration {
1105 LateParsedClass(
Parser *
P, ParsingClass *
C);
1106 ~LateParsedClass()
override;
1108 void ParseLexedMethodDeclarations()
override;
1109 void ParseLexedMemberInitializers()
override;
1110 void ParseLexedMethodDefs()
override;
1111 void ParseLexedAttributes()
override;
1115 ParsingClass *Class;
1124 struct LateParsedAttribute :
public LateParsedDeclaration {
1133 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1135 void ParseLexedAttributes()
override;
1137 void addDecl(
Decl *D) { Decls.push_back(D); }
1141 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1143 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1145 bool parseSoon() {
return ParseSoon; }
1154 struct LexedMethod :
public LateParsedDeclaration {
1165 : Self(P), D(MD), TemplateScope(
false) {}
1167 void ParseLexedMethodDefs()
override;
1174 struct LateParsedDefaultArgument {
1175 explicit LateParsedDefaultArgument(
Decl *
P,
1176 std::unique_ptr<CachedTokens> Toks =
nullptr)
1177 : Param(P), Toks(std::move(Toks)) { }
1186 std::unique_ptr<CachedTokens> Toks;
1193 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1194 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1195 : Self(P), Method(M), TemplateScope(
false),
1196 ExceptionSpecTokens(
nullptr) {}
1198 void ParseLexedMethodDeclarations()
override;
1225 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1227 : Self(P), Field(FD) { }
1229 void ParseLexedMemberInitializers()
override;
1252 struct ParsingClass {
1253 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1254 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1255 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1259 bool TopLevelClass : 1;
1264 bool TemplateScope : 1;
1267 bool IsInterface : 1;
1270 Decl *TagOrTemplate;
1275 LateParsedDeclarationsContainer LateParsedDeclarations;
1281 std::stack<ParsingClass *> ClassStack;
1283 ParsingClass &getCurrentClass() {
1284 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1285 return *ClassStack.top();
1289 class ParsingClassDefinition {
1295 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1297 :
P(P), Popped(
false),
1298 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1303 assert(!Popped &&
"Nested class has already been popped");
1305 P.PopParsingClass(State);
1308 ~ParsingClassDefinition() {
1310 P.PopParsingClass(State);
1317 struct ParsedTemplateInfo {
1318 ParsedTemplateInfo()
1319 :
Kind(NonTemplate), TemplateParams(
nullptr), TemplateLoc() { }
1321 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1322 bool isSpecialization,
1323 bool lastParameterListWasEmpty =
false)
1324 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1325 TemplateParams(TemplateParams),
1326 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1330 :
Kind(ExplicitInstantiation), TemplateParams(
nullptr),
1331 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1332 LastParameterListWasEmpty(
false){ }
1341 ExplicitSpecialization,
1343 ExplicitInstantiation
1348 TemplateParameterLists *TemplateParams;
1359 bool LastParameterListWasEmpty;
1364 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1368 static void LateTemplateParserCleanupCallback(
void *P);
1371 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1372 void DeallocateParsedClasses(ParsingClass *Class);
1375 enum CachedInitKind {
1376 CIK_DefaultArgument,
1377 CIK_DefaultInitializer
1383 const ParsedTemplateInfo &TemplateInfo,
1386 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1387 void ParseLexedAttributes(ParsingClass &Class);
1388 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1389 bool EnterScope,
bool OnDefinition);
1390 void ParseLexedAttribute(LateParsedAttribute &LA,
1391 bool EnterScope,
bool OnDefinition);
1392 void ParseLexedMethodDeclarations(ParsingClass &Class);
1393 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1394 void ParseLexedMethodDefs(ParsingClass &Class);
1395 void ParseLexedMethodDef(LexedMethod &LM);
1396 void ParseLexedMemberInitializers(ParsingClass &Class);
1397 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1398 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1399 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1400 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1405 bool ConsumeFinalToken =
true) {
1406 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1411 bool ConsumeFinalToken =
true);
1428 void clearListOnly() {
1436 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1438 bool isDeclarationAfterDeclarator();
1440 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1441 ParsedAttributesWithRange &attrs,
1444 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1448 void SkipFunctionBody();
1450 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1451 LateParsedAttrList *LateParsedAttrs =
nullptr);
1452 void ParseKNRParamDeclarations(Declarator &D);
1460 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs);
1461 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1474 bool RBraceMissing);
1475 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1480 bool WarnOnDeclarations,
1481 bool ForObjCContainer,
1484 bool consumeLastToken);
1489 void parseObjCTypeArgsOrProtocolQualifiers(
1498 bool consumeLastToken,
1499 bool warnOnIncompleteProtocols);
1503 void parseObjCTypeArgsAndProtocolQualifiers(
1512 bool consumeLastToken);
1522 bool consumeLastToken,
1527 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1530 struct ObjCImplParsingDataRAII {
1535 LateParsedObjCMethodContainer LateParsedObjCMethods;
1537 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1538 :
P(parser), Dcl(D), HasCFunction(
false) {
1539 P.CurParsedObjCImpl =
this;
1542 ~ObjCImplParsingDataRAII();
1545 bool isFinished()
const {
return Finished; }
1550 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1551 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1553 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc);
1554 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1562 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1563 objc_nonnull, objc_nullable, objc_null_unspecified,
1568 bool isTokIdentifier_in()
const;
1572 void ParseObjCMethodRequirement();
1573 Decl *ParseObjCMethodPrototype(
1575 bool MethodDefinition =
true);
1578 bool MethodDefinition=
true);
1581 Decl *ParseObjCMethodDefinition();
1604 unsigned &NumLineToksConsumed,
1605 bool IsUnevaluated);
1614 ExprResult ParseCastExpression(
bool isUnaryExpression,
1615 bool isAddressOfOperand,
1618 bool isVectorLiteral =
false);
1619 ExprResult ParseCastExpression(
bool isUnaryExpression,
1620 bool isAddressOfOperand =
false,
1622 bool isVectorLiteral =
false);
1625 bool isNotExpressionStart();
1629 bool isPostfixExpressionSuffixStart() {
1631 return (K == tok::l_square || K == tok::l_paren ||
1632 K == tok::period || K == tok::arrow ||
1633 K == tok::plusplus || K == tok::minusminus);
1637 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1639 const Token &OpToken);
1640 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1641 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1642 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1647 ExprResult ParseUnaryExprOrTypeTraitExpression();
1659 bool ParseExpressionList(
1662 llvm::function_ref<
void()> Completer = llvm::function_ref<
void()>());
1671 enum ParenParseOption {
1678 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1679 bool stopIfCastExpr,
1685 ParenParseOption &ExprType,
ParsedType &CastTy,
1691 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1693 ExprResult ParseGenericSelectionExpression();
1702 Token &Replacement);
1703 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1705 bool areTokensAdjacent(
const Token &A,
const Token &B);
1707 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1713 bool EnteringContext,
1714 bool *MayBePseudoDestructor =
nullptr,
1715 bool IsTypename =
false,
1717 bool OnlyNamespace =
false);
1726 bool *SkippedInits =
nullptr);
1728 ExprResult ParseLambdaExpressionAfterIntroducer(
1775 bool MayBeFollowedByDirectInit);
1788 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1790 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1796 void ParseDirectNewDeclarator(Declarator &D);
1798 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1803 struct ForRangeInfo;
1807 ForRangeInfo *FRI =
nullptr);
1822 if (Tok.
isNot(tok::l_brace))
1824 return ParseBraceInitializer();
1826 bool MayBeDesignationStart();
1828 ExprResult ParseInitializerWithPotentialDesignator();
1848 bool isSimpleObjCMessageExpression();
1853 Expr *ReceiverExpr);
1854 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1857 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1871 bool AllowOpenMPStandalone =
false);
1872 enum AllowedConstructsKind {
1876 ACK_StatementsOpenMPNonStandalone,
1878 ACK_StatementsOpenMPAnyExecutable
1881 ParseStatementOrDeclaration(StmtVector &Stmts, AllowedConstructsKind Allowed,
1883 StmtResult ParseStatementOrDeclarationAfterAttributes(
1885 AllowedConstructsKind Allowed,
1887 ParsedAttributesWithRange &Attrs);
1889 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs);
1890 StmtResult ParseCaseStatement(
bool MissingCase =
false,
1893 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
1894 StmtResult ParseCompoundStatement(
bool isStmtExpr,
1895 unsigned ScopeFlags);
1896 void ParseCompoundStatementLeadingPragmas();
1897 bool ConsumeNullStmt(StmtVector &Stmts);
1898 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
1899 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
1914 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
1915 AllowedConstructsKind Allowed,
1917 ParsedAttributesWithRange &Attrs);
1921 enum IfExistsBehavior {
1933 struct IfExistsCondition {
1948 IfExistsBehavior Behavior;
1951 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
1952 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
1953 void ParseMicrosoftIfExistsExternalDeclaration();
1957 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
1968 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
1994 enum class DeclSpecContext {
1999 DSC_alias_declaration,
2002 DSC_template_type_arg,
2003 DSC_objc_method_result,
2009 static bool isTypeSpecifier(DeclSpecContext DSC) {
2011 case DeclSpecContext::DSC_normal:
2012 case DeclSpecContext::DSC_template_param:
2013 case DeclSpecContext::DSC_class:
2014 case DeclSpecContext::DSC_top_level:
2015 case DeclSpecContext::DSC_objc_method_result:
2016 case DeclSpecContext::DSC_condition:
2019 case DeclSpecContext::DSC_template_type_arg:
2020 case DeclSpecContext::DSC_type_specifier:
2021 case DeclSpecContext::DSC_trailing:
2022 case DeclSpecContext::DSC_alias_declaration:
2025 llvm_unreachable(
"Missing DeclSpecContext case");
2030 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2032 case DeclSpecContext::DSC_normal:
2033 case DeclSpecContext::DSC_template_param:
2034 case DeclSpecContext::DSC_class:
2035 case DeclSpecContext::DSC_top_level:
2036 case DeclSpecContext::DSC_condition:
2037 case DeclSpecContext::DSC_type_specifier:
2040 case DeclSpecContext::DSC_objc_method_result:
2041 case DeclSpecContext::DSC_template_type_arg:
2042 case DeclSpecContext::DSC_trailing:
2043 case DeclSpecContext::DSC_alias_declaration:
2046 llvm_unreachable(
"Missing DeclSpecContext case");
2051 struct ForRangeInit {
2055 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2057 struct ForRangeInfo : ForRangeInit {
2063 ParsedAttributesWithRange &attrs);
2066 ParsedAttributesWithRange &attrs,
2068 ForRangeInit *FRI =
nullptr);
2072 ForRangeInit *FRI =
nullptr);
2073 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2074 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2075 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2076 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2078 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2079 ForRangeInit *FRI =
nullptr);
2087 bool trySkippingFunctionBody();
2090 const ParsedTemplateInfo &TemplateInfo,
2092 ParsedAttributesWithRange &Attrs);
2095 void ParseDeclarationSpecifiers(
2097 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2099 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2100 LateParsedAttrList *LateAttrs =
nullptr);
2101 bool DiagnoseMissingSemiAfterTagDefinition(
2103 LateParsedAttrList *LateAttrs =
nullptr);
2105 void ParseSpecifierQualifierList(
2107 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2113 const ParsedTemplateInfo &TemplateInfo,
2119 void ParseStructDeclaration(
2123 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2124 bool isTypeSpecifierQualifier();
2129 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2134 bool isKnownToBeDeclarationSpecifier() {
2136 return isCXXDeclarationSpecifier() == TPResult::True;
2137 return isDeclarationSpecifier(
true);
2143 bool isDeclarationStatement() {
2145 return isCXXDeclarationStatement();
2146 return isDeclarationSpecifier(
true);
2153 bool isForInitDeclaration() {
2157 return isCXXSimpleDeclaration(
true);
2158 return isDeclarationSpecifier(
true);
2162 bool isForRangeIdentifier();
2166 bool isStartOfObjCClassMessageMissingOpenBracket();
2171 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2175 enum TentativeCXXTypeIdContext {
2178 TypeIdAsTemplateArgument
2185 bool isTypeIdInParens(
bool &isAmbiguous) {
2187 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2188 isAmbiguous =
false;
2189 return isTypeSpecifierQualifier();
2191 bool isTypeIdInParens() {
2193 return isTypeIdInParens(isAmbiguous);
2199 bool isTypeIdUnambiguously() {
2202 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2203 return isTypeSpecifierQualifier();
2209 bool isCXXDeclarationStatement();
2216 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2225 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2228 enum class ConditionOrInitStatement {
2238 ConditionOrInitStatement
2239 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2240 bool CanBeForRangeDecl);
2242 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2243 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2245 return isCXXTypeId(Context, isAmbiguous);
2250 enum class TPResult {
2251 True, False, Ambiguous, Error
2274 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2275 bool *HasMissingTypename =
nullptr);
2280 bool isCXXDeclarationSpecifierAType();
2294 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2295 TPResult TryParseTypeofSpecifier();
2296 TPResult TryParseProtocolQualifiers();
2297 TPResult TryParsePtrOperatorSeq();
2298 TPResult TryParseOperatorId();
2299 TPResult TryParseInitDeclaratorList();
2300 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2301 bool mayHaveDirectInit =
false);
2303 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2304 bool VersusTemplateArg =
false);
2305 TPResult TryParseFunctionDeclarator();
2306 TPResult TryParseBracketDeclarator();
2307 TPResult TryConsumeDeclarationSpecifier();
2314 Decl **OwnedType =
nullptr,
2321 bool standardAttributesAllowed()
const {
2323 return LO.DoubleSquareBracketAttributes;
2328 bool CheckProhibitedCXX11Attribute() {
2329 assert(Tok.
is(tok::l_square));
2330 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2332 return DiagnoseProhibitedCXX11Attribute();
2335 bool DiagnoseProhibitedCXX11Attribute();
2336 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2338 if (!standardAttributesAllowed())
2341 Tok.
isNot(tok::kw_alignas))
2343 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2345 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2348 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2352 void ProhibitAttributes(ParsedAttributesWithRange &Attrs,
2354 if (Attrs.Range.isInvalid())
2356 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2360 void ProhibitAttributes(ParsedAttributesViewWithRange &Attrs,
2362 if (Attrs.Range.isInvalid())
2364 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2365 Attrs.clearListOnly();
2367 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2373 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2383 void DiagnoseAndSkipCXX11Attributes();
2395 void MaybeParseGNUAttributes(Declarator &D,
2396 LateParsedAttrList *LateAttrs =
nullptr) {
2397 if (Tok.
is(tok::kw___attribute)) {
2400 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2406 LateParsedAttrList *LateAttrs =
nullptr) {
2407 if (Tok.
is(tok::kw___attribute))
2408 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2412 LateParsedAttrList *LateAttrs =
nullptr,
2413 Declarator *D =
nullptr);
2427 void MaybeParseCXX11Attributes(Declarator &D) {
2428 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2429 ParsedAttributesWithRange attrs(AttrFactory);
2431 ParseCXX11Attributes(attrs, &endLoc);
2437 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2438 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2439 ParseCXX11Attributes(attrsWithRange, endLoc);
2443 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2445 bool OuterMightBeMessageSend =
false) {
2446 if (standardAttributesAllowed() &&
2447 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2448 ParseCXX11Attributes(attrs, endLoc);
2453 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2468 ParseMicrosoftAttributes(attrs, endLoc);
2476 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2477 ParseMicrosoftDeclSpecs(Attrs,
End);
2485 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2496 return ParseOpenCLUnrollHintAttribute(Attrs);
2504 VersionTuple ParseVersionTuple(
SourceRange &Range);
2516 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2524 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2546 void ParseTypeofSpecifier(
DeclSpec &DS);
2548 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2551 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2552 void ParseAtomicSpecifier(
DeclSpec &DS);
2561 return isCXX11VirtSpecifier(Tok);
2563 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2566 bool isCXX11FinalKeyword()
const;
2571 class DeclaratorScopeObj {
2578 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2580 void EnterDeclaratorScope() {
2581 assert(!EnteredScope &&
"Already entered the scope!");
2582 assert(SS.
isSet() &&
"C++ scope was not set!");
2584 CreatedScope =
true;
2588 EnteredScope =
true;
2591 ~DeclaratorScopeObj() {
2593 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2602 void ParseDeclarator(Declarator &D);
2604 typedef void (
Parser::*DirectDeclParseFunction)(Declarator&);
2605 void ParseDeclaratorInternal(Declarator &D,
2606 DirectDeclParseFunction DirectDeclParser);
2608 enum AttrRequirements {
2609 AR_NoAttributesParsed = 0,
2610 AR_GNUAttributesParsedAndRejected = 1 << 0,
2611 AR_GNUAttributesParsed = 1 << 1,
2612 AR_CXX11AttributesParsed = 1 << 2,
2613 AR_DeclspecAttributesParsed = 1 << 3,
2614 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2615 AR_CXX11AttributesParsed |
2616 AR_DeclspecAttributesParsed,
2617 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2618 AR_DeclspecAttributesParsed
2621 void ParseTypeQualifierListOpt(
2622 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2623 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2625 void ParseDirectDeclarator(Declarator &D);
2626 void ParseDecompositionDeclarator(Declarator &D);
2627 void ParseParenDeclarator(Declarator &D);
2628 void ParseFunctionDeclarator(Declarator &D,
2632 bool RequiresArg =
false);
2633 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2635 bool isFunctionDeclaratorIdentifierList();
2636 void ParseFunctionDeclaratorIdentifierList(
2639 void ParseParameterDeclarationClause(
2644 void ParseBracketDeclarator(Declarator &D);
2645 void ParseMisplacedBracketDeclarator(Declarator &D);
2651 enum CXX11AttributeKind {
2653 CAK_NotAttributeSpecifier,
2655 CAK_AttributeSpecifier,
2658 CAK_InvalidAttributeSpecifier
2661 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2662 bool OuterMightBeMessageSend =
false);
2664 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2670 struct InnerNamespaceInfo {
2683 Decl *ParseExportDeclaration();
2684 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2692 struct UsingDeclarator {
2707 const ParsedTemplateInfo &TemplateInfo,
2711 Decl *ParseAliasDeclarationAfterDeclarator(
2723 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2725 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2727 DeclSpecContext DSC,
2728 ParsedAttributesWithRange &Attributes);
2735 ParsedAttributesWithRange &Attrs,
2740 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
2743 LateParsedAttrList &LateAttrs);
2744 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
2746 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2748 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2750 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2753 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2755 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
2762 void ParseBaseClause(
Decl *ClassDecl);
2770 bool EnteringContext,
2773 bool AssumeTemplateId);
2774 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2781 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2785 DeclGroupPtrTy ParseOMPDeclareTargetClauses();
2790 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2795 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2798 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2807 bool ParseOpenMPSimpleVarList(
2811 bool AllowScopeSpecifier);
2820 ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed);
2890 bool IsMapTypeImplicit =
false;
2899 bool AllowDestructorName,
2900 bool AllowConstructorName,
2901 bool AllowDeductionGuide,
2919 Decl *ParseSingleDeclarationAfterTemplate(
2923 bool ParseTemplateParameters(
unsigned Depth,
2927 bool ParseTemplateParameterList(
unsigned Depth,
2929 bool isStartOfTemplateTypeParameter();
2930 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
2931 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
2932 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
2933 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
2936 bool AlreadyHasEllipsis,
2937 bool IdentifierHasName);
2938 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
2944 bool ConsumeLastToken,
2945 bool ObjCGenericList);
2946 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
2948 TemplateArgList &TemplateArgs,
2955 bool AllowTypeAnnotation =
true);
2956 void AnnotateTemplateIdTokenAsType(
bool IsClassName =
false);
2957 bool IsTemplateArgumentList(
unsigned Skip = 0);
2958 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
2970 DeclGroupPtrTy ParseModuleDecl();
2972 bool parseMisplacedModuleImport();
2973 bool tryParseMisplacedModuleImport() {
2975 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
2976 Kind == tok::annot_module_include)
2977 return parseMisplacedModuleImport();
2981 bool ParseModuleName(
2997 void CodeCompleteDirective(
bool InConditional)
override;
2998 void CodeCompleteInConditionalExclusion()
override;
2999 void CodeCompleteMacroName(
bool IsDefinition)
override;
3000 void CodeCompletePreprocessorExpression()
override;
3002 unsigned ArgumentIndex)
override;
3003 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3004 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.
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.
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
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.
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.
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.
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.