13 #ifndef LLVM_CLANG_PARSE_PARSER_H 14 #define LLVM_CLANG_PARSE_PARSER_H 26 #include "llvm/ADT/SmallVector.h" 27 #include "llvm/Support/Compiler.h" 28 #include "llvm/Support/PrettyStackTrace.h" 29 #include "llvm/Support/SaveAndRestore.h" 36 class BalancedDelimiterTracker;
37 class CorrectionCandidateCallback;
39 class DiagnosticBuilder;
42 class ParsingDeclRAIIObject;
43 class ParsingDeclSpec;
44 class ParsingDeclarator;
45 class ParsingFieldDeclarator;
46 class ColonProtectionRAIIObject;
47 class InMessageExpressionRAIIObject;
48 class PoisonSEHIdentifiersRAIIObject;
50 class ObjCTypeParamList;
51 class ObjCTypeParameter;
81 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
82 unsigned short MisplacedModuleBeginCount = 0;
91 enum { ScopeCacheSize = 16 };
92 unsigned NumCachedScopes;
93 Scope *ScopeCache[ScopeCacheSize];
99 *Ident___exception_code,
100 *Ident_GetExceptionCode;
103 *Ident___exception_info,
104 *Ident_GetExceptionInfo;
107 *Ident___abnormal_termination,
108 *Ident_AbnormalTermination;
151 *Ident_generated_declaration;
164 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
166 std::unique_ptr<PragmaHandler> AlignHandler;
167 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
168 std::unique_ptr<PragmaHandler> OptionsHandler;
169 std::unique_ptr<PragmaHandler> PackHandler;
170 std::unique_ptr<PragmaHandler> MSStructHandler;
171 std::unique_ptr<PragmaHandler> UnusedHandler;
172 std::unique_ptr<PragmaHandler> WeakHandler;
173 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
174 std::unique_ptr<PragmaHandler> FPContractHandler;
175 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
176 std::unique_ptr<PragmaHandler> OpenMPHandler;
177 std::unique_ptr<PragmaHandler> PCSectionHandler;
178 std::unique_ptr<PragmaHandler> MSCommentHandler;
179 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
180 std::unique_ptr<PragmaHandler> MSPointersToMembers;
181 std::unique_ptr<PragmaHandler> MSVtorDisp;
182 std::unique_ptr<PragmaHandler> MSInitSeg;
183 std::unique_ptr<PragmaHandler> MSDataSeg;
184 std::unique_ptr<PragmaHandler> MSBSSSeg;
185 std::unique_ptr<PragmaHandler> MSConstSeg;
186 std::unique_ptr<PragmaHandler> MSCodeSeg;
187 std::unique_ptr<PragmaHandler> MSSection;
188 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
189 std::unique_ptr<PragmaHandler> MSIntrinsic;
190 std::unique_ptr<PragmaHandler> MSOptimize;
191 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
192 std::unique_ptr<PragmaHandler> OptimizeHandler;
193 std::unique_ptr<PragmaHandler> LoopHintHandler;
194 std::unique_ptr<PragmaHandler> UnrollHintHandler;
195 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
196 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
197 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
198 std::unique_ptr<PragmaHandler> FPHandler;
199 std::unique_ptr<PragmaHandler> STDCFENVHandler;
200 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
201 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
202 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
204 std::unique_ptr<CommentHandler> CommentSemaHandler;
210 bool GreaterThanIsOperator;
223 bool InMessageExpression;
228 bool CalledSignatureHelp =
false;
231 unsigned TemplateParameterDepth;
234 class TemplateParameterDepthRAII {
236 unsigned AddedLevels;
238 explicit TemplateParameterDepthRAII(
unsigned &Depth)
239 : Depth(Depth), AddedLevels(0) {}
241 ~TemplateParameterDepthRAII() {
242 Depth -= AddedLevels;
249 void addDepth(
unsigned D) {
253 void setAddedDepth(
unsigned D) {
254 Depth = Depth - AddedLevels + D;
258 unsigned getDepth()
const {
return Depth; }
259 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
282 struct AngleBracketTracker {
285 enum Priority :
unsigned short {
292 SpaceBeforeLess = 0x0,
294 NoSpaceBeforeLess = 0x1,
296 LLVM_MARK_AS_BITMASK_ENUM( DependentName)
306 return P.ParenCount == ParenCount && P.BracketCount == BracketCount &&
307 P.BraceCount == BraceCount;
311 return isActive(P) || P.ParenCount > ParenCount ||
312 P.BracketCount > BracketCount || P.BraceCount > BraceCount;
325 if (!Locs.empty() && Locs.back().isActive(P)) {
326 if (Locs.back().Priority <= Prio) {
327 Locs.back().TemplateName = TemplateName;
328 Locs.back().LessLoc = LessLoc;
329 Locs.back().Priority = Prio;
332 Locs.push_back({TemplateName, LessLoc, Prio,
333 P.ParenCount, P.BracketCount, P.BraceCount});
341 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
348 if (!Locs.empty() && Locs.back().isActive(P))
354 AngleBracketTracker AngleBrackets;
363 bool ParsingInObjCContainer;
369 bool SkipFunctionBodies;
377 enum class ParsedStmtContext {
380 AllowDeclarationsInC = 0x1,
382 AllowStandaloneOpenMPDirectives = 0x2,
389 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
391 LLVM_MARK_AS_BITMASK_ENUM(InStmtExpr)
449 assert(!isTokenSpecial() &&
450 "Should consume special tokens with Consume*Token");
453 return PrevTokLocation;
457 if (Tok.
isNot(Expected))
459 assert(!isTokenSpecial() &&
460 "Should consume special tokens with Consume*Token");
469 Loc = PrevTokLocation;
478 return ConsumeParen();
479 if (isTokenBracket())
480 return ConsumeBracket();
482 return ConsumeBrace();
483 if (isTokenStringLiteral())
484 return ConsumeStringToken();
485 if (Tok.
is(tok::code_completion))
486 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
487 : handleUnexpectedCodeCompletionToken();
489 return ConsumeAnnotationToken();
510 bool isTokenParen()
const {
511 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
514 bool isTokenBracket()
const {
515 return Tok.
isOneOf(tok::l_square, tok::r_square);
518 bool isTokenBrace()
const {
519 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
522 bool isTokenStringLiteral()
const {
526 bool isTokenSpecial()
const {
527 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
528 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
533 bool isTokenEqualOrEqualTypo();
537 void UnconsumeToken(
Token &Consumed) {
555 assert(isTokenParen() &&
"wrong consume method");
556 if (Tok.
getKind() == tok::l_paren)
558 else if (ParenCount) {
559 AngleBrackets.clear(*
this);
564 return PrevTokLocation;
570 assert(isTokenBracket() &&
"wrong consume method");
571 if (Tok.
getKind() == tok::l_square)
573 else if (BracketCount) {
574 AngleBrackets.clear(*
this);
580 return PrevTokLocation;
586 assert(isTokenBrace() &&
"wrong consume method");
587 if (Tok.
getKind() == tok::l_brace)
589 else if (BraceCount) {
590 AngleBrackets.clear(*
this);
596 return PrevTokLocation;
604 assert(isTokenStringLiteral() &&
605 "Should only consume string literals with this method");
608 return PrevTokLocation;
617 assert(Tok.
is(tok::code_completion));
620 return PrevTokLocation;
632 void cutOffParsing() {
643 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
644 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
654 void initializePragmaHandlers();
657 void resetPragmaHandlers();
660 void HandlePragmaUnused();
664 void HandlePragmaVisibility();
668 void HandlePragmaPack();
672 void HandlePragmaMSStruct();
676 void HandlePragmaMSComment();
678 void HandlePragmaMSPointersToMembers();
680 void HandlePragmaMSVtorDisp();
682 void HandlePragmaMSPragma();
683 bool HandlePragmaMSSection(StringRef PragmaName,
685 bool HandlePragmaMSSegment(StringRef PragmaName,
687 bool HandlePragmaMSInitSeg(StringRef PragmaName,
692 void HandlePragmaAlign();
696 void HandlePragmaDump();
700 void HandlePragmaWeak();
704 void HandlePragmaWeakAlias();
708 void HandlePragmaRedefineExtname();
712 void HandlePragmaFPContract();
716 void HandlePragmaFEnvAccess();
720 void HandlePragmaFP();
724 void HandlePragmaOpenCLExtension();
732 bool HandlePragmaLoopHint(
LoopHint &Hint);
734 bool ParsePragmaAttributeSubjectMatchRuleSet(
738 void HandlePragmaAttribute();
747 const Token &GetLookAheadToken(
unsigned N) {
790 enum AnnotatedNameKind {
802 AnnotatedNameKind TryAnnotateName(
bool IsAddressOfOperand,
806 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
812 const char *&PrevSpec,
unsigned &DiagID,
822 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
828 bool TryAltiVecVectorToken() {
831 return TryAltiVecVectorTokenOutOfLine();
834 bool TryAltiVecVectorTokenOutOfLine();
836 const char *&PrevSpec,
unsigned &DiagID,
842 bool isObjCInstancetype() {
846 if (!Ident_instancetype)
856 bool TryKeywordIdentFallback(
bool DisableKeyword);
872 class TentativeParsingAction {
876 size_t PrevTentativelyDeclaredIdentifierCount;
877 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
881 explicit TentativeParsingAction(
Parser&
p) :
P(p) {
882 PrevPreferredType = P.PreferredType;
884 PrevTentativelyDeclaredIdentifierCount =
885 P.TentativelyDeclaredIdentifiers.size();
886 PrevParenCount = P.ParenCount;
887 PrevBracketCount = P.BracketCount;
888 PrevBraceCount = P.BraceCount;
893 assert(isActive &&
"Parsing action was finished!");
894 P.TentativelyDeclaredIdentifiers.resize(
895 PrevTentativelyDeclaredIdentifierCount);
900 assert(isActive &&
"Parsing action was finished!");
902 P.PreferredType = PrevPreferredType;
904 P.TentativelyDeclaredIdentifiers.resize(
905 PrevTentativelyDeclaredIdentifierCount);
906 P.ParenCount = PrevParenCount;
907 P.BracketCount = PrevBracketCount;
908 P.BraceCount = PrevBraceCount;
911 ~TentativeParsingAction() {
912 assert(!isActive &&
"Forgot to call Commit or Revert!");
917 class RevertingTentativeParsingAction
918 :
private Parser::TentativeParsingAction {
920 RevertingTentativeParsingAction(
Parser &
P)
921 : Parser::TentativeParsingAction(P) {}
922 ~RevertingTentativeParsingAction() { Revert(); }
937 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
956 unsigned Diag = diag::err_expected,
957 StringRef DiagMsg =
"");
964 bool ExpectAndConsumeSemi(
unsigned DiagID);
970 InstanceVariableList = 2,
971 AfterMemberFunctionDefinition = 3
975 void ConsumeExtraSemi(ExtraSemiKind Kind,
unsigned TST =
TST_unspecified);
983 bool expectIdentifier();
1005 bool BeforeCompoundStmt =
false)
1007 if (EnteredScope && !BeforeCompoundStmt)
1010 if (BeforeCompoundStmt)
1013 this->Self =
nullptr;
1039 class ParseScopeFlags {
1042 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1043 void operator=(
const ParseScopeFlags &) =
delete;
1046 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1057 return Diag(Tok, DiagID);
1078 static_cast<unsigned>(R));
1091 return SkipUntil(llvm::makeArrayRef(T), Flags);
1114 struct ParsingClass;
1124 class LateParsedDeclaration {
1126 virtual ~LateParsedDeclaration();
1128 virtual void ParseLexedMethodDeclarations();
1129 virtual void ParseLexedMemberInitializers();
1130 virtual void ParseLexedMethodDefs();
1131 virtual void ParseLexedAttributes();
1136 class LateParsedClass :
public LateParsedDeclaration {
1138 LateParsedClass(
Parser *
P, ParsingClass *
C);
1139 ~LateParsedClass()
override;
1141 void ParseLexedMethodDeclarations()
override;
1142 void ParseLexedMemberInitializers()
override;
1143 void ParseLexedMethodDefs()
override;
1144 void ParseLexedAttributes()
override;
1148 ParsingClass *Class;
1157 struct LateParsedAttribute :
public LateParsedDeclaration {
1167 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1169 void ParseLexedAttributes()
override;
1171 void addDecl(
Decl *D) { Decls.push_back(D); }
1175 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1177 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1179 bool parseSoon() {
return ParseSoon; }
1188 struct LexedMethod :
public LateParsedDeclaration {
1199 : Self(P), D(MD), TemplateScope(
false) {}
1201 void ParseLexedMethodDefs()
override;
1208 struct LateParsedDefaultArgument {
1209 explicit LateParsedDefaultArgument(
Decl *
P,
1210 std::unique_ptr<CachedTokens> Toks =
nullptr)
1211 : Param(P), Toks(std::move(Toks)) { }
1220 std::unique_ptr<CachedTokens> Toks;
1227 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1228 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1229 : Self(P), Method(M), TemplateScope(
false),
1230 ExceptionSpecTokens(
nullptr) {}
1232 void ParseLexedMethodDeclarations()
override;
1259 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1261 : Self(P), Field(FD) { }
1263 void ParseLexedMemberInitializers()
override;
1286 struct ParsingClass {
1287 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1288 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1289 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1293 bool TopLevelClass : 1;
1298 bool TemplateScope : 1;
1301 bool IsInterface : 1;
1304 Decl *TagOrTemplate;
1309 LateParsedDeclarationsContainer LateParsedDeclarations;
1315 std::stack<ParsingClass *> ClassStack;
1317 ParsingClass &getCurrentClass() {
1318 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1319 return *ClassStack.top();
1323 class ParsingClassDefinition {
1329 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1331 :
P(P), Popped(
false),
1332 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1337 assert(!Popped &&
"Nested class has already been popped");
1339 P.PopParsingClass(State);
1342 ~ParsingClassDefinition() {
1344 P.PopParsingClass(State);
1351 struct ParsedTemplateInfo {
1352 ParsedTemplateInfo()
1353 :
Kind(NonTemplate), TemplateParams(
nullptr), TemplateLoc() { }
1355 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1356 bool isSpecialization,
1357 bool lastParameterListWasEmpty =
false)
1358 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1359 TemplateParams(TemplateParams),
1360 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1364 :
Kind(ExplicitInstantiation), TemplateParams(
nullptr),
1365 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1366 LastParameterListWasEmpty(
false){ }
1375 ExplicitSpecialization,
1377 ExplicitInstantiation
1382 TemplateParameterLists *TemplateParams;
1393 bool LastParameterListWasEmpty;
1398 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1402 static void LateTemplateParserCleanupCallback(
void *P);
1405 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1406 void DeallocateParsedClasses(ParsingClass *Class);
1409 enum CachedInitKind {
1410 CIK_DefaultArgument,
1411 CIK_DefaultInitializer
1417 const ParsedTemplateInfo &TemplateInfo,
1420 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1421 void ParseLexedAttributes(ParsingClass &Class);
1422 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1423 bool EnterScope,
bool OnDefinition);
1424 void ParseLexedAttribute(LateParsedAttribute &LA,
1425 bool EnterScope,
bool OnDefinition);
1426 void ParseLexedMethodDeclarations(ParsingClass &Class);
1427 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1428 void ParseLexedMethodDefs(ParsingClass &Class);
1429 void ParseLexedMethodDef(LexedMethod &LM);
1430 void ParseLexedMemberInitializers(ParsingClass &Class);
1431 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1432 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1433 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1434 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1439 bool ConsumeFinalToken =
true) {
1440 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1445 bool ConsumeFinalToken =
true);
1462 void clearListOnly() {
1470 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1472 bool isDeclarationAfterDeclarator();
1474 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1475 ParsedAttributesWithRange &attrs,
1478 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1482 void SkipFunctionBody();
1484 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1485 LateParsedAttrList *LateParsedAttrs =
nullptr);
1486 void ParseKNRParamDeclarations(Declarator &D);
1494 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributesWithRange &Attrs);
1495 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1508 bool RBraceMissing);
1509 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1514 bool WarnOnDeclarations,
1515 bool ForObjCContainer,
1518 bool consumeLastToken);
1523 void parseObjCTypeArgsOrProtocolQualifiers(
1532 bool consumeLastToken,
1533 bool warnOnIncompleteProtocols);
1537 void parseObjCTypeArgsAndProtocolQualifiers(
1546 bool consumeLastToken);
1556 bool consumeLastToken,
1561 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1564 struct ObjCImplParsingDataRAII {
1569 LateParsedObjCMethodContainer LateParsedObjCMethods;
1571 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1572 :
P(parser), Dcl(D), HasCFunction(
false) {
1573 P.CurParsedObjCImpl =
this;
1576 ~ObjCImplParsingDataRAII();
1579 bool isFinished()
const {
return Finished; }
1584 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1585 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1587 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
1589 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1597 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1598 objc_nonnull, objc_nullable, objc_null_unspecified,
1603 bool isTokIdentifier_in()
const;
1607 void ParseObjCMethodRequirement();
1608 Decl *ParseObjCMethodPrototype(
1610 bool MethodDefinition =
true);
1613 bool MethodDefinition=
true);
1616 Decl *ParseObjCMethodDefinition();
1639 unsigned &NumLineToksConsumed,
1640 bool IsUnevaluated);
1649 ExprResult ParseCastExpression(
bool isUnaryExpression,
1650 bool isAddressOfOperand,
1653 bool isVectorLiteral =
false);
1654 ExprResult ParseCastExpression(
bool isUnaryExpression,
1655 bool isAddressOfOperand =
false,
1657 bool isVectorLiteral =
false);
1660 bool isNotExpressionStart();
1664 bool isPostfixExpressionSuffixStart() {
1666 return (K == tok::l_square || K == tok::l_paren ||
1667 K == tok::period || K == tok::arrow ||
1668 K == tok::plusplus || K == tok::minusminus);
1672 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1674 const Token &OpToken);
1675 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1676 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1677 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1682 ExprResult ParseUnaryExprOrTypeTraitExpression();
1696 llvm::function_ref<
void()> ExpressionStarts =
1697 llvm::function_ref<
void()>());
1706 enum ParenParseOption {
1713 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1714 bool stopIfCastExpr,
1720 ParenParseOption &ExprType,
ParsedType &CastTy,
1726 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1728 ExprResult ParseGenericSelectionExpression();
1737 Token &Replacement);
1738 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1740 bool areTokensAdjacent(
const Token &A,
const Token &B);
1742 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1748 bool EnteringContext,
1749 bool *MayBePseudoDestructor =
nullptr,
1750 bool IsTypename =
false,
1752 bool OnlyNamespace =
false);
1758 enum class LambdaIntroducerTentativeParse {
1776 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1826 bool MayBeFollowedByDirectInit);
1839 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1841 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1847 void ParseDirectNewDeclarator(Declarator &D);
1849 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1854 struct ForRangeInfo;
1858 ForRangeInfo *FRI =
nullptr);
1873 if (Tok.
isNot(tok::l_brace))
1875 return ParseBraceInitializer();
1877 bool MayBeDesignationStart();
1879 ExprResult ParseInitializerWithPotentialDesignator();
1899 bool isSimpleObjCMessageExpression();
1904 Expr *ReceiverExpr);
1905 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1908 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1923 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
1925 StmtVector &Stmts, ParsedStmtContext StmtCtx,
1927 StmtResult ParseStatementOrDeclarationAfterAttributes(
1929 ParsedStmtContext StmtCtx,
1931 ParsedAttributesWithRange &Attrs);
1932 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
1933 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs,
1934 ParsedStmtContext StmtCtx);
1935 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
1936 bool MissingCase =
false,
1938 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
1939 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
1940 StmtResult ParseCompoundStatement(
bool isStmtExpr,
1941 unsigned ScopeFlags);
1942 void ParseCompoundStatementLeadingPragmas();
1943 bool ConsumeNullStmt(StmtVector &Stmts);
1944 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
1945 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
1960 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
1961 ParsedStmtContext StmtCtx,
1963 ParsedAttributesWithRange &Attrs);
1967 enum IfExistsBehavior {
1979 struct IfExistsCondition {
1994 IfExistsBehavior Behavior;
1997 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
1998 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
1999 void ParseMicrosoftIfExistsExternalDeclaration();
2003 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2014 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2028 ParsedStmtContext StmtCtx);
2041 enum class DeclSpecContext {
2046 DSC_alias_declaration,
2049 DSC_template_type_arg,
2050 DSC_objc_method_result,
2056 static bool isTypeSpecifier(DeclSpecContext DSC) {
2058 case DeclSpecContext::DSC_normal:
2059 case DeclSpecContext::DSC_template_param:
2060 case DeclSpecContext::DSC_class:
2061 case DeclSpecContext::DSC_top_level:
2062 case DeclSpecContext::DSC_objc_method_result:
2063 case DeclSpecContext::DSC_condition:
2066 case DeclSpecContext::DSC_template_type_arg:
2067 case DeclSpecContext::DSC_type_specifier:
2068 case DeclSpecContext::DSC_trailing:
2069 case DeclSpecContext::DSC_alias_declaration:
2072 llvm_unreachable(
"Missing DeclSpecContext case");
2077 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2079 case DeclSpecContext::DSC_normal:
2080 case DeclSpecContext::DSC_template_param:
2081 case DeclSpecContext::DSC_class:
2082 case DeclSpecContext::DSC_top_level:
2083 case DeclSpecContext::DSC_condition:
2084 case DeclSpecContext::DSC_type_specifier:
2087 case DeclSpecContext::DSC_objc_method_result:
2088 case DeclSpecContext::DSC_template_type_arg:
2089 case DeclSpecContext::DSC_trailing:
2090 case DeclSpecContext::DSC_alias_declaration:
2093 llvm_unreachable(
"Missing DeclSpecContext case");
2098 struct ForRangeInit {
2102 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2104 struct ForRangeInfo : ForRangeInit {
2110 ParsedAttributesWithRange &attrs);
2113 ParsedAttributesWithRange &attrs,
2115 ForRangeInit *FRI =
nullptr);
2119 ForRangeInit *FRI =
nullptr);
2120 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2121 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2122 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2123 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2125 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2126 ForRangeInit *FRI =
nullptr);
2134 bool trySkippingFunctionBody();
2137 const ParsedTemplateInfo &TemplateInfo,
2139 ParsedAttributesWithRange &Attrs);
2142 void ParseDeclarationSpecifiers(
2144 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2146 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2147 LateParsedAttrList *LateAttrs =
nullptr);
2148 bool DiagnoseMissingSemiAfterTagDefinition(
2150 LateParsedAttrList *LateAttrs =
nullptr);
2152 void ParseSpecifierQualifierList(
2154 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2160 const ParsedTemplateInfo &TemplateInfo,
2166 void ParseStructDeclaration(
2170 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2171 bool isTypeSpecifierQualifier();
2176 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2181 bool isKnownToBeDeclarationSpecifier() {
2183 return isCXXDeclarationSpecifier() == TPResult::True;
2184 return isDeclarationSpecifier(
true);
2190 bool isDeclarationStatement() {
2192 return isCXXDeclarationStatement();
2193 return isDeclarationSpecifier(
true);
2200 bool isForInitDeclaration() {
2204 return isCXXSimpleDeclaration(
true);
2205 return isDeclarationSpecifier(
true);
2209 bool isForRangeIdentifier();
2213 bool isStartOfObjCClassMessageMissingOpenBracket();
2218 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2222 enum TentativeCXXTypeIdContext {
2225 TypeIdAsTemplateArgument
2232 bool isTypeIdInParens(
bool &isAmbiguous) {
2234 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2235 isAmbiguous =
false;
2236 return isTypeSpecifierQualifier();
2238 bool isTypeIdInParens() {
2240 return isTypeIdInParens(isAmbiguous);
2246 bool isTypeIdUnambiguously() {
2249 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2250 return isTypeSpecifierQualifier();
2256 bool isCXXDeclarationStatement();
2263 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2272 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2275 enum class ConditionOrInitStatement {
2285 ConditionOrInitStatement
2286 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2287 bool CanBeForRangeDecl);
2289 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2290 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2292 return isCXXTypeId(Context, isAmbiguous);
2297 enum class TPResult {
2298 True, False, Ambiguous, Error
2321 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2322 bool *InvalidAsDeclSpec =
nullptr);
2327 bool isCXXDeclarationSpecifierAType();
2332 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2346 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2347 TPResult TryParseTypeofSpecifier();
2348 TPResult TryParseProtocolQualifiers();
2349 TPResult TryParsePtrOperatorSeq();
2350 TPResult TryParseOperatorId();
2351 TPResult TryParseInitDeclaratorList();
2352 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2353 bool mayHaveDirectInit =
false);
2355 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2356 bool VersusTemplateArg =
false);
2357 TPResult TryParseFunctionDeclarator();
2358 TPResult TryParseBracketDeclarator();
2359 TPResult TryConsumeDeclarationSpecifier();
2366 Decl **OwnedType =
nullptr,
2373 bool standardAttributesAllowed()
const {
2375 return LO.DoubleSquareBracketAttributes;
2380 bool CheckProhibitedCXX11Attribute() {
2381 assert(Tok.
is(tok::l_square));
2382 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2384 return DiagnoseProhibitedCXX11Attribute();
2387 bool DiagnoseProhibitedCXX11Attribute();
2388 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2390 if (!standardAttributesAllowed())
2393 Tok.
isNot(tok::kw_alignas))
2395 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2397 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2400 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2404 void ProhibitAttributes(ParsedAttributesWithRange &Attrs,
2406 if (Attrs.Range.isInvalid())
2408 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2412 void ProhibitAttributes(ParsedAttributesViewWithRange &Attrs,
2414 if (Attrs.Range.isInvalid())
2416 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2417 Attrs.clearListOnly();
2419 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2425 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2435 void DiagnoseAndSkipCXX11Attributes();
2447 void MaybeParseGNUAttributes(Declarator &D,
2448 LateParsedAttrList *LateAttrs =
nullptr) {
2449 if (Tok.
is(tok::kw___attribute)) {
2452 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2458 LateParsedAttrList *LateAttrs =
nullptr) {
2459 if (Tok.
is(tok::kw___attribute))
2460 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2464 LateParsedAttrList *LateAttrs =
nullptr,
2465 Declarator *D =
nullptr);
2479 void MaybeParseCXX11Attributes(Declarator &D) {
2480 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2481 ParsedAttributesWithRange attrs(AttrFactory);
2483 ParseCXX11Attributes(attrs, &endLoc);
2489 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2490 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2491 ParseCXX11Attributes(attrsWithRange, endLoc);
2495 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2497 bool OuterMightBeMessageSend =
false) {
2498 if (standardAttributesAllowed() &&
2499 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2500 ParseCXX11Attributes(attrs, endLoc);
2505 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2520 ParseMicrosoftAttributes(attrs, endLoc);
2528 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2529 ParseMicrosoftDeclSpecs(Attrs,
End);
2537 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2548 return ParseOpenCLUnrollHintAttribute(Attrs);
2556 VersionTuple ParseVersionTuple(
SourceRange &Range);
2568 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2576 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2598 void ParseTypeofSpecifier(
DeclSpec &DS);
2600 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2603 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2604 void ParseAtomicSpecifier(
DeclSpec &DS);
2613 return isCXX11VirtSpecifier(Tok);
2615 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2618 bool isCXX11FinalKeyword()
const;
2623 class DeclaratorScopeObj {
2630 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2632 void EnterDeclaratorScope() {
2633 assert(!EnteredScope &&
"Already entered the scope!");
2634 assert(SS.
isSet() &&
"C++ scope was not set!");
2636 CreatedScope =
true;
2640 EnteredScope =
true;
2643 ~DeclaratorScopeObj() {
2645 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2654 void ParseDeclarator(Declarator &D);
2656 typedef void (
Parser::*DirectDeclParseFunction)(Declarator&);
2657 void ParseDeclaratorInternal(Declarator &D,
2658 DirectDeclParseFunction DirectDeclParser);
2660 enum AttrRequirements {
2661 AR_NoAttributesParsed = 0,
2662 AR_GNUAttributesParsedAndRejected = 1 << 0,
2663 AR_GNUAttributesParsed = 1 << 1,
2664 AR_CXX11AttributesParsed = 1 << 2,
2665 AR_DeclspecAttributesParsed = 1 << 3,
2666 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2667 AR_CXX11AttributesParsed |
2668 AR_DeclspecAttributesParsed,
2669 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2670 AR_DeclspecAttributesParsed
2673 void ParseTypeQualifierListOpt(
2674 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2675 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2677 void ParseDirectDeclarator(Declarator &D);
2678 void ParseDecompositionDeclarator(Declarator &D);
2679 void ParseParenDeclarator(Declarator &D);
2680 void ParseFunctionDeclarator(Declarator &D,
2684 bool RequiresArg =
false);
2685 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2687 bool isFunctionDeclaratorIdentifierList();
2688 void ParseFunctionDeclaratorIdentifierList(
2691 void ParseParameterDeclarationClause(
2696 void ParseBracketDeclarator(Declarator &D);
2697 void ParseMisplacedBracketDeclarator(Declarator &D);
2703 enum CXX11AttributeKind {
2705 CAK_NotAttributeSpecifier,
2707 CAK_AttributeSpecifier,
2710 CAK_InvalidAttributeSpecifier
2713 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2714 bool OuterMightBeMessageSend =
false);
2716 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2722 struct InnerNamespaceInfo {
2735 Decl *ParseExportDeclaration();
2736 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2744 struct UsingDeclarator {
2759 const ParsedTemplateInfo &TemplateInfo,
2763 Decl *ParseAliasDeclarationAfterDeclarator(
2775 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2777 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2779 DeclSpecContext DSC,
2780 ParsedAttributesWithRange &Attributes);
2787 ParsedAttributesWithRange &Attrs,
2792 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
2795 LateParsedAttrList &LateAttrs);
2796 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
2798 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2800 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2802 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2805 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2807 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
2814 void ParseBaseClause(
Decl *ClassDecl);
2822 bool EnteringContext,
2825 bool AssumeTemplateId);
2826 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2833 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2837 DeclGroupPtrTy ParseOMPDeclareTargetClauses();
2842 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2847 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2850 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2866 bool ParseOpenMPSimpleVarList(
2870 bool AllowScopeSpecifier);
2875 ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx);
2945 bool IsMapTypeImplicit =
false;
2954 bool AllowDestructorName,
2955 bool AllowConstructorName,
2956 bool AllowDeductionGuide,
2980 Decl *ParseSingleDeclarationAfterTemplate(
2984 bool ParseTemplateParameters(
unsigned Depth,
2988 bool ParseTemplateParameterList(
unsigned Depth,
2990 bool isStartOfTemplateTypeParameter();
2991 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
2992 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
2993 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
2994 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
2997 bool AlreadyHasEllipsis,
2998 bool IdentifierHasName);
2999 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
3005 bool ConsumeLastToken,
3006 bool ObjCGenericList);
3007 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3009 TemplateArgList &TemplateArgs,
3016 bool AllowTypeAnnotation =
true);
3017 void AnnotateTemplateIdTokenAsType(
bool IsClassName =
false);
3018 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
3029 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3034 DeclGroupPtrTy ParseModuleDecl(
bool IsFirstDecl);
3036 bool parseMisplacedModuleImport();
3037 bool tryParseMisplacedModuleImport() {
3039 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3040 Kind == tok::annot_module_include)
3041 return parseMisplacedModuleImport();
3045 bool ParseModuleName(
3061 void CodeCompleteDirective(
bool InConditional)
override;
3062 void CodeCompleteInConditionalExclusion()
override;
3063 void CodeCompleteMacroName(
bool IsDefinition)
override;
3064 void CodeCompletePreprocessorExpression()
override;
3066 unsigned ArgumentIndex)
override;
3067 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3068 void CodeCompleteNaturalLanguage()
override;
Sema::FullExprArg FullExprArg
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind...
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
ParseScope - Introduces a new scope for parsing.
SourceLocation getEndOfPreviousToken()
void Initialize()
Initialize - Warm up the parser.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Class to handle popping type parameters when leaving the scope.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
NullabilityKind
Describes the nullability of a particular type.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
DeclarationNameInfo ReductionOrMapperId
Decl - This represents one declaration (or definition), e.g.
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)
Represents a variable declaration or definition.
Information about one declarator, including the parsed type information and the identifier.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token...
TypeSpecifierType
Specifies the kind of type.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
Information about a template-id annotation token.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
SourceLocation getAnnotationEndLoc() const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
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.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
OpenMPClauseKind
OpenMP clauses.
void startOpenMPLoop()
If the current region is a loop-based region, mark the start of the loop construct.
Represents a C++ template name within the type system.
Keeps track of expected type during expression parsing.
A class for parsing a field declarator.
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Provides LLVM's BitmaskEnum facility to enumeration types declared in namespace clang.
Preprocessor & getPreprocessor() const
Defines and computes precedence levels for binary/ternary operators.
SmallVector< SourceLocation, OMPMapClause::NumberOfModifiers > MapTypeModifiersLoc
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
This file defines OpenMP AST classes for clauses.
const LangOptions & getLangOpts() const
A class for parsing a DeclSpec.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Represents the parsed form of a C++ template argument.
Encodes a location in the source.
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.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
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.
The name of a declaration.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SkipUntilFlags
Control flags for SkipUntil functions.
Data used for parsing list of variables in OpenMP clauses.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static const TST TST_unspecified
Encapsulates the data about a macro definition (e.g.
CXXScopeSpec ReductionOrMapperIdScopeSpec
const TargetInfo & getTargetInfo() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
bool isSet() const
Deprecated.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
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 parseMapTypeModifiers(OpenMPVarListDataTy &Data)
Parses map-type-modifiers in map clause.
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
bool parseMapperModifier(OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
Contains a late templated function.
Loop optimization hint for loop and unroll pragmas.
AngleBracketTracker::Priority Priority
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Callback handler that receives notifications when performing code completion within the preprocessor...
void * getAnnotationValue() const
static OpaquePtr getFromOpaquePtr(void *P)
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
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.