214 return Actions.incrementMSManglingNumber();
263 assert(!isTokenSpecial() &&
264 "Should consume special tokens with Consume*Token");
265 PrevTokLocation = Tok.getLocation();
267 return PrevTokLocation;
273 assert(!isTokenSpecial() &&
274 "Should consume special tokens with Consume*Token");
275 PrevTokLocation = Tok.getLocation();
283 Loc = PrevTokLocation;
292 return ConsumeParen();
293 if (isTokenBracket())
294 return ConsumeBracket();
296 return ConsumeBrace();
297 if (isTokenStringLiteral())
298 return ConsumeStringToken();
299 if (Tok.is(tok::code_completion))
300 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
301 : handleUnexpectedCodeCompletionToken();
302 if (Tok.isAnnotation())
303 return ConsumeAnnotationToken();
317 if (N == 0 || Tok.is(tok::eof))
319 return PP.LookAhead(N - 1);
328 if (!Tok.getAnnotationValue())
378 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
379 (Tok.is(tok::annot_template_id) &&
381 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
398 ParseScope(
const ParseScope &) =
delete;
399 void operator=(
const ParseScope &) =
delete;
406 bool BeforeCompoundStmt =
false)
408 if (EnteredScope && !BeforeCompoundStmt)
409 Self->EnterScope(ScopeFlags);
411 if (BeforeCompoundStmt)
412 Self->incrementMSManglingNumber();
414 this->Self = nullptr;
432 class MultiParseScope {
434 unsigned NumScopes = 0;
436 MultiParseScope(
const MultiParseScope &) =
delete;
441 Self.EnterScope(ScopeFlags);
483 static_cast<unsigned>(R));
538 unsigned short ParenCount = 0, BracketCount = 0,
BraceCount = 0;
539 unsigned short MisplacedModuleBeginCount = 0;
550 static constexpr int ScopeCacheSize = 16;
551 unsigned NumCachedScopes;
552 Scope *ScopeCache[ScopeCacheSize];
558 *Ident_GetExceptionCode;
561 *Ident_GetExceptionInfo;
563 IdentifierInfo *Ident__abnormal_termination, *Ident___abnormal_termination,
564 *Ident_AbnormalTermination;
573 std::unique_ptr<CommentHandler> CommentSemaHandler;
578 bool CalledSignatureHelp =
false;
586 bool SkipFunctionBodies;
593 bool isTokenParen()
const {
return Tok.isOneOf(tok::l_paren, tok::r_paren); }
595 bool isTokenBracket()
const {
596 return Tok.isOneOf(tok::l_square, tok::r_square);
599 bool isTokenBrace()
const {
return Tok.isOneOf(tok::l_brace, tok::r_brace); }
601 bool isTokenStringLiteral()
const {
605 bool isTokenSpecial()
const {
606 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
607 isTokenBrace() || Tok.is(tok::code_completion) || Tok.isAnnotation();
612 bool isTokenEqualOrEqualTypo();
616 void UnconsumeToken(Token &Consumed) {
618 PP.EnterToken(Consumed,
true);
620 PP.EnterToken(
Next,
true);
623 SourceLocation ConsumeAnnotationToken() {
624 assert(Tok.isAnnotation() &&
"wrong consume method");
625 SourceLocation Loc = Tok.getLocation();
626 PrevTokLocation = Tok.getAnnotationEndLoc();
633 SourceLocation ConsumeParen() {
634 assert(isTokenParen() &&
"wrong consume method");
635 if (Tok.getKind() == tok::l_paren)
637 else if (ParenCount) {
638 AngleBrackets.clear(*
this);
641 PrevTokLocation = Tok.getLocation();
643 return PrevTokLocation;
648 SourceLocation ConsumeBracket() {
649 assert(isTokenBracket() &&
"wrong consume method");
650 if (Tok.getKind() == tok::l_square)
652 else if (BracketCount) {
653 AngleBrackets.clear(*
this);
657 PrevTokLocation = Tok.getLocation();
659 return PrevTokLocation;
664 SourceLocation ConsumeBrace() {
665 assert(isTokenBrace() &&
"wrong consume method");
666 if (Tok.getKind() == tok::l_brace)
668 else if (BraceCount) {
669 AngleBrackets.clear(*
this);
673 PrevTokLocation = Tok.getLocation();
675 return PrevTokLocation;
682 SourceLocation ConsumeStringToken() {
683 assert(isTokenStringLiteral() &&
684 "Should only consume string literals with this method");
685 PrevTokLocation = Tok.getLocation();
687 return PrevTokLocation;
695 SourceLocation ConsumeCodeCompletionToken() {
696 assert(Tok.is(tok::code_completion));
697 PrevTokLocation = Tok.getLocation();
699 return PrevTokLocation;
707 SourceLocation handleUnexpectedCodeCompletionToken();
711 void cutOffParsing() {
712 if (PP.isCodeCompletionEnabled())
713 PP.setCodeCompletionReached();
715 Tok.setKind(tok::eof);
722 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
723 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
724 Kind == tok::annot_repl_input_end;
727 static void setTypeAnnotation(Token &Tok,
TypeResult T) {
728 assert((
T.isInvalid() ||
T.get()) &&
729 "produced a valid-but-null type annotation?");
730 Tok.setAnnotationValue(
T.isInvalid() ?
nullptr :
T.get().getAsOpaquePtr());
733 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
734 return static_cast<NamedDecl *
>(Tok.getAnnotationValue());
737 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
738 Tok.setAnnotationValue(ND);
741 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
742 return static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
745 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
746 Tok.setAnnotationValue(ND);
751 static ExprResult getExprAnnotation(
const Token &Tok) {
752 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
757 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
758 Tok.setAnnotationValue(ER.getAsOpaquePointer());
772 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
777 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
784 bool TryKeywordIdentFallback(
bool DisableKeyword);
789 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
800 unsigned Diag = diag::err_expected,
801 StringRef DiagMsg =
"");
808 bool ExpectAndConsumeSemi(
unsigned DiagID, StringRef TokenUsed =
"");
819 bool expectIdentifier();
822 enum class CompoundToken {
837 void checkCompoundToken(SourceLocation FirstTokLoc,
840 void diagnoseUseOfC11Keyword(
const Token &Tok);
843 class ParseScopeFlags {
845 unsigned OldFlags = 0;
846 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
847 void operator=(
const ParseScopeFlags &) =
delete;
852 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
866 void SuggestParentheses(SourceLocation Loc,
unsigned DK,
867 SourceRange ParenRange);
903 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
904 ParsedAttributes &DeclSpecAttrs,
905 ParsingDeclSpec *DS =
nullptr);
909 bool isDeclarationAfterDeclarator();
913 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
916 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
937 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
938 ParsedAttributes &DeclSpecAttrs,
942 void SkipFunctionBody();
944 struct ParsedTemplateInfo;
945 class LateParsedAttrList;
963 Decl *ParseFunctionDefinition(
964 ParsingDeclarator &D,
965 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
966 LateParsedAttrList *LateParsedAttrs =
nullptr);
970 void ParseKNRParamDeclarations(Declarator &D);
980 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
993 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
997 struct IfExistsCondition {
999 SourceLocation KeywordLoc;
1015 bool ParseMicrosoftIfExistsCondition(IfExistsCondition &
Result);
1016 void ParseMicrosoftIfExistsExternalDeclaration();
1055 Decl *ParseModuleImport(SourceLocation AtLoc,
1062 bool parseMisplacedModuleImport();
1064 bool tryParseMisplacedModuleImport() {
1066 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
1067 Kind == tok::annot_module_include)
1068 return parseMisplacedModuleImport();
1081 bool ParseModuleName(SourceLocation UseLoc,
1082 SmallVectorImpl<IdentifierLoc> &Path,
bool IsImport);
1086 void CodeCompleteDirective(
bool InConditional)
override;
1088 void CodeCompleteMacroName(
bool IsDefinition)
override;
1090 void CodeCompleteMacroArgument(IdentifierInfo *
Macro, MacroInfo *MacroInfo,
1091 unsigned ArgumentIndex)
override;
1092 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
1108 struct ParsingClass;
1118 class LateParsedDeclaration {
1120 virtual ~LateParsedDeclaration();
1122 virtual void ParseLexedMethodDeclarations();
1123 virtual void ParseLexedMemberInitializers();
1124 virtual void ParseLexedMethodDefs();
1125 virtual void ParseLexedAttributes();
1126 virtual void ParseLexedPragmas();
1131 class LateParsedClass :
public LateParsedDeclaration {
1133 LateParsedClass(
Parser *P, ParsingClass *
C);
1134 ~LateParsedClass()
override;
1136 void ParseLexedMethodDeclarations()
override;
1137 void ParseLexedMemberInitializers()
override;
1138 void ParseLexedMethodDefs()
override;
1139 void ParseLexedAttributes()
override;
1140 void ParseLexedPragmas()
override;
1143 LateParsedClass(
const LateParsedClass &) =
delete;
1144 LateParsedClass &operator=(
const LateParsedClass &) =
delete;
1148 ParsingClass *Class;
1157 struct LateParsedAttribute :
public LateParsedDeclaration {
1160 IdentifierInfo &AttrName;
1161 IdentifierInfo *MacroII =
nullptr;
1162 SourceLocation AttrNameLoc;
1163 SmallVector<Decl *, 2> Decls;
1165 explicit LateParsedAttribute(
Parser *P, IdentifierInfo &Name,
1167 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1169 void ParseLexedAttributes()
override;
1171 void addDecl(Decl *D) { Decls.push_back(D); }
1178 class LateParsedPragma :
public LateParsedDeclaration {
1185 : Self(P), AS(AS) {}
1187 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1191 void ParseLexedPragmas()
override;
1195 class LateParsedAttrList :
public SmallVector<LateParsedAttribute *, 2> {
1197 LateParsedAttrList(
bool PSoon =
false,
1198 bool LateAttrParseExperimentalExtOnly =
false)
1200 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1202 bool parseSoon() {
return ParseSoon; }
1205 bool lateAttrParseExperimentalExtOnly() {
1206 return LateAttrParseExperimentalExtOnly;
1211 bool LateAttrParseExperimentalExtOnly;
1217 struct LexedMethod :
public LateParsedDeclaration {
1222 explicit LexedMethod(
Parser *P, Decl *MD) : Self(P), D(MD) {}
1224 void ParseLexedMethodDefs()
override;
1231 struct LateParsedDefaultArgument {
1232 explicit LateParsedDefaultArgument(
1233 Decl *P, std::unique_ptr<CachedTokens> Toks =
nullptr)
1234 : Param(P), Toks(std::move(Toks)) {}
1243 std::unique_ptr<CachedTokens> Toks;
1250 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1251 explicit LateParsedMethodDeclaration(
Parser *P, Decl *M)
1252 : Self(P), Method(M), ExceptionSpecTokens(
nullptr) {}
1254 void ParseLexedMethodDeclarations()
override;
1266 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1276 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1277 LateParsedMemberInitializer(
Parser *P, Decl *FD) : Self(P), Field(FD) {}
1279 void ParseLexedMemberInitializers()
override;
1297 typedef SmallVector<LateParsedDeclaration *, 2>
1298 LateParsedDeclarationsContainer;
1312 const ParsedAttributesView &AccessAttrs,
1313 ParsingDeclarator &D,
1314 const ParsedTemplateInfo &TemplateInfo,
1315 const VirtSpecifiers &VS,
1316 SourceLocation PureSpecLoc);
1319 StringLiteral *ParseCXXDeletedFunctionMessage();
1324 void SkipDeletedFunctionBody();
1330 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1334 void ParseLexedAttributes(ParsingClass &
Class);
1337 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1345 void ParseLexedAttribute(LateParsedAttribute &LA,
bool EnterScope,
1352 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1353 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1358 void ParseLexedMethodDefs(ParsingClass &
Class);
1359 void ParseLexedMethodDef(LexedMethod &LM);
1365 void ParseLexedMemberInitializers(ParsingClass &
Class);
1366 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1400 ParsedAttributes *Attrs =
nullptr);
1406 IdentifierInfo *Ident_vector;
1407 IdentifierInfo *Ident_bool;
1408 IdentifierInfo *Ident_Bool;
1412 IdentifierInfo *Ident_pixel;
1415 IdentifierInfo *Ident_introduced;
1418 IdentifierInfo *Ident_deprecated;
1421 IdentifierInfo *Ident_obsoleted;
1424 IdentifierInfo *Ident_unavailable;
1427 IdentifierInfo *Ident_message;
1430 IdentifierInfo *Ident_strict;
1433 IdentifierInfo *Ident_replacement;
1436 IdentifierInfo *Ident_environment;
1439 IdentifierInfo *Ident_language, *Ident_defined_in,
1440 *Ident_generated_declaration, *Ident_USR;
1443 AttributeFactory AttrFactory;
1448 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
const char *&PrevSpec,
1453 if (Tok.getIdentifierInfo() != Ident_vector &&
1454 Tok.getIdentifierInfo() != Ident_bool &&
1455 Tok.getIdentifierInfo() != Ident_Bool &&
1456 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
1459 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
1465 bool TryAltiVecVectorToken() {
1467 Tok.getIdentifierInfo() != Ident_vector)
1469 return TryAltiVecVectorTokenOutOfLine();
1474 bool TryAltiVecVectorTokenOutOfLine();
1475 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
1476 const char *&PrevSpec,
unsigned &DiagID,
1479 void ParseLexedCAttributeList(LateParsedAttrList &LA,
bool EnterScope,
1480 ParsedAttributes *OutAttrs =
nullptr);
1487 void ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
1488 ParsedAttributes *OutAttrs =
nullptr);
1490 void ParseLexedPragmas(ParsingClass &
Class);
1491 void ParseLexedPragma(LateParsedPragma &LP);
1499 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1515 bool ConsumeFinalToken =
true) {
1516 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1527 bool ConsumeFinalToken =
true);
1535 enum class DeclSpecContext {
1540 DSC_alias_declaration,
1545 DSC_template_type_arg,
1546 DSC_objc_method_result,
1555 static bool isTypeSpecifier(DeclSpecContext DSC) {
1557 case DeclSpecContext::DSC_normal:
1558 case DeclSpecContext::DSC_template_param:
1559 case DeclSpecContext::DSC_template_arg:
1560 case DeclSpecContext::DSC_class:
1561 case DeclSpecContext::DSC_top_level:
1562 case DeclSpecContext::DSC_objc_method_result:
1563 case DeclSpecContext::DSC_condition:
1566 case DeclSpecContext::DSC_template_type_arg:
1567 case DeclSpecContext::DSC_type_specifier:
1568 case DeclSpecContext::DSC_conv_operator:
1569 case DeclSpecContext::DSC_trailing:
1570 case DeclSpecContext::DSC_alias_declaration:
1571 case DeclSpecContext::DSC_association:
1572 case DeclSpecContext::DSC_new:
1575 llvm_unreachable(
"Missing DeclSpecContext case");
1579 enum class AllowDefiningTypeSpec {
1596 static AllowDefiningTypeSpec
1597 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
1599 case DeclSpecContext::DSC_normal:
1600 case DeclSpecContext::DSC_class:
1601 case DeclSpecContext::DSC_top_level:
1602 case DeclSpecContext::DSC_alias_declaration:
1603 case DeclSpecContext::DSC_objc_method_result:
1604 return AllowDefiningTypeSpec::Yes;
1606 case DeclSpecContext::DSC_condition:
1607 case DeclSpecContext::DSC_template_param:
1608 return AllowDefiningTypeSpec::YesButInvalid;
1610 case DeclSpecContext::DSC_template_type_arg:
1611 case DeclSpecContext::DSC_type_specifier:
1612 return AllowDefiningTypeSpec::NoButErrorRecovery;
1614 case DeclSpecContext::DSC_association:
1615 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
1616 : AllowDefiningTypeSpec::Yes;
1618 case DeclSpecContext::DSC_trailing:
1619 case DeclSpecContext::DSC_conv_operator:
1620 case DeclSpecContext::DSC_template_arg:
1621 case DeclSpecContext::DSC_new:
1622 return AllowDefiningTypeSpec::No;
1624 llvm_unreachable(
"Missing DeclSpecContext case");
1628 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
1630 case DeclSpecContext::DSC_normal:
1631 case DeclSpecContext::DSC_class:
1632 case DeclSpecContext::DSC_top_level:
1635 case DeclSpecContext::DSC_alias_declaration:
1636 case DeclSpecContext::DSC_objc_method_result:
1637 case DeclSpecContext::DSC_condition:
1638 case DeclSpecContext::DSC_template_param:
1639 case DeclSpecContext::DSC_template_type_arg:
1640 case DeclSpecContext::DSC_type_specifier:
1641 case DeclSpecContext::DSC_trailing:
1642 case DeclSpecContext::DSC_association:
1643 case DeclSpecContext::DSC_conv_operator:
1644 case DeclSpecContext::DSC_template_arg:
1645 case DeclSpecContext::DSC_new:
1649 llvm_unreachable(
"Missing DeclSpecContext case");
1654 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
1656 case DeclSpecContext::DSC_normal:
1657 case DeclSpecContext::DSC_template_param:
1658 case DeclSpecContext::DSC_template_arg:
1659 case DeclSpecContext::DSC_class:
1660 case DeclSpecContext::DSC_top_level:
1661 case DeclSpecContext::DSC_condition:
1662 case DeclSpecContext::DSC_type_specifier:
1663 case DeclSpecContext::DSC_association:
1664 case DeclSpecContext::DSC_conv_operator:
1665 case DeclSpecContext::DSC_new:
1668 case DeclSpecContext::DSC_objc_method_result:
1669 case DeclSpecContext::DSC_template_type_arg:
1670 case DeclSpecContext::DSC_trailing:
1671 case DeclSpecContext::DSC_alias_declaration:
1674 llvm_unreachable(
"Missing DeclSpecContext case");
1679 getImplicitTypenameContext(DeclSpecContext DSC) {
1681 case DeclSpecContext::DSC_class:
1682 case DeclSpecContext::DSC_top_level:
1683 case DeclSpecContext::DSC_type_specifier:
1684 case DeclSpecContext::DSC_template_type_arg:
1685 case DeclSpecContext::DSC_trailing:
1686 case DeclSpecContext::DSC_alias_declaration:
1687 case DeclSpecContext::DSC_template_param:
1688 case DeclSpecContext::DSC_new:
1691 case DeclSpecContext::DSC_normal:
1692 case DeclSpecContext::DSC_objc_method_result:
1693 case DeclSpecContext::DSC_condition:
1694 case DeclSpecContext::DSC_template_arg:
1695 case DeclSpecContext::DSC_conv_operator:
1696 case DeclSpecContext::DSC_association:
1699 llvm_unreachable(
"Missing DeclSpecContext case");
1704 struct ForRangeInit {
1705 SourceLocation ColonLoc;
1707 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
1708 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
1710 struct ForRangeInfo : ForRangeInit {
1733 SourceLocation &DeclEnd,
1734 ParsedAttributes &DeclAttrs,
1735 ParsedAttributes &DeclSpecAttrs,
1736 SourceLocation *DeclSpecStart =
nullptr);
1763 ParsedAttributes &DeclAttrs,
1764 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
1765 ForRangeInit *FRI =
nullptr,
1766 SourceLocation *DeclSpecStart =
nullptr);
1776 ParsedAttributes &Attrs,
1777 ParsedTemplateInfo &TemplateInfo,
1778 SourceLocation *DeclEnd =
nullptr,
1779 ForRangeInit *FRI =
nullptr);
1805 Decl *ParseDeclarationAfterDeclarator(
1807 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1811 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
1812 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
1814 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1815 ForRangeInit *FRI =
nullptr);
1826 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
1828 DeclSpecContext DSC, ParsedAttributes &Attrs);
1838 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1840 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
1841 LateParsedAttrList *LateAttrs =
nullptr) {
1842 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
1843 getImplicitTypenameContext(DSC));
1876 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1878 LateParsedAttrList *LateAttrs,
1888 bool DiagnoseMissingSemiAfterTagDefinition(
1890 LateParsedAttrList *LateAttrs =
nullptr);
1892 void ParseSpecifierQualifierList(
1894 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
1895 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
1906 void ParseSpecifierQualifierList(
1909 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
1943 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
1944 const ParsedTemplateInfo &TemplateInfo,
1959 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
1960 SkipBodyInfo *SkipBody =
nullptr);
1974 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
1975 RecordDecl *TagDecl);
2000 void ParseStructDeclaration(
2001 ParsingDeclSpec &DS,
2002 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2003 LateParsedAttrList *LateFieldAttrs =
nullptr);
2015 bool DisambiguatingWithExpression =
false);
2019 bool isTypeSpecifierQualifier();
2024 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2029 bool isConstructorDeclarator(
2032 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2036 void DiagnoseBitIntUse(
const Token &Tok);
2040 bool CheckProhibitedCXX11Attribute() {
2041 assert(Tok.is(tok::l_square));
2044 return DiagnoseProhibitedCXX11Attribute();
2055 bool DiagnoseProhibitedCXX11Attribute();
2057 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2058 SourceLocation CorrectLocation) {
2059 if (!Tok.isRegularKeywordAttribute() &&
2060 (Tok.isNot(tok::l_square) ||
NextToken().
isNot(tok::l_square)) &&
2061 Tok.isNot(tok::kw_alignas))
2063 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2070 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2071 SourceLocation CorrectLocation);
2081 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2085 void ProhibitAttributes(ParsedAttributes &Attrs,
2086 SourceLocation FixItLoc = SourceLocation()) {
2087 if (Attrs.Range.isInvalid())
2089 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2093 void ProhibitAttributes(ParsedAttributesView &Attrs,
2094 SourceLocation FixItLoc = SourceLocation()) {
2095 if (Attrs.Range.isInvalid())
2097 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2098 Attrs.clearListOnly();
2100 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2101 SourceLocation FixItLoc);
2109 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2110 unsigned KeywordDiagId,
2111 bool DiagnoseEmptyAttrs =
false,
2112 bool WarnOnUnknownAttrs =
false);
2116 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2118 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2121 ParseAttributeArgumentList(
const clang::IdentifierInfo &AttrName,
2122 SmallVectorImpl<Expr *> &Exprs,
2123 ParsedAttributeArgumentsProperties ArgsProperties);
2130 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2131 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2132 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2133 ParsedAttr::Form Form);
2135 enum ParseAttrKindMask {
2137 PAKM_Declspec = 1 << 1,
2138 PAKM_CXX11 = 1 << 2,
2157 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2158 LateParsedAttrList *LateAttrs =
nullptr);
2161 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2162 LateParsedAttrList *LateAttrs =
nullptr) {
2163 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2164 isAllowedCXX11AttributeSpecifier()) {
2165 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2171 void MaybeParseGNUAttributes(Declarator &D,
2172 LateParsedAttrList *LateAttrs =
nullptr) {
2173 if (Tok.is(tok::kw___attribute)) {
2174 ParsedAttributes Attrs(AttrFactory);
2175 ParseGNUAttributes(Attrs, LateAttrs, &D);
2176 D.takeAttributesAppending(Attrs);
2180 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2181 LateParsedAttrList *LateAttrs =
nullptr) {
2182 if (Tok.is(tok::kw___attribute)) {
2183 ParseGNUAttributes(Attrs, LateAttrs);
2205 bool ParseSingleGNUAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc,
2206 LateParsedAttrList *LateAttrs =
nullptr,
2207 Declarator *D =
nullptr);
2252 void ParseGNUAttributes(ParsedAttributes &Attrs,
2253 LateParsedAttrList *LateAttrs =
nullptr,
2254 Declarator *D =
nullptr);
2258 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2259 SourceLocation AttrNameLoc,
2260 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2261 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2262 ParsedAttr::Form Form, Declarator *D);
2263 IdentifierLoc *ParseIdentifierLoc();
2266 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2267 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2268 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2269 ParsedAttr::Form Form);
2271 void MaybeParseCXX11Attributes(Declarator &D) {
2272 if (isAllowedCXX11AttributeSpecifier()) {
2273 ParsedAttributes Attrs(AttrFactory);
2274 ParseCXX11Attributes(Attrs);
2275 D.takeAttributesAppending(Attrs);
2279 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2280 bool OuterMightBeMessageSend =
false) {
2281 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2282 ParseCXX11Attributes(Attrs);
2288 bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2289 bool AttrsParsed =
false;
2291 Tok.is(tok::l_square)) {
2292 ParsedAttributes AttrsWithRange(AttrFactory);
2293 ParseMicrosoftAttributes(AttrsWithRange);
2294 AttrsParsed = !AttrsWithRange.empty();
2295 Attrs.takeAllAppendingFrom(AttrsWithRange);
2299 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
2300 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
2301 ParseMicrosoftDeclSpecs(Attrs);
2315 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
2316 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
2317 SourceLocation AttrNameLoc,
2318 ParsedAttributes &Attrs);
2319 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
2320 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
2321 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2322 SourceLocation SkipExtendedMicrosoftTypeAttributes();
2324 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
2325 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
2326 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
2327 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
2328 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
2329 bool isHLSLQualifier(
const Token &Tok)
const;
2330 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
2342 VersionTuple ParseVersionTuple(SourceRange &Range);
2371 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
2372 SourceLocation AvailabilityLoc,
2373 ParsedAttributes &attrs,
2374 SourceLocation *endLoc,
2375 IdentifierInfo *ScopeName,
2376 SourceLocation ScopeLoc,
2377 ParsedAttr::Form Form);
2395 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
2397 ParsedAttributes &Attrs,
2398 SourceLocation *EndLoc,
2399 IdentifierInfo *ScopeName,
2400 SourceLocation ScopeLoc,
2401 ParsedAttr::Form Form);
2416 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
2417 SourceLocation ObjCBridgeRelatedLoc,
2418 ParsedAttributes &Attrs,
2419 SourceLocation *EndLoc,
2420 IdentifierInfo *ScopeName,
2421 SourceLocation ScopeLoc,
2422 ParsedAttr::Form Form);
2424 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
2425 SourceLocation AttrNameLoc,
2426 ParsedAttributes &Attrs,
2427 SourceLocation *EndLoc,
2428 IdentifierInfo *ScopeName,
2429 SourceLocation ScopeLoc,
2430 ParsedAttr::Form Form);
2432 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
2433 SourceLocation AttrNameLoc,
2434 ParsedAttributes &Attrs,
2435 SourceLocation *EndLoc,
2436 IdentifierInfo *ScopeName,
2437 SourceLocation ScopeLoc,
2438 ParsedAttr::Form Form);
2440 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
2441 SourceLocation AttrNameLoc,
2442 ParsedAttributes &Attrs,
2443 IdentifierInfo *ScopeName,
2444 SourceLocation ScopeLoc,
2445 ParsedAttr::Form Form);
2447 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
2453 void ParseBoundsAttribute(IdentifierInfo &AttrName,
2454 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
2455 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2456 ParsedAttr::Form Form);
2472 void ParseTypeofSpecifier(DeclSpec &DS);
2479 void ParseAtomicSpecifier(DeclSpec &DS);
2489 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
2490 SourceLocation &EllipsisLoc,
bool &IsType,
2503 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
2504 SourceLocation *endLoc =
nullptr);
2513 void ParsePtrauthQualifier(ParsedAttributes &Attrs);
2518 class DeclaratorScopeObj {
2525 DeclaratorScopeObj(
Parser &p, CXXScopeSpec &ss)
2526 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2528 void EnterDeclaratorScope() {
2529 assert(!EnteredScope &&
"Already entered the scope!");
2530 assert(SS.isSet() &&
"C++ scope was not set!");
2532 CreatedScope =
true;
2535 if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS))
2536 EnteredScope =
true;
2539 ~DeclaratorScopeObj() {
2541 assert(SS.isSet() &&
"C++ scope was cleared ?");
2542 P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS);
2550 void ParseDeclarator(Declarator &D);
2581 void ParseDeclaratorInternal(Declarator &D,
2582 DirectDeclParseFunction DirectDeclParser);
2584 enum AttrRequirements {
2585 AR_NoAttributesParsed = 0,
2586 AR_GNUAttributesParsedAndRejected = 1 << 0,
2587 AR_GNUAttributesParsed = 1 << 1,
2588 AR_CXX11AttributesParsed = 1 << 2,
2589 AR_DeclspecAttributesParsed = 1 << 3,
2590 AR_AllAttributesParsed = AR_GNUAttributesParsed | AR_CXX11AttributesParsed |
2591 AR_DeclspecAttributesParsed,
2592 AR_VendorAttributesParsed =
2593 AR_GNUAttributesParsed | AR_DeclspecAttributesParsed
2610 void ParseTypeQualifierListOpt(
2611 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2612 bool AtomicOrPtrauthAllowed =
true,
bool IdentifierRequired =
false,
2613 llvm::function_ref<
void()> CodeCompletionHandler = {});
2663 void ParseDirectDeclarator(Declarator &D);
2664 void ParseDecompositionDeclarator(Declarator &D);
2682 void ParseParenDeclarator(Declarator &D);
2707 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
2709 bool IsAmbiguous,
bool RequiresArg =
false);
2710 void InitCXXThisScopeForDeclaratorIfRelevant(
2711 const Declarator &D,
const DeclSpec &DS,
2712 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
2716 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2717 SourceLocation &RefQualifierLoc);
2724 bool isFunctionDeclaratorIdentifierList();
2738 void ParseFunctionDeclaratorIdentifierList(
2739 Declarator &D, SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
2740 void ParseParameterDeclarationClause(
2741 Declarator &D, ParsedAttributes &attrs,
2742 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2743 SourceLocation &EllipsisLoc) {
2744 return ParseParameterDeclarationClause(
2745 D.getContext(), attrs, ParamInfo, EllipsisLoc,
2746 D.getCXXScopeSpec().isSet() &&
2747 D.isFunctionDeclaratorAFunctionDeclaration());
2785 void ParseParameterDeclarationClause(
2787 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2788 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
2799 void ParseBracketDeclarator(Declarator &D);
2802 void ParseMisplacedBracketDeclarator(Declarator &D);
2813 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
2814 SourceLocation IncludeLoc);
2830 mutable IdentifierInfo *Ident_sealed;
2831 mutable IdentifierInfo *Ident_abstract;
2834 mutable IdentifierInfo *Ident_final;
2835 mutable IdentifierInfo *Ident_GNU_final;
2836 mutable IdentifierInfo *Ident_override;
2837 mutable IdentifierInfo *Ident_trivially_relocatable_if_eligible;
2842 struct ParsingClass {
2843 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
2844 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
2845 TagOrTemplate(TagOrTemplate) {}
2849 bool TopLevelClass : 1;
2852 bool IsInterface : 1;
2855 Decl *TagOrTemplate;
2860 LateParsedDeclarationsContainer LateParsedDeclarations;
2866 std::stack<ParsingClass *> ClassStack;
2868 ParsingClass &getCurrentClass() {
2869 assert(!ClassStack.empty() &&
"No lexed method stacks!");
2870 return *ClassStack.top();
2874 class ParsingClassDefinition {
2880 ParsingClassDefinition(
Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
2882 : P(P), Popped(
false),
2883 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
2888 assert(!Popped &&
"Nested class has already been popped");
2890 P.PopParsingClass(State);
2893 ~ParsingClassDefinition() {
2895 P.PopParsingClass(State);
2911 bool Delayed, SourceRange &SpecificationRange,
2912 SmallVectorImpl<ParsedType> &DynamicExceptions,
2913 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2931 ParseDynamicExceptionSpecification(SourceRange &SpecificationRange,
2932 SmallVectorImpl<ParsedType> &Exceptions,
2933 SmallVectorImpl<SourceRange> &Ranges);
2940 TypeResult ParseTrailingReturnType(SourceRange &Range,
2941 bool MayBeFollowedByDirectInit);
2944 void ParseTrailingRequiresClause(Declarator &D);
2946 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2947 ParsedAttributes &AccessAttrs,
2950 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2951 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2952 SourceLocation StartLoc,
2953 SourceLocation EndLoc);
2960 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2961 bool OuterMightBeMessageSend =
false) {
2962 return (Tok.isRegularKeywordAttribute() ||
2963 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend) !=
2970 SourceLocation SkipCXX11Attributes();
2974 void DiagnoseAndSkipCXX11Attributes();
2976 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3005 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3007 SourceLocation *EndLoc =
nullptr);
3008 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3009 SourceLocation *EndLoc =
nullptr) {
3011 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3012 ReplayOpenMPAttributeTokens(OpenMPTokens);
3021 void ParseCXX11Attributes(ParsedAttributes &attrs);
3041 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3042 SourceLocation AttrNameLoc,
3043 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3044 IdentifierInfo *ScopeName,
3045 SourceLocation ScopeLoc,
3051 ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
3052 SourceLocation AttrNameLoc,
3053 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3054 SourceLocation *EndLoc, ParsedAttr::Form Form);
3065 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3066 SourceLocation &Loc,
3069 const IdentifierInfo *EnclosingScope =
nullptr);
3072 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3084 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3086 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3087 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3096 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3097 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3098 SourceLocation StartLoc,
3099 SourceLocation EndLoc);
3112 return isCXX11VirtSpecifier(Tok);
3122 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3123 SourceLocation FriendLoc);
3127 bool isCXX11FinalKeyword()
const;
3133 bool isClassCompatibleKeyword()
const;
3135 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3138 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3170 SourceLocation &DeclEnd,
3171 SourceLocation InlineLoc = SourceLocation());
3173 struct InnerNamespaceInfo {
3174 SourceLocation NamespaceLoc;
3175 SourceLocation InlineLoc;
3176 SourceLocation IdentLoc;
3177 IdentifierInfo *Ident;
3179 using InnerNamespaceInfoList = llvm::SmallVector<InnerNamespaceInfo, 4>;
3182 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3183 unsigned int index, SourceLocation &InlineLoc,
3184 ParsedAttributes &attrs,
3216 Decl *ParseExportDeclaration();
3222 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3237 SourceLocation &DeclEnd, ParsedAttributes &attrs);
3239 struct UsingDeclarator {
3240 SourceLocation TypenameLoc;
3243 SourceLocation EllipsisLoc;
3246 TypenameLoc = EllipsisLoc = SourceLocation();
3287 const ParsedTemplateInfo &TemplateInfo,
3288 SourceLocation UsingLoc,
3289 SourceLocation &DeclEnd,
3290 ParsedAttributes &Attrs,
3292 Decl *ParseAliasDeclarationAfterDeclarator(
3293 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3295 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3308 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3313 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3314 SourceLocation AliasLoc, IdentifierInfo *Alias,
3315 SourceLocation &DeclEnd);
3323 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3367 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3368 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3370 DeclSpecContext DSC, ParsedAttributes &Attributes);
3371 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3372 SourceLocation AttrFixitLoc,
unsigned TagType,
3383 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3384 SourceLocation AttrFixitLoc,
3385 ParsedAttributes &Attrs,
unsigned TagType,
3410 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3411 SourceLocation &EqualLoc);
3415 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3418 LateParsedAttrList &LateAttrs);
3423 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3424 VirtSpecifiers &VS);
3480 ParsedTemplateInfo &TemplateInfo,
3481 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3484 ParsedAttributes &AccessAttrs,
3510 void ParseConstructorInitializer(Decl *ConstructorDecl);
3532 void HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
3560 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3561 SourceLocation &EndLocation);
3573 void ParseBaseClause(Decl *ClassDecl);
3588 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3601 bool isCXX2CTriviallyRelocatableKeyword(Token Tok)
const;
3602 bool isCXX2CTriviallyRelocatableKeyword()
const;
3603 void ParseCXX2CTriviallyRelocatableSpecifier(SourceLocation &TRS);
3608 bool isClassCompatibleKeyword(Token Tok)
const;
3610 void ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs);
3785 bool GreaterThanIsOperator;
3789 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
3808 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
3812 void DeallocateParsedClasses(ParsingClass *
Class);
4030 bool isAddressOfOperand,
bool &NotCastExpr,
4032 bool isVectorLiteral =
false,
4033 bool *NotPrimaryExpression =
nullptr);
4035 bool isAddressOfOperand =
false,
4038 bool isVectorLiteral =
false,
4039 bool *NotPrimaryExpression =
nullptr);
4042 bool isNotExpressionStart();
4046 bool isPostfixExpressionSuffixStart() {
4048 return (K == tok::l_square || K == tok::l_paren || K == tok::period ||
4049 K == tok::arrow || K == tok::plusplus || K == tok::minusminus);
4091 ExprResult ParseUnaryExprOrTypeTraitExpression();
4120 ExprResult ParseSYCLUniqueStableNameExpression();
4182 llvm::function_ref<
void()> ExpressionStarts =
4183 llvm::function_ref<
void()>(),
4184 bool FailImmediatelyOnInvalidExpr =
false);
4229 bool StopIfCastExpr,
4266 ExprResult ParseGenericSelectionExpression();
4285 void injectEmbedTokens();
4311 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
4313 Expr *ReceiverExpr);
4318 bool isKnownToBeDeclarationSpecifier() {
4332 bool isTypeIdForGenericSelection() {
4338 return isTypeSpecifierQualifier();
4344 bool isTypeIdUnambiguously() {
4349 return isTypeSpecifierQualifier();
4358 void ParseBlockId(SourceLocation CaretLoc);
4367 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
4368 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
4374 bool tryParseOpenMPArrayShapingCastPart();
4376 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
4429 bool ObjectHadErrors,
bool EnteringContext,
4430 bool AllowDestructorName,
bool AllowConstructorName,
4431 bool AllowDeductionGuide,
4432 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
4450 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
4451 Token &Replacement);
4502 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
4505 bool areTokensAdjacent(
const Token &A,
const Token &B);
4509 void CheckForTemplateAndDigraph(Token &
Next,
ParsedType ObjectTypePtr,
4510 bool EnteringContext, IdentifierInfo &II,
4565 bool ParseOptionalCXXScopeSpecifier(
4566 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
4567 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
4568 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
4569 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
4570 bool Disambiguation =
false);
4576 enum class LambdaIntroducerTentativeParse {
4654 ParseLambdaIntroducer(LambdaIntroducer &Intro,
4655 LambdaIntroducerTentativeParse *Tentative =
nullptr);
4659 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
4743 ExprResult ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc,
4798 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
4828 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
4843 bool ParseCXXTypeSpecifierSeq(
4861 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr *> &Exprs,
4873 void ParseDirectNewDeclarator(Declarator &D);
4906 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
4921 ExprResult ParseCXXDeleteExpression(
bool UseGlobal, SourceLocation Start);
4960 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
4964 ForRangeInfo *FRI =
nullptr,
4965 bool EnterForConditionScope =
false);
4967 ParsedAttributes &Attrs);
5014 bool isTypeIdInParens(
bool &isAmbiguous) {
5017 isAmbiguous =
false;
5018 return isTypeSpecifierQualifier();
5020 bool isTypeIdInParens() {
5022 return isTypeIdInParens(isAmbiguous);
5060 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
ParsedType ObjectType,
5061 bool ObjectHadErrors,
5062 SourceLocation TemplateKWLoc,
5063 IdentifierInfo *Name,
5064 SourceLocation NameLoc,
5065 bool EnteringContext, UnqualifiedId &Id,
5066 bool AssumeTemplateId);
5108 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
5166 bool MaybeParseHLSLAnnotations(Declarator &D,
5167 SourceLocation *EndLoc =
nullptr,
5168 bool CouldBeBitField =
false) {
5169 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5170 if (Tok.is(tok::colon)) {
5171 ParsedAttributes Attrs(AttrFactory);
5172 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
5173 D.takeAttributesAppending(Attrs);
5179 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
5180 SourceLocation *EndLoc =
nullptr) {
5181 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5182 if (Tok.is(tok::colon))
5183 ParseHLSLAnnotations(Attrs, EndLoc);
5186 struct ParsedSemantic {
5187 StringRef Name =
"";
5189 bool Explicit =
false;
5192 ParsedSemantic ParseHLSLSemantic();
5194 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
5195 SourceLocation *EndLoc =
nullptr,
5196 bool CouldBeBitField =
false);
5197 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd, ParsedAttributes &Attrs);
5221 ExprResult ParseInitializer(Decl *DeclForInitializer =
nullptr);
5226 bool MayBeDesignationStart();
5244 struct DesignatorCompletionInfo {
5245 SmallVectorImpl<Expr *> &InitExprs;
5246 QualType PreferredBaseType;
5295 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
5300 typedef SmallVector<Expr *, 12> ExprVector;
5304 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
5321 friend class ObjCDeclContextSwitch;
5324 return Actions.ObjC().getObjCDeclContext();
5330 return Actions.getNullabilityKeyword(nullability);
5346 bool InMessageExpression;
5353 bool ParsingInObjCContainer;
5358 bool isObjCInstancetype() {
5360 if (
Tok.isAnnotation())
5362 if (!Ident_instancetype)
5364 return Tok.getIdentifierInfo() == Ident_instancetype;
5372 ObjCContainerDecl *DC;
5373 SaveAndRestore<bool> WithinObjCContainer;
5378 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
5380 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
5382 ~ObjCDeclContextSwitch() {
5384 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
5388 void CheckNestedObjCContexts(SourceLocation AtLoc);
5390 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
5408 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
5409 ParsedAttributes &DeclSpecAttrs);
5420 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
5453 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
5454 ParsedAttributes &prefixAttrs);
5460 ObjCTypeParamList *parseObjCTypeParamList();
5488 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
5490 SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
5491 bool mayBeProtocolList =
true);
5493 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
5494 SourceLocation atLoc,
5496 SmallVectorImpl<Decl *> &AllIvarDecls,
5497 bool RBraceMissing);
5522 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
5524 SourceLocation atLoc);
5531 bool ParseObjCProtocolReferences(
5532 SmallVectorImpl<Decl *> &P, SmallVectorImpl<SourceLocation> &PLocs,
5533 bool WarnOnDeclarations,
bool ForObjCContainer, SourceLocation &LAngleLoc,
5534 SourceLocation &EndProtoLoc,
bool consumeLastToken);
5545 void parseObjCTypeArgsOrProtocolQualifiers(
5546 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5547 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5548 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5549 SmallVectorImpl<SourceLocation> &protocolLocs,
5550 SourceLocation &protocolRAngleLoc,
bool consumeLastToken,
5551 bool warnOnIncompleteProtocols);
5555 void parseObjCTypeArgsAndProtocolQualifiers(
5556 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5557 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5558 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5559 SmallVectorImpl<SourceLocation> &protocolLocs,
5560 SourceLocation &protocolRAngleLoc,
bool consumeLastToken);
5564 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
5568 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
5570 bool consumeLastToken,
5571 SourceLocation &endLoc);
5607 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
5608 ParsedAttributes &prefixAttrs);
5610 struct ObjCImplParsingDataRAII {
5614 typedef SmallVector<LexedMethod *, 8> LateParsedObjCMethodContainer;
5615 LateParsedObjCMethodContainer LateParsedObjCMethods;
5617 ObjCImplParsingDataRAII(
Parser &parser, Decl *D)
5618 : P(parser), Dcl(D), HasCFunction(
false) {
5619 P.CurParsedObjCImpl =
this;
5622 ~ObjCImplParsingDataRAII();
5624 void finish(SourceRange AtEnd);
5625 bool isFinished()
const {
return Finished; }
5630 ObjCImplParsingDataRAII *CurParsedObjCImpl;
5634 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
5648 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
5649 ParsedAttributes &Attrs);
5657 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
5672 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
5683 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
5695 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
5703 bool isTokIdentifier_in()
const;
5712 ParsedAttributes *ParamAttrs);
5726 Decl *ParseObjCMethodPrototype(
5728 bool MethodDefinition =
true);
5760 Decl *ParseObjCMethodDecl(
5763 bool MethodDefinition =
true);
5793 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
5799 Decl *ParseObjCMethodDefinition();
5803 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
5804 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
5811 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
5820 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
5829 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
5831 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
5832 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
5839 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
5845 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
5851 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
5857 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
5864 bool isSimpleObjCMessageExpression();
5919 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
5920 SourceLocation SuperLoc,
5922 Expr *ReceiverExpr);
5948 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
5953 enum class ParsedStmtContext;
5955 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
5956 ParsedStmtContext StmtCtx);
5971 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
5978 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
5985 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
5992 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
6019 bool isStartOfObjCClassMessageMissingOpenBracket();
6051 bool OpenACCDirectiveParsing =
false;
6055 bool AllowOpenACCArraySections =
false;
6059 class OpenACCArraySectionRAII {
6063 OpenACCArraySectionRAII(
Parser &P) : P(P) {
6064 assert(!P.AllowOpenACCArraySections);
6065 P.AllowOpenACCArraySections =
true;
6067 ~OpenACCArraySectionRAII() {
6068 assert(P.AllowOpenACCArraySections);
6069 P.AllowOpenACCArraySections =
false;
6076 struct OpenACCDirectiveParseInfo {
6078 SourceLocation StartLoc;
6079 SourceLocation DirLoc;
6080 SourceLocation LParenLoc;
6081 SourceLocation RParenLoc;
6082 SourceLocation EndLoc;
6083 SourceLocation MiscLoc;
6085 SmallVector<Expr *> Exprs;
6086 SmallVector<OpenACCClause *> Clauses;
6091 struct OpenACCWaitParseInfo {
6092 bool Failed =
false;
6093 Expr *DevNumExpr =
nullptr;
6094 SourceLocation QueuesLoc;
6095 SmallVector<Expr *> QueueIdExprs;
6097 SmallVector<Expr *> getAllExprs() {
6098 SmallVector<Expr *>
Out;
6099 Out.push_back(DevNumExpr);
6100 llvm::append_range(Out, QueueIdExprs);
6104 struct OpenACCCacheParseInfo {
6105 bool Failed =
false;
6106 SourceLocation ReadOnlyLoc;
6107 SmallVector<Expr *> Vars;
6112 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
6118 using OpenACCClauseParseResult =
6119 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
6121 OpenACCClauseParseResult OpenACCCanContinue();
6122 OpenACCClauseParseResult OpenACCCannotContinue();
6123 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
6127 OpenACCDirectiveParseInfo ParseOpenACCDirective();
6137 OpenACCCacheParseInfo ParseOpenACCCacheVarList();
6143 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
6169 OpenACCClauseParseResult
6170 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
6172 SourceLocation ClauseLoc);
6176 OpenACCClauseParseResult
6177 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
6187 SmallVector<OpenACCClause *>
6196 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation Loc,
6201 std::variant<std::monostate, StringLiteral *, IdentifierInfo *>
6202 ParseOpenACCBindClauseArgument();
6207 using OpenACCIntExprParseResult =
6208 std::pair<ExprResult, OpenACCParseCanContinue>;
6213 SourceLocation Loc);
6218 llvm::SmallVectorImpl<Expr *> &IntExprs);
6231 bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
6245 SourceLocation Loc);
6260 llvm::SmallVectorImpl<Expr *> &SizeExprs);
6272 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
6273 llvm::SmallVectorImpl<OpenACCGangKind> &GKs,
6274 llvm::SmallVectorImpl<Expr *> &IntExprs);
6276 using OpenACCGangArgRes = std::pair<OpenACCGangKind, ExprResult>;
6280 OpenACCGangArgRes ParseOpenACCGangArg(SourceLocation GangLoc);
6284 ParseOpenACCAfterRoutineDecl(
AccessSpecifier &AS, ParsedAttributes &Attrs,
6286 OpenACCDirectiveParseInfo &DirInfo);
6287 StmtResult ParseOpenACCAfterRoutineStmt(OpenACCDirectiveParseInfo &DirInfo);
6305 bool OpenMPDirectiveParsing =
false;
6310 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
6313 if (!OpenMPTokens.empty()) {
6314 PP.EnterToken(Tok,
true);
6315 PP.EnterTokenStream(OpenMPTokens,
true,
6327 SourceLocation Loc);
6331 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
6332 llvm::omp::TraitSet
Set,
6333 llvm::omp::TraitSelector Selector,
6334 llvm::StringMap<SourceLocation> &Seen);
6337 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
6338 llvm::omp::TraitSet
Set,
6339 llvm::StringMap<SourceLocation> &Seen);
6342 void parseOMPTraitSetKind(OMPTraitSet &TISet,
6343 llvm::StringMap<SourceLocation> &Seen);
6346 void parseOMPContextProperty(OMPTraitSelector &TISelector,
6347 llvm::omp::TraitSet
Set,
6348 llvm::StringMap<SourceLocation> &Seen);
6355 void parseOMPContextSelector(OMPTraitSelector &TISelector,
6356 llvm::omp::TraitSet
Set,
6357 llvm::StringMap<SourceLocation> &SeenSelectors);
6364 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
6365 llvm::StringMap<SourceLocation> &SeenSets);
6372 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
6375 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
6379 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
6380 OMPTraitInfo *ParentTI);
6385 SourceLocation Loc);
6404 void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
6405 SourceLocation Loc);
6408 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
6425 void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
6426 SmallVectorImpl<clang::OMPClause *> &Clauses,
6427 SourceLocation Loc);
6430 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
6433 void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind BeginDKind,
6434 OpenMPDirectiveKind EndDKind,
6435 SourceLocation Loc);
6439 void skipUntilPragmaOpenMPEnd(OpenMPDirectiveKind DKind);
6445 void parseOMPEndDirective(OpenMPDirectiveKind BeginKind,
6446 OpenMPDirectiveKind ExpectedKind,
6447 OpenMPDirectiveKind FoundKind,
6448 SourceLocation MatchingLoc, SourceLocation FoundLoc,
6449 bool SkipUntilOpenMPEnd);
6490 AccessSpecifier &AS, ParsedAttributes &Attrs,
bool Delayed =
false,
6492 Decl *TagDecl =
nullptr);
6506 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(AccessSpecifier AS);
6510 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
6522 DeclGroupPtrTy ParseOpenMPDeclareMapperDirective(AccessSpecifier AS);
6525 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
6526 DeclarationName &Name,
6527 AccessSpecifier AS =
AS_none);
6541 bool ParseOpenMPSimpleVarList(
6542 OpenMPDirectiveKind Kind,
6543 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)>
6545 bool AllowScopeSpecifier);
6594 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
6595 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
6605 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
6606 OpenMPDirectiveKind DKind, SourceLocation Loc,
6607 bool ReadDirectiveWithinMetadirective);
6616 StmtResult ParseOpenMPInformationalDirective(
6617 ParsedStmtContext StmtCtx, OpenMPDirectiveKind DKind, SourceLocation Loc,
6618 bool ReadDirectiveWithinMetadirective);
6647 OMPClause *ParseOpenMPClause(OpenMPDirectiveKind DKind,
6702 OMPClause *ParseOpenMPSingleExprClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6732 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6757 OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
6762 OMPClause *ParseOpenMPLoopRangeClause();
6765 OMPClause *ParseOpenMPSizesClause();
6768 OMPClause *ParseOpenMPPermutationClause();
6802 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
6872 OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
6886 SourceLocation &ClauseNameLoc,
6887 SourceLocation &OpenLoc,
6888 SourceLocation &CloseLoc,
6889 SmallVectorImpl<Expr *> &Exprs,
6890 bool ReqIntConst =
false);
6905 OMPClause *ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind);
6908 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
6939 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6946 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
6953 bool IsAddressOfOperand =
false);
6957 SemaOpenMP::OpenMPVarListDataTy &
Data,
6958 const LangOptions &LangOpts);
6961 SmallVectorImpl<Expr *> &Vars,
6962 SemaOpenMP::OpenMPVarListDataTy &
Data);
6997 std::unique_ptr<PragmaHandler> AlignHandler;
6998 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
6999 std::unique_ptr<PragmaHandler> OptionsHandler;
7000 std::unique_ptr<PragmaHandler> PackHandler;
7001 std::unique_ptr<PragmaHandler> MSStructHandler;
7002 std::unique_ptr<PragmaHandler> UnusedHandler;
7003 std::unique_ptr<PragmaHandler> WeakHandler;
7004 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
7005 std::unique_ptr<PragmaHandler> FPContractHandler;
7006 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
7007 std::unique_ptr<PragmaHandler> OpenMPHandler;
7008 std::unique_ptr<PragmaHandler> OpenACCHandler;
7009 std::unique_ptr<PragmaHandler> PCSectionHandler;
7010 std::unique_ptr<PragmaHandler> MSCommentHandler;
7011 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
7012 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
7013 std::unique_ptr<PragmaHandler> FloatControlHandler;
7014 std::unique_ptr<PragmaHandler> MSPointersToMembers;
7015 std::unique_ptr<PragmaHandler> MSVtorDisp;
7016 std::unique_ptr<PragmaHandler> MSInitSeg;
7017 std::unique_ptr<PragmaHandler> MSDataSeg;
7018 std::unique_ptr<PragmaHandler> MSBSSSeg;
7019 std::unique_ptr<PragmaHandler> MSConstSeg;
7020 std::unique_ptr<PragmaHandler> MSCodeSeg;
7021 std::unique_ptr<PragmaHandler> MSSection;
7022 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
7023 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
7024 std::unique_ptr<PragmaHandler> MSIntrinsic;
7025 std::unique_ptr<PragmaHandler> MSFunction;
7026 std::unique_ptr<PragmaHandler> MSOptimize;
7027 std::unique_ptr<PragmaHandler> MSFenvAccess;
7028 std::unique_ptr<PragmaHandler> MSAllocText;
7029 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
7030 std::unique_ptr<PragmaHandler> OptimizeHandler;
7031 std::unique_ptr<PragmaHandler> LoopHintHandler;
7032 std::unique_ptr<PragmaHandler> UnrollHintHandler;
7033 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
7034 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
7035 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
7036 std::unique_ptr<PragmaHandler> FPHandler;
7037 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
7038 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
7039 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
7040 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
7041 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
7042 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
7043 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
7044 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7047 void initializePragmaHandlers();
7050 void resetPragmaHandlers();
7057 void HandlePragmaUnused();
7061 void HandlePragmaVisibility();
7065 void HandlePragmaPack();
7069 void HandlePragmaMSStruct();
7071 void HandlePragmaMSPointersToMembers();
7073 void HandlePragmaMSVtorDisp();
7075 void HandlePragmaMSPragma();
7076 bool HandlePragmaMSSection(StringRef PragmaName,
7077 SourceLocation PragmaLocation);
7078 bool HandlePragmaMSSegment(StringRef PragmaName,
7079 SourceLocation PragmaLocation);
7082 bool HandlePragmaMSInitSeg(StringRef PragmaName,
7083 SourceLocation PragmaLocation);
7088 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
7089 SourceLocation PragmaLocation);
7090 bool HandlePragmaMSFunction(StringRef PragmaName,
7091 SourceLocation PragmaLocation);
7092 bool HandlePragmaMSAllocText(StringRef PragmaName,
7093 SourceLocation PragmaLocation);
7096 bool HandlePragmaMSOptimize(StringRef PragmaName,
7097 SourceLocation PragmaLocation);
7100 bool HandlePragmaMSIntrinsic(StringRef PragmaName,
7101 SourceLocation PragmaLocation);
7105 void HandlePragmaAlign();
7109 void HandlePragmaDump();
7113 void HandlePragmaWeak();
7117 void HandlePragmaWeakAlias();
7121 void HandlePragmaRedefineExtname();
7125 void HandlePragmaFPContract();
7129 void HandlePragmaFEnvAccess();
7133 void HandlePragmaFEnvRound();
7137 void HandlePragmaCXLimitedRange();
7141 void HandlePragmaFloatControl();
7145 void HandlePragmaFP();
7149 void HandlePragmaOpenCLExtension();
7153 StmtResult HandlePragmaCaptured();
7157 bool HandlePragmaLoopHint(LoopHint &Hint);
7159 bool ParsePragmaAttributeSubjectMatchRuleSet(
7161 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
7163 void HandlePragmaAttribute();
7189 enum class ParsedStmtContext {
7192 AllowDeclarationsInC = 0x1,
7194 AllowStandaloneOpenMPDirectives = 0x2,
7201 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
7218 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt,
7273 ParseStatementOrDeclaration(
StmtVector &Stmts, ParsedStmtContext StmtCtx,
7277 StmtResult ParseStatementOrDeclarationAfterAttributes(
7278 StmtVector &Stmts, ParsedStmtContext StmtCtx,
7283 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
7297 ParsedStmtContext StmtCtx);
7306 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
7307 bool MissingCase =
false,
7317 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
7319 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
7345 StmtResult ParseCompoundStatement(
bool isStmtExpr,
unsigned ScopeFlags);
7350 void ParseCompoundStatementLeadingPragmas();
7352 void DiagnoseLabelAtEndOfCompoundStatement();
7362 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
7380 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
7496 StmtResult ParseBreakOrContinueStatement(
bool IsContinue);
7513 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
7560 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
7598 Decl *ParseFunctionStatementBody(
Decl *
Decl, ParseScope &BodyScope);
7607 Decl *ParseFunctionTryBlock(
Decl *
Decl, ParseScope &BodyScope);
7613 bool trySkippingFunctionBody();
7621 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
7623 return isCXXDeclarationStatement(DisambiguatingWithExpression);
7631 bool isForInitDeclaration() {
7635 return Tok.is(tok::kw_using) ||
7636 isCXXSimpleDeclaration(
true);
7641 bool isForRangeIdentifier();
7658 unsigned &NumLineToksConsumed,
7659 bool IsUnevaluated);
7702 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
7718 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
7719 SmallVectorImpl<Expr *> &Constraints,
7720 SmallVectorImpl<Expr *> &Exprs);
7722 class GNUAsmQualifiers {
7723 unsigned Qualifiers = AQ_unspecified;
7732 static const char *getQualifierName(AQ Qualifier);
7733 bool setAsmQualifier(AQ Qualifier);
7734 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
7735 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
7736 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
7740 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
7742 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
7743 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
7756 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
7780 unsigned TemplateParameterDepth;
7783 class TemplateParameterDepthRAII {
7785 unsigned AddedLevels;
7788 explicit TemplateParameterDepthRAII(
unsigned &Depth)
7789 : Depth(Depth), AddedLevels(0) {}
7791 ~TemplateParameterDepthRAII() { Depth -= AddedLevels; }
7797 void addDepth(
unsigned D) {
7801 void setAddedDepth(
unsigned D) {
7802 Depth = Depth - AddedLevels + D;
7806 unsigned getDepth()
const {
return Depth; }
7807 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
7812 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
7818 bool DelayTemplateIdDestruction =
false;
7820 void MaybeDestroyTemplateIds() {
7821 if (DelayTemplateIdDestruction)
7823 if (!TemplateIds.empty() &&
7824 (Tok.is(tok::eof) || !PP.mightHavePendingAnnotationTokens()))
7825 DestroyTemplateIds();
7827 void DestroyTemplateIds();
7831 struct DestroyTemplateIdAnnotationsRAIIObj {
7834 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
7835 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
7838 struct DelayTemplateIdDestructionRAII {
7840 bool PrevDelayTemplateIdDestruction;
7842 DelayTemplateIdDestructionRAII(
Parser &Self,
7843 bool DelayTemplateIdDestruction) noexcept
7845 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
7846 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
7849 ~DelayTemplateIdDestructionRAII() noexcept {
7850 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
7855 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
7867 struct AngleBracketTracker {
7870 enum Priority :
unsigned short {
7872 PotentialTypo = 0x0,
7874 DependentName = 0x2,
7877 SpaceBeforeLess = 0x0,
7879 NoSpaceBeforeLess = 0x1,
7910 if (!Locs.empty() && Locs.back().isActive(P)) {
7911 if (Locs.back().Priority <= Prio) {
7913 Locs.back().LessLoc = LessLoc;
7914 Locs.back().Priority = Prio;
7917 Locs.push_back({
TemplateName, LessLoc, Prio, P.ParenCount,
7918 P.BracketCount, P.BraceCount});
7926 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
7933 if (!Locs.empty() && Locs.back().isActive(P))
7934 return &Locs.back();
7939 AngleBracketTracker AngleBrackets;
7944 struct ParsedTemplateInfo {
7945 ParsedTemplateInfo()
7949 bool isSpecialization,
7950 bool lastParameterListWasEmpty =
false)
7953 TemplateParams(TemplateParams),
7954 LastParameterListWasEmpty(lastParameterListWasEmpty) {}
7956 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
7957 SourceLocation TemplateLoc)
7959 TemplateParams(
nullptr), ExternLoc(ExternLoc),
7960 TemplateLoc(TemplateLoc), LastParameterListWasEmpty(
false) {}
7970 SourceLocation ExternLoc;
7974 SourceLocation TemplateLoc;
7977 bool LastParameterListWasEmpty;
7979 SourceRange getSourceRange() const LLVM_READONLY;
7983 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
7986 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
7988 static
void LateTemplateParserCallback(
void *P, LateParsedTemplate &LPT);
7996 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
7997 bool checkPotentialAngleBracketDelimiter(const AngleBracketTracker::Loc &,
7998 const Token &OpToken);
7999 bool checkPotentialAngleBracketDelimiter(const Token &OpToken) {
8000 if (
auto *Info = AngleBrackets.getCurrent(*
this))
8001 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
8012 SourceLocation &DeclEnd,
8013 ParsedAttributes &AccessAttrs);
8060 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
8072 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
8073 SmallVectorImpl<NamedDecl *> &TemplateParams,
8074 SourceLocation &LAngleLoc,
8075 SourceLocation &RAngleLoc);
8087 bool ParseTemplateParameterList(
unsigned Depth,
8088 SmallVectorImpl<NamedDecl *> &TemplateParams);
8090 enum class TPResult;
8094 TPResult isStartOfTemplateTypeParameter();
8118 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
8131 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
8147 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
8157 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
8161 bool isTypeConstraintAnnotation();
8173 bool TryAnnotateTypeConstraint();
8175 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
8176 SourceLocation CorrectLoc,
8177 bool AlreadyHasEllipsis,
8178 bool IdentifierHasName);
8179 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
8182 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
8199 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
8200 SourceLocation &RAngleLoc,
8201 bool ConsumeLastToken,
8202 bool ObjCGenericList);
8215 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
8216 SourceLocation &LAngleLoc,
8217 TemplateArgList &TemplateArgs,
8218 SourceLocation &RAngleLoc,
8263 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8265 bool AllowTypeAnnotation =
true,
8266 bool TypeConstraint =
false);
8284 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
8286 bool IsClassName =
false);
8298 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
8302 ParsedTemplateArgument ParseTemplateTemplateArgument();
8314 ParsedTemplateArgument ParseTemplateArgument();
8326 SourceLocation ExternLoc,
8327 SourceLocation TemplateLoc,
8328 SourceLocation &DeclEnd,
8329 ParsedAttributes &AccessAttrs,
8338 Decl *ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
8339 SourceLocation &DeclEnd);
8367 class TentativeParsingAction {
8369 PreferredTypeBuilder PrevPreferredType;
8371 size_t PrevTentativelyDeclaredIdentifierCount;
8372 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
8376 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
8377 : P(p), PrevPreferredType(P.PreferredType) {
8379 PrevTentativelyDeclaredIdentifierCount =
8380 P.TentativelyDeclaredIdentifiers.size();
8381 PrevParenCount = P.ParenCount;
8382 PrevBracketCount = P.BracketCount;
8383 PrevBraceCount = P.BraceCount;
8384 P.PP.EnableBacktrackAtThisPos(Unannotated);
8388 assert(isActive &&
"Parsing action was finished!");
8389 P.TentativelyDeclaredIdentifiers.resize(
8390 PrevTentativelyDeclaredIdentifierCount);
8391 P.PP.CommitBacktrackedTokens();
8395 assert(isActive &&
"Parsing action was finished!");
8397 P.PreferredType = PrevPreferredType;
8399 P.TentativelyDeclaredIdentifiers.resize(
8400 PrevTentativelyDeclaredIdentifierCount);
8401 P.ParenCount = PrevParenCount;
8402 P.BracketCount = PrevBracketCount;
8403 P.BraceCount = PrevBraceCount;
8406 ~TentativeParsingAction() {
8407 assert(!isActive &&
"Forgot to call Commit or Revert!");
8413 class RevertingTentativeParsingAction
8414 :
private Parser::TentativeParsingAction {
8416 using TentativeParsingAction::TentativeParsingAction;
8418 ~RevertingTentativeParsingAction() { Revert(); }
8453 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
8479 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
8492 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
8496 struct ConditionDeclarationOrInitStatementState;
8497 enum class ConditionOrInitStatement {
8524 ConditionOrInitStatement
8525 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
8526 bool CanBeForRangeDecl);
8552 return isCXXTypeId(Context, isAmbiguous);
8566 bool isEnumBase(
bool AllowSemi);
8686 TPResult BracedCastResult = TPResult::False,
8687 bool *InvalidAsDeclSpec =
nullptr);
8692 bool isCXXDeclarationSpecifierAType();
8698 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
8703 TPResult isExplicitBool();
8708 bool isTentativelyDeclared(IdentifierInfo *II);
8727 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
8735 TPResult TryParseTypeofSpecifier();
8739 TPResult TryParseProtocolQualifiers();
8741 TPResult TryParsePtrOperatorSeq();
8763 TPResult TryParseOperatorId();
8794 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
8851 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
8852 bool mayHaveDirectInit =
false,
8853 bool mayHaveTrailingReturnType =
false);
8874 TPResult TryParseParameterDeclarationClause(
8875 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
8892 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
8898 bool NameAfterArrowIsNonType();
8904 TPResult TryParseBracketDeclarator();
8908 TPResult TryConsumeDeclarationSpecifier();
8912 bool TrySkipAttributes();
8954 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
8955 bool OuterMightBeMessageSend =
false);