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;
413 assert(!isTokenSpecial() &&
414 "Should consume special tokens with Consume*Token");
417 return PrevTokLocation;
421 if (Tok.
isNot(Expected))
423 assert(!isTokenSpecial() &&
424 "Should consume special tokens with Consume*Token");
433 Loc = PrevTokLocation;
442 return ConsumeParen();
443 if (isTokenBracket())
444 return ConsumeBracket();
446 return ConsumeBrace();
447 if (isTokenStringLiteral())
448 return ConsumeStringToken();
449 if (Tok.
is(tok::code_completion))
450 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
451 : handleUnexpectedCodeCompletionToken();
453 return ConsumeAnnotationToken();
474 bool isTokenParen()
const {
475 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
478 bool isTokenBracket()
const {
479 return Tok.
isOneOf(tok::l_square, tok::r_square);
482 bool isTokenBrace()
const {
483 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
486 bool isTokenStringLiteral()
const {
490 bool isTokenSpecial()
const {
491 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
492 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
497 bool isTokenEqualOrEqualTypo();
501 void UnconsumeToken(
Token &Consumed) {
519 assert(isTokenParen() &&
"wrong consume method");
520 if (Tok.
getKind() == tok::l_paren)
522 else if (ParenCount) {
523 AngleBrackets.clear(*
this);
528 return PrevTokLocation;
534 assert(isTokenBracket() &&
"wrong consume method");
535 if (Tok.
getKind() == tok::l_square)
537 else if (BracketCount) {
538 AngleBrackets.clear(*
this);
544 return PrevTokLocation;
550 assert(isTokenBrace() &&
"wrong consume method");
551 if (Tok.
getKind() == tok::l_brace)
553 else if (BraceCount) {
554 AngleBrackets.clear(*
this);
560 return PrevTokLocation;
568 assert(isTokenStringLiteral() &&
569 "Should only consume string literals with this method");
572 return PrevTokLocation;
581 assert(Tok.
is(tok::code_completion));
584 return PrevTokLocation;
596 void cutOffParsing() {
607 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
608 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
618 void initializePragmaHandlers();
621 void resetPragmaHandlers();
624 void HandlePragmaUnused();
628 void HandlePragmaVisibility();
632 void HandlePragmaPack();
636 void HandlePragmaMSStruct();
640 void HandlePragmaMSComment();
642 void HandlePragmaMSPointersToMembers();
644 void HandlePragmaMSVtorDisp();
646 void HandlePragmaMSPragma();
647 bool HandlePragmaMSSection(StringRef PragmaName,
649 bool HandlePragmaMSSegment(StringRef PragmaName,
651 bool HandlePragmaMSInitSeg(StringRef PragmaName,
656 void HandlePragmaAlign();
660 void HandlePragmaDump();
664 void HandlePragmaWeak();
668 void HandlePragmaWeakAlias();
672 void HandlePragmaRedefineExtname();
676 void HandlePragmaFPContract();
680 void HandlePragmaFEnvAccess();
684 void HandlePragmaFP();
688 void HandlePragmaOpenCLExtension();
696 bool HandlePragmaLoopHint(
LoopHint &Hint);
698 bool ParsePragmaAttributeSubjectMatchRuleSet(
702 void HandlePragmaAttribute();
711 const Token &GetLookAheadToken(
unsigned N) {
754 enum AnnotatedNameKind {
767 TryAnnotateName(
bool IsAddressOfOperand,
768 std::unique_ptr<CorrectionCandidateCallback> CCC =
nullptr);
771 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
777 const char *&PrevSpec,
unsigned &DiagID,
787 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
793 bool TryAltiVecVectorToken() {
796 return TryAltiVecVectorTokenOutOfLine();
799 bool TryAltiVecVectorTokenOutOfLine();
801 const char *&PrevSpec,
unsigned &DiagID,
807 bool isObjCInstancetype() {
811 if (!Ident_instancetype)
821 bool TryKeywordIdentFallback(
bool DisableKeyword);
837 class TentativeParsingAction {
840 size_t PrevTentativelyDeclaredIdentifierCount;
841 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
845 explicit TentativeParsingAction(
Parser& p) :
P(p) {
847 PrevTentativelyDeclaredIdentifierCount =
848 P.TentativelyDeclaredIdentifiers.size();
849 PrevParenCount = P.ParenCount;
850 PrevBracketCount = P.BracketCount;
851 PrevBraceCount = P.BraceCount;
856 assert(isActive &&
"Parsing action was finished!");
857 P.TentativelyDeclaredIdentifiers.resize(
858 PrevTentativelyDeclaredIdentifierCount);
863 assert(isActive &&
"Parsing action was finished!");
866 P.TentativelyDeclaredIdentifiers.resize(
867 PrevTentativelyDeclaredIdentifierCount);
868 P.ParenCount = PrevParenCount;
869 P.BracketCount = PrevBracketCount;
870 P.BraceCount = PrevBraceCount;
873 ~TentativeParsingAction() {
874 assert(!isActive &&
"Forgot to call Commit or Revert!");
879 class RevertingTentativeParsingAction
880 :
private Parser::TentativeParsingAction {
882 RevertingTentativeParsingAction(
Parser &
P)
883 : Parser::TentativeParsingAction(P) {}
884 ~RevertingTentativeParsingAction() { Revert(); }
899 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
918 unsigned Diag = diag::err_expected,
919 StringRef DiagMsg =
"");
926 bool ExpectAndConsumeSemi(
unsigned DiagID);
932 InstanceVariableList = 2,
933 AfterMemberFunctionDefinition = 3
937 void ConsumeExtraSemi(ExtraSemiKind Kind,
unsigned TST =
TST_unspecified);
945 bool expectIdentifier();
967 bool BeforeCompoundStmt =
false)
969 if (EnteredScope && !BeforeCompoundStmt)
972 if (BeforeCompoundStmt)
975 this->Self =
nullptr;
1001 class ParseScopeFlags {
1004 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1005 void operator=(
const ParseScopeFlags &) =
delete;
1008 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1019 return Diag(Tok, DiagID);
1040 static_cast<unsigned>(R));
1053 return SkipUntil(llvm::makeArrayRef(T), Flags);
1076 struct ParsingClass;
1086 class LateParsedDeclaration {
1088 virtual ~LateParsedDeclaration();
1090 virtual void ParseLexedMethodDeclarations();
1091 virtual void ParseLexedMemberInitializers();
1092 virtual void ParseLexedMethodDefs();
1093 virtual void ParseLexedAttributes();
1098 class LateParsedClass :
public LateParsedDeclaration {
1100 LateParsedClass(
Parser *
P, ParsingClass *
C);
1101 ~LateParsedClass()
override;
1103 void ParseLexedMethodDeclarations()
override;
1104 void ParseLexedMemberInitializers()
override;
1105 void ParseLexedMethodDefs()
override;
1106 void ParseLexedAttributes()
override;
1110 ParsingClass *Class;
1119 struct LateParsedAttribute :
public LateParsedDeclaration {
1128 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1130 void ParseLexedAttributes()
override;
1132 void addDecl(
Decl *D) { Decls.push_back(D); }
1136 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1138 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1140 bool parseSoon() {
return ParseSoon; }
1149 struct LexedMethod :
public LateParsedDeclaration {
1160 : Self(P), D(MD), TemplateScope(
false) {}
1162 void ParseLexedMethodDefs()
override;
1169 struct LateParsedDefaultArgument {
1170 explicit LateParsedDefaultArgument(
Decl *
P,
1171 std::unique_ptr<CachedTokens> Toks =
nullptr)
1172 : Param(P), Toks(std::move(Toks)) { }
1181 std::unique_ptr<CachedTokens> Toks;
1188 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1189 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1190 : Self(P), Method(M), TemplateScope(
false),
1191 ExceptionSpecTokens(
nullptr) {}
1193 void ParseLexedMethodDeclarations()
override;
1220 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1222 : Self(P), Field(FD) { }
1224 void ParseLexedMemberInitializers()
override;
1247 struct ParsingClass {
1248 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1249 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1250 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1254 bool TopLevelClass : 1;
1259 bool TemplateScope : 1;
1262 bool IsInterface : 1;
1265 Decl *TagOrTemplate;
1270 LateParsedDeclarationsContainer LateParsedDeclarations;
1276 std::stack<ParsingClass *> ClassStack;
1278 ParsingClass &getCurrentClass() {
1279 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1280 return *ClassStack.top();
1284 class ParsingClassDefinition {
1290 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1292 :
P(P), Popped(
false),
1293 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1298 assert(!Popped &&
"Nested class has already been popped");
1300 P.PopParsingClass(State);
1303 ~ParsingClassDefinition() {
1305 P.PopParsingClass(State);
1312 struct ParsedTemplateInfo {
1313 ParsedTemplateInfo()
1314 :
Kind(NonTemplate), TemplateParams(
nullptr), TemplateLoc() { }
1316 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1317 bool isSpecialization,
1318 bool lastParameterListWasEmpty =
false)
1319 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1320 TemplateParams(TemplateParams),
1321 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1325 :
Kind(ExplicitInstantiation), TemplateParams(
nullptr),
1326 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1327 LastParameterListWasEmpty(
false){ }
1336 ExplicitSpecialization,
1338 ExplicitInstantiation
1343 TemplateParameterLists *TemplateParams;
1354 bool LastParameterListWasEmpty;
1359 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1363 static void LateTemplateParserCleanupCallback(
void *P);
1366 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1367 void DeallocateParsedClasses(ParsingClass *Class);
1370 enum CachedInitKind {
1371 CIK_DefaultArgument,
1372 CIK_DefaultInitializer
1378 const ParsedTemplateInfo &TemplateInfo,
1381 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1382 void ParseLexedAttributes(ParsingClass &Class);
1383 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1384 bool EnterScope,
bool OnDefinition);
1385 void ParseLexedAttribute(LateParsedAttribute &LA,
1386 bool EnterScope,
bool OnDefinition);
1387 void ParseLexedMethodDeclarations(ParsingClass &Class);
1388 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1389 void ParseLexedMethodDefs(ParsingClass &Class);
1390 void ParseLexedMethodDef(LexedMethod &LM);
1391 void ParseLexedMemberInitializers(ParsingClass &Class);
1392 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1393 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1394 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1395 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1400 bool ConsumeFinalToken =
true) {
1401 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1406 bool ConsumeFinalToken =
true);
1423 void clearListOnly() {
1431 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1433 bool isDeclarationAfterDeclarator();
1435 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1436 ParsedAttributesWithRange &attrs,
1439 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1443 void SkipFunctionBody();
1445 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1446 LateParsedAttrList *LateParsedAttrs =
nullptr);
1447 void ParseKNRParamDeclarations(Declarator &D);
1455 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs);
1456 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1469 bool RBraceMissing);
1470 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1475 bool WarnOnDeclarations,
1476 bool ForObjCContainer,
1479 bool consumeLastToken);
1484 void parseObjCTypeArgsOrProtocolQualifiers(
1493 bool consumeLastToken,
1494 bool warnOnIncompleteProtocols);
1498 void parseObjCTypeArgsAndProtocolQualifiers(
1507 bool consumeLastToken);
1517 bool consumeLastToken,
1522 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1525 struct ObjCImplParsingDataRAII {
1530 LateParsedObjCMethodContainer LateParsedObjCMethods;
1532 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1533 :
P(parser), Dcl(D), HasCFunction(
false) {
1534 P.CurParsedObjCImpl =
this;
1537 ~ObjCImplParsingDataRAII();
1540 bool isFinished()
const {
return Finished; }
1545 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1546 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1548 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc);
1549 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1557 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1558 objc_nonnull, objc_nullable, objc_null_unspecified,
1563 bool isTokIdentifier_in()
const;
1567 void ParseObjCMethodRequirement();
1568 Decl *ParseObjCMethodPrototype(
1570 bool MethodDefinition =
true);
1573 bool MethodDefinition=
true);
1576 Decl *ParseObjCMethodDefinition();
1599 unsigned &NumLineToksConsumed,
1600 bool IsUnevaluated);
1609 ExprResult ParseCastExpression(
bool isUnaryExpression,
1610 bool isAddressOfOperand,
1613 bool isVectorLiteral =
false);
1614 ExprResult ParseCastExpression(
bool isUnaryExpression,
1615 bool isAddressOfOperand =
false,
1617 bool isVectorLiteral =
false);
1620 bool isNotExpressionStart();
1624 bool isPostfixExpressionSuffixStart() {
1626 return (K == tok::l_square || K == tok::l_paren ||
1627 K == tok::period || K == tok::arrow ||
1628 K == tok::plusplus || K == tok::minusminus);
1632 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1634 const Token &OpToken);
1635 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1636 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1637 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1642 ExprResult ParseUnaryExprOrTypeTraitExpression();
1654 bool ParseExpressionList(
1657 llvm::function_ref<
void()> Completer = llvm::function_ref<
void()>());
1666 enum ParenParseOption {
1673 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1674 bool stopIfCastExpr,
1680 ParenParseOption &ExprType,
ParsedType &CastTy,
1686 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1688 ExprResult ParseGenericSelectionExpression();
1697 Token &Replacement);
1698 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1700 bool areTokensAdjacent(
const Token &A,
const Token &B);
1702 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1708 bool EnteringContext,
1709 bool *MayBePseudoDestructor =
nullptr,
1710 bool IsTypename =
false,
1712 bool OnlyNamespace =
false);
1721 bool *SkippedInits =
nullptr);
1723 ExprResult ParseLambdaExpressionAfterIntroducer(
1770 bool MayBeFollowedByDirectInit);
1783 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1785 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1791 void ParseDirectNewDeclarator(Declarator &D);
1793 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1798 struct ForRangeInfo;
1802 ForRangeInfo *FRI =
nullptr);
1817 if (Tok.
isNot(tok::l_brace))
1819 return ParseBraceInitializer();
1821 bool MayBeDesignationStart();
1823 ExprResult ParseInitializerWithPotentialDesignator();
1843 bool isSimpleObjCMessageExpression();
1848 Expr *ReceiverExpr);
1849 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1852 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1866 bool AllowOpenMPStandalone =
false);
1867 enum AllowedConstructsKind {
1871 ACK_StatementsOpenMPNonStandalone,
1873 ACK_StatementsOpenMPAnyExecutable
1876 ParseStatementOrDeclaration(StmtVector &Stmts, AllowedConstructsKind Allowed,
1878 StmtResult ParseStatementOrDeclarationAfterAttributes(
1880 AllowedConstructsKind Allowed,
1882 ParsedAttributesWithRange &Attrs);
1884 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs);
1885 StmtResult ParseCaseStatement(
bool MissingCase =
false,
1888 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
1889 StmtResult ParseCompoundStatement(
bool isStmtExpr,
1890 unsigned ScopeFlags);
1891 void ParseCompoundStatementLeadingPragmas();
1892 bool ConsumeNullStmt(StmtVector &Stmts);
1893 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
1894 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
1909 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
1910 AllowedConstructsKind Allowed,
1912 ParsedAttributesWithRange &Attrs);
1916 enum IfExistsBehavior {
1928 struct IfExistsCondition {
1943 IfExistsBehavior Behavior;
1946 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
1947 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
1948 void ParseMicrosoftIfExistsExternalDeclaration();
1952 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
1963 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
1989 enum class DeclSpecContext {
1994 DSC_alias_declaration,
1997 DSC_template_type_arg,
1998 DSC_objc_method_result,
2004 static bool isTypeSpecifier(DeclSpecContext DSC) {
2006 case DeclSpecContext::DSC_normal:
2007 case DeclSpecContext::DSC_template_param:
2008 case DeclSpecContext::DSC_class:
2009 case DeclSpecContext::DSC_top_level:
2010 case DeclSpecContext::DSC_objc_method_result:
2011 case DeclSpecContext::DSC_condition:
2014 case DeclSpecContext::DSC_template_type_arg:
2015 case DeclSpecContext::DSC_type_specifier:
2016 case DeclSpecContext::DSC_trailing:
2017 case DeclSpecContext::DSC_alias_declaration:
2020 llvm_unreachable(
"Missing DeclSpecContext case");
2025 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2027 case DeclSpecContext::DSC_normal:
2028 case DeclSpecContext::DSC_template_param:
2029 case DeclSpecContext::DSC_class:
2030 case DeclSpecContext::DSC_top_level:
2031 case DeclSpecContext::DSC_condition:
2032 case DeclSpecContext::DSC_type_specifier:
2035 case DeclSpecContext::DSC_objc_method_result:
2036 case DeclSpecContext::DSC_template_type_arg:
2037 case DeclSpecContext::DSC_trailing:
2038 case DeclSpecContext::DSC_alias_declaration:
2041 llvm_unreachable(
"Missing DeclSpecContext case");
2046 struct ForRangeInit {
2050 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2052 struct ForRangeInfo : ForRangeInit {
2058 ParsedAttributesWithRange &attrs);
2061 ParsedAttributesWithRange &attrs,
2063 ForRangeInit *FRI =
nullptr);
2067 ForRangeInit *FRI =
nullptr);
2068 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2069 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2070 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2071 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2073 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2074 ForRangeInit *FRI =
nullptr);
2082 bool trySkippingFunctionBody();
2085 const ParsedTemplateInfo &TemplateInfo,
2087 ParsedAttributesWithRange &Attrs);
2090 void ParseDeclarationSpecifiers(
2092 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2094 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2095 LateParsedAttrList *LateAttrs =
nullptr);
2096 bool DiagnoseMissingSemiAfterTagDefinition(
2098 LateParsedAttrList *LateAttrs =
nullptr);
2100 void ParseSpecifierQualifierList(
2102 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2108 const ParsedTemplateInfo &TemplateInfo,
2114 void ParseStructDeclaration(
2118 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2119 bool isTypeSpecifierQualifier();
2124 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2129 bool isKnownToBeDeclarationSpecifier() {
2131 return isCXXDeclarationSpecifier() == TPResult::True;
2132 return isDeclarationSpecifier(
true);
2138 bool isDeclarationStatement() {
2140 return isCXXDeclarationStatement();
2141 return isDeclarationSpecifier(
true);
2148 bool isForInitDeclaration() {
2152 return isCXXSimpleDeclaration(
true);
2153 return isDeclarationSpecifier(
true);
2157 bool isForRangeIdentifier();
2161 bool isStartOfObjCClassMessageMissingOpenBracket();
2166 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2170 enum TentativeCXXTypeIdContext {
2173 TypeIdAsTemplateArgument
2180 bool isTypeIdInParens(
bool &isAmbiguous) {
2182 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2183 isAmbiguous =
false;
2184 return isTypeSpecifierQualifier();
2186 bool isTypeIdInParens() {
2188 return isTypeIdInParens(isAmbiguous);
2194 bool isTypeIdUnambiguously() {
2197 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2198 return isTypeSpecifierQualifier();
2204 bool isCXXDeclarationStatement();
2211 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2220 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2223 enum class ConditionOrInitStatement {
2233 ConditionOrInitStatement
2234 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2235 bool CanBeForRangeDecl);
2237 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2238 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2240 return isCXXTypeId(Context, isAmbiguous);
2245 enum class TPResult {
2246 True, False, Ambiguous, Error
2269 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2270 bool *HasMissingTypename =
nullptr);
2275 bool isCXXDeclarationSpecifierAType();
2289 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2290 TPResult TryParseTypeofSpecifier();
2291 TPResult TryParseProtocolQualifiers();
2292 TPResult TryParsePtrOperatorSeq();
2293 TPResult TryParseOperatorId();
2294 TPResult TryParseInitDeclaratorList();
2295 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2296 bool mayHaveDirectInit =
false);
2298 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2299 bool VersusTemplateArg =
false);
2300 TPResult TryParseFunctionDeclarator();
2301 TPResult TryParseBracketDeclarator();
2302 TPResult TryConsumeDeclarationSpecifier();
2309 Decl **OwnedType =
nullptr,
2316 bool standardAttributesAllowed()
const {
2318 return LO.DoubleSquareBracketAttributes;
2323 bool CheckProhibitedCXX11Attribute() {
2324 assert(Tok.
is(tok::l_square));
2325 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2327 return DiagnoseProhibitedCXX11Attribute();
2330 bool DiagnoseProhibitedCXX11Attribute();
2331 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2333 if (!standardAttributesAllowed())
2336 Tok.
isNot(tok::kw_alignas))
2338 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2340 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2343 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2347 void ProhibitAttributes(ParsedAttributesWithRange &Attrs,
2349 if (Attrs.Range.isInvalid())
2351 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2355 void ProhibitAttributes(ParsedAttributesViewWithRange &Attrs,
2357 if (Attrs.Range.isInvalid())
2359 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2360 Attrs.clearListOnly();
2362 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2368 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2378 void DiagnoseAndSkipCXX11Attributes();
2390 void MaybeParseGNUAttributes(Declarator &D,
2391 LateParsedAttrList *LateAttrs =
nullptr) {
2392 if (Tok.
is(tok::kw___attribute)) {
2395 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2401 LateParsedAttrList *LateAttrs =
nullptr) {
2402 if (Tok.
is(tok::kw___attribute))
2403 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2407 LateParsedAttrList *LateAttrs =
nullptr,
2408 Declarator *D =
nullptr);
2422 void MaybeParseCXX11Attributes(Declarator &D) {
2423 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2424 ParsedAttributesWithRange attrs(AttrFactory);
2426 ParseCXX11Attributes(attrs, &endLoc);
2432 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2433 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2434 ParseCXX11Attributes(attrsWithRange, endLoc);
2438 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2440 bool OuterMightBeMessageSend =
false) {
2441 if (standardAttributesAllowed() &&
2442 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2443 ParseCXX11Attributes(attrs, endLoc);
2448 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2463 ParseMicrosoftAttributes(attrs, endLoc);
2471 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2472 ParseMicrosoftDeclSpecs(Attrs,
End);
2480 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2491 return ParseOpenCLUnrollHintAttribute(Attrs);
2499 VersionTuple ParseVersionTuple(
SourceRange &Range);
2511 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2519 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2541 void ParseTypeofSpecifier(
DeclSpec &DS);
2543 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2546 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2547 void ParseAtomicSpecifier(
DeclSpec &DS);
2556 return isCXX11VirtSpecifier(Tok);
2558 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2561 bool isCXX11FinalKeyword()
const;
2566 class DeclaratorScopeObj {
2573 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2575 void EnterDeclaratorScope() {
2576 assert(!EnteredScope &&
"Already entered the scope!");
2577 assert(SS.
isSet() &&
"C++ scope was not set!");
2579 CreatedScope =
true;
2583 EnteredScope =
true;
2586 ~DeclaratorScopeObj() {
2588 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2597 void ParseDeclarator(Declarator &D);
2599 typedef void (
Parser::*DirectDeclParseFunction)(Declarator&);
2600 void ParseDeclaratorInternal(Declarator &D,
2601 DirectDeclParseFunction DirectDeclParser);
2603 enum AttrRequirements {
2604 AR_NoAttributesParsed = 0,
2605 AR_GNUAttributesParsedAndRejected = 1 << 0,
2606 AR_GNUAttributesParsed = 1 << 1,
2607 AR_CXX11AttributesParsed = 1 << 2,
2608 AR_DeclspecAttributesParsed = 1 << 3,
2609 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2610 AR_CXX11AttributesParsed |
2611 AR_DeclspecAttributesParsed,
2612 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2613 AR_DeclspecAttributesParsed
2616 void ParseTypeQualifierListOpt(
2617 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2618 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2620 void ParseDirectDeclarator(Declarator &D);
2621 void ParseDecompositionDeclarator(Declarator &D);
2622 void ParseParenDeclarator(Declarator &D);
2623 void ParseFunctionDeclarator(Declarator &D,
2627 bool RequiresArg =
false);
2628 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2630 bool isFunctionDeclaratorIdentifierList();
2631 void ParseFunctionDeclaratorIdentifierList(
2634 void ParseParameterDeclarationClause(
2639 void ParseBracketDeclarator(Declarator &D);
2640 void ParseMisplacedBracketDeclarator(Declarator &D);
2646 enum CXX11AttributeKind {
2648 CAK_NotAttributeSpecifier,
2650 CAK_AttributeSpecifier,
2653 CAK_InvalidAttributeSpecifier
2656 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2657 bool OuterMightBeMessageSend =
false);
2659 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2665 struct InnerNamespaceInfo {
2678 Decl *ParseExportDeclaration();
2679 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2687 struct UsingDeclarator {
2702 const ParsedTemplateInfo &TemplateInfo,
2706 Decl *ParseAliasDeclarationAfterDeclarator(
2718 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2720 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2722 DeclSpecContext DSC,
2723 ParsedAttributesWithRange &Attributes);
2730 ParsedAttributesWithRange &Attrs,
2735 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
2738 LateParsedAttrList &LateAttrs);
2739 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
2741 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2743 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2745 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2748 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2750 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
2757 void ParseBaseClause(
Decl *ClassDecl);
2765 bool EnteringContext,
2768 bool AssumeTemplateId);
2769 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2776 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2780 DeclGroupPtrTy ParseOMPDeclareTargetClauses();
2785 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2790 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2793 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2802 bool ParseOpenMPSimpleVarList(
2806 bool AllowScopeSpecifier);
2815 ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed);
2885 bool IsMapTypeImplicit =
false;
2894 bool AllowDestructorName,
2895 bool AllowConstructorName,
2896 bool AllowDeductionGuide,
2914 Decl *ParseSingleDeclarationAfterTemplate(
2918 bool ParseTemplateParameters(
unsigned Depth,
2922 bool ParseTemplateParameterList(
unsigned Depth,
2924 bool isStartOfTemplateTypeParameter();
2925 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
2926 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
2927 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
2928 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
2931 bool AlreadyHasEllipsis,
2932 bool IdentifierHasName);
2933 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
2939 bool ConsumeLastToken,
2940 bool ObjCGenericList);
2941 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
2943 TemplateArgList &TemplateArgs,
2950 bool AllowTypeAnnotation =
true);
2951 void AnnotateTemplateIdTokenAsType(
bool IsClassName =
false);
2952 bool IsTemplateArgumentList(
unsigned Skip = 0);
2953 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
2965 DeclGroupPtrTy ParseModuleDecl();
2967 bool parseMisplacedModuleImport();
2968 bool tryParseMisplacedModuleImport() {
2970 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
2971 Kind == tok::annot_module_include)
2972 return parseMisplacedModuleImport();
2976 bool ParseModuleName(
2992 void CodeCompleteDirective(
bool InConditional)
override;
2993 void CodeCompleteInConditionalExclusion()
override;
2994 void CodeCompleteMacroName(
bool IsDefinition)
override;
2995 void CodeCompletePreprocessorExpression()
override;
2997 unsigned ArgumentIndex)
override;
2998 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
2999 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.