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;
2838 mutable IdentifierInfo *Ident_replaceable_if_eligible;
2843 struct ParsingClass {
2844 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
2845 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
2846 TagOrTemplate(TagOrTemplate) {}
2850 bool TopLevelClass : 1;
2853 bool IsInterface : 1;
2856 Decl *TagOrTemplate;
2861 LateParsedDeclarationsContainer LateParsedDeclarations;
2867 std::stack<ParsingClass *> ClassStack;
2869 ParsingClass &getCurrentClass() {
2870 assert(!ClassStack.empty() &&
"No lexed method stacks!");
2871 return *ClassStack.top();
2875 class ParsingClassDefinition {
2881 ParsingClassDefinition(
Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
2883 : P(P), Popped(
false),
2884 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
2889 assert(!Popped &&
"Nested class has already been popped");
2891 P.PopParsingClass(State);
2894 ~ParsingClassDefinition() {
2896 P.PopParsingClass(State);
2912 bool Delayed, SourceRange &SpecificationRange,
2913 SmallVectorImpl<ParsedType> &DynamicExceptions,
2914 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2932 ParseDynamicExceptionSpecification(SourceRange &SpecificationRange,
2933 SmallVectorImpl<ParsedType> &Exceptions,
2934 SmallVectorImpl<SourceRange> &Ranges);
2941 TypeResult ParseTrailingReturnType(SourceRange &Range,
2942 bool MayBeFollowedByDirectInit);
2945 void ParseTrailingRequiresClause(Declarator &D);
2947 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2948 ParsedAttributes &AccessAttrs,
2951 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2952 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2953 SourceLocation StartLoc,
2954 SourceLocation EndLoc);
2961 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2962 bool OuterMightBeMessageSend =
false) {
2963 return (Tok.isRegularKeywordAttribute() ||
2964 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend) !=
2971 SourceLocation SkipCXX11Attributes();
2975 void DiagnoseAndSkipCXX11Attributes();
2977 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3006 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3008 SourceLocation *EndLoc =
nullptr);
3009 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3010 SourceLocation *EndLoc =
nullptr) {
3012 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3013 ReplayOpenMPAttributeTokens(OpenMPTokens);
3022 void ParseCXX11Attributes(ParsedAttributes &attrs);
3042 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3043 SourceLocation AttrNameLoc,
3044 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3045 IdentifierInfo *ScopeName,
3046 SourceLocation ScopeLoc,
3052 ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
3053 SourceLocation AttrNameLoc,
3054 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3055 SourceLocation *EndLoc, ParsedAttr::Form Form);
3066 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3067 SourceLocation &Loc,
3070 const IdentifierInfo *EnclosingScope =
nullptr);
3073 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3085 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3087 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3088 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3097 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3098 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3099 SourceLocation StartLoc,
3100 SourceLocation EndLoc);
3113 return isCXX11VirtSpecifier(Tok);
3123 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3124 SourceLocation FriendLoc);
3128 bool isCXX11FinalKeyword()
const;
3134 bool isClassCompatibleKeyword()
const;
3136 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3139 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3171 SourceLocation &DeclEnd,
3172 SourceLocation InlineLoc = SourceLocation());
3174 struct InnerNamespaceInfo {
3175 SourceLocation NamespaceLoc;
3176 SourceLocation InlineLoc;
3177 SourceLocation IdentLoc;
3178 IdentifierInfo *Ident;
3180 using InnerNamespaceInfoList = llvm::SmallVector<InnerNamespaceInfo, 4>;
3183 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3184 unsigned int index, SourceLocation &InlineLoc,
3185 ParsedAttributes &attrs,
3217 Decl *ParseExportDeclaration();
3223 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3238 SourceLocation &DeclEnd, ParsedAttributes &attrs);
3240 struct UsingDeclarator {
3241 SourceLocation TypenameLoc;
3244 SourceLocation EllipsisLoc;
3247 TypenameLoc = EllipsisLoc = SourceLocation();
3288 const ParsedTemplateInfo &TemplateInfo,
3289 SourceLocation UsingLoc,
3290 SourceLocation &DeclEnd,
3291 ParsedAttributes &Attrs,
3293 Decl *ParseAliasDeclarationAfterDeclarator(
3294 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3296 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3309 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3314 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3315 SourceLocation AliasLoc, IdentifierInfo *Alias,
3316 SourceLocation &DeclEnd);
3324 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3368 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3369 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3371 DeclSpecContext DSC, ParsedAttributes &Attributes);
3372 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3373 SourceLocation AttrFixitLoc,
unsigned TagType,
3384 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3385 SourceLocation AttrFixitLoc,
3386 ParsedAttributes &Attrs,
unsigned TagType,
3411 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3412 SourceLocation &EqualLoc);
3416 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3419 LateParsedAttrList &LateAttrs);
3424 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3425 VirtSpecifiers &VS);
3481 ParsedTemplateInfo &TemplateInfo,
3482 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3485 ParsedAttributes &AccessAttrs,
3511 void ParseConstructorInitializer(Decl *ConstructorDecl);
3533 void HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
3561 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3562 SourceLocation &EndLocation);
3574 void ParseBaseClause(Decl *ClassDecl);
3589 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3602 bool isCXX2CTriviallyRelocatableKeyword(Token Tok)
const;
3603 bool isCXX2CTriviallyRelocatableKeyword()
const;
3604 void ParseCXX2CTriviallyRelocatableSpecifier(SourceLocation &TRS);
3606 bool isCXX2CReplaceableKeyword(Token Tok)
const;
3607 bool isCXX2CReplaceableKeyword()
const;
3608 void ParseCXX2CReplaceableSpecifier(SourceLocation &MRS);
3613 bool isClassCompatibleKeyword(Token Tok)
const;
3615 void ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs);
3790 bool GreaterThanIsOperator;
3794 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
3813 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
3817 void DeallocateParsedClasses(ParsingClass *
Class);
4035 bool isAddressOfOperand,
bool &NotCastExpr,
4037 bool isVectorLiteral =
false,
4038 bool *NotPrimaryExpression =
nullptr);
4040 bool isAddressOfOperand =
false,
4043 bool isVectorLiteral =
false,
4044 bool *NotPrimaryExpression =
nullptr);
4047 bool isNotExpressionStart();
4051 bool isPostfixExpressionSuffixStart() {
4053 return (K == tok::l_square || K == tok::l_paren || K == tok::period ||
4054 K == tok::arrow || K == tok::plusplus || K == tok::minusminus);
4096 ExprResult ParseUnaryExprOrTypeTraitExpression();
4125 ExprResult ParseSYCLUniqueStableNameExpression();
4187 llvm::function_ref<
void()> ExpressionStarts =
4188 llvm::function_ref<
void()>(),
4189 bool FailImmediatelyOnInvalidExpr =
false);
4234 bool StopIfCastExpr,
4271 ExprResult ParseGenericSelectionExpression();
4290 void injectEmbedTokens();
4316 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
4318 Expr *ReceiverExpr);
4323 bool isKnownToBeDeclarationSpecifier() {
4337 bool isTypeIdForGenericSelection() {
4343 return isTypeSpecifierQualifier();
4349 bool isTypeIdUnambiguously() {
4354 return isTypeSpecifierQualifier();
4363 void ParseBlockId(SourceLocation CaretLoc);
4372 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
4373 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
4379 bool tryParseOpenMPArrayShapingCastPart();
4381 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
4434 bool ObjectHadErrors,
bool EnteringContext,
4435 bool AllowDestructorName,
bool AllowConstructorName,
4436 bool AllowDeductionGuide,
4437 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
4455 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
4456 Token &Replacement);
4507 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
4510 bool areTokensAdjacent(
const Token &A,
const Token &B);
4514 void CheckForTemplateAndDigraph(Token &
Next,
ParsedType ObjectTypePtr,
4515 bool EnteringContext, IdentifierInfo &II,
4570 bool ParseOptionalCXXScopeSpecifier(
4571 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
4572 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
4573 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
4574 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
4575 bool Disambiguation =
false);
4581 enum class LambdaIntroducerTentativeParse {
4659 ParseLambdaIntroducer(LambdaIntroducer &Intro,
4660 LambdaIntroducerTentativeParse *Tentative =
nullptr);
4664 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
4748 ExprResult ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc,
4803 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
4833 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
4848 bool ParseCXXTypeSpecifierSeq(
4866 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr *> &Exprs,
4878 void ParseDirectNewDeclarator(Declarator &D);
4911 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
4926 ExprResult ParseCXXDeleteExpression(
bool UseGlobal, SourceLocation Start);
4965 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
4969 ForRangeInfo *FRI =
nullptr,
4970 bool EnterForConditionScope =
false);
4972 ParsedAttributes &Attrs);
5019 bool isTypeIdInParens(
bool &isAmbiguous) {
5022 isAmbiguous =
false;
5023 return isTypeSpecifierQualifier();
5025 bool isTypeIdInParens() {
5027 return isTypeIdInParens(isAmbiguous);
5065 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
ParsedType ObjectType,
5066 bool ObjectHadErrors,
5067 SourceLocation TemplateKWLoc,
5068 IdentifierInfo *Name,
5069 SourceLocation NameLoc,
5070 bool EnteringContext, UnqualifiedId &Id,
5071 bool AssumeTemplateId);
5113 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
5171 bool MaybeParseHLSLAnnotations(Declarator &D,
5172 SourceLocation *EndLoc =
nullptr,
5173 bool CouldBeBitField =
false) {
5174 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5175 if (Tok.is(tok::colon)) {
5176 ParsedAttributes Attrs(AttrFactory);
5177 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
5178 D.takeAttributesAppending(Attrs);
5184 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
5185 SourceLocation *EndLoc =
nullptr) {
5186 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5187 if (Tok.is(tok::colon))
5188 ParseHLSLAnnotations(Attrs, EndLoc);
5191 struct ParsedSemantic {
5192 StringRef Name =
"";
5194 bool Explicit =
false;
5197 ParsedSemantic ParseHLSLSemantic();
5199 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
5200 SourceLocation *EndLoc =
nullptr,
5201 bool CouldBeBitField =
false);
5202 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd, ParsedAttributes &Attrs);
5226 ExprResult ParseInitializer(Decl *DeclForInitializer =
nullptr);
5231 bool MayBeDesignationStart();
5249 struct DesignatorCompletionInfo {
5250 SmallVectorImpl<Expr *> &InitExprs;
5251 QualType PreferredBaseType;
5300 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
5305 typedef SmallVector<Expr *, 12> ExprVector;
5309 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
5326 friend class ObjCDeclContextSwitch;
5329 return Actions.ObjC().getObjCDeclContext();
5335 return Actions.getNullabilityKeyword(nullability);
5351 bool InMessageExpression;
5358 bool ParsingInObjCContainer;
5363 bool isObjCInstancetype() {
5365 if (
Tok.isAnnotation())
5367 if (!Ident_instancetype)
5369 return Tok.getIdentifierInfo() == Ident_instancetype;
5377 ObjCContainerDecl *DC;
5378 SaveAndRestore<bool> WithinObjCContainer;
5383 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
5385 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
5387 ~ObjCDeclContextSwitch() {
5389 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
5393 void CheckNestedObjCContexts(SourceLocation AtLoc);
5395 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
5413 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
5414 ParsedAttributes &DeclSpecAttrs);
5425 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
5458 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
5459 ParsedAttributes &prefixAttrs);
5465 ObjCTypeParamList *parseObjCTypeParamList();
5493 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
5495 SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
5496 bool mayBeProtocolList =
true);
5498 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
5499 SourceLocation atLoc,
5501 SmallVectorImpl<Decl *> &AllIvarDecls,
5502 bool RBraceMissing);
5527 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
5529 SourceLocation atLoc);
5536 bool ParseObjCProtocolReferences(
5537 SmallVectorImpl<Decl *> &P, SmallVectorImpl<SourceLocation> &PLocs,
5538 bool WarnOnDeclarations,
bool ForObjCContainer, SourceLocation &LAngleLoc,
5539 SourceLocation &EndProtoLoc,
bool consumeLastToken);
5550 void parseObjCTypeArgsOrProtocolQualifiers(
5551 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5552 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5553 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5554 SmallVectorImpl<SourceLocation> &protocolLocs,
5555 SourceLocation &protocolRAngleLoc,
bool consumeLastToken,
5556 bool warnOnIncompleteProtocols);
5560 void parseObjCTypeArgsAndProtocolQualifiers(
5561 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5562 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5563 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5564 SmallVectorImpl<SourceLocation> &protocolLocs,
5565 SourceLocation &protocolRAngleLoc,
bool consumeLastToken);
5569 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
5573 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
5575 bool consumeLastToken,
5576 SourceLocation &endLoc);
5612 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
5613 ParsedAttributes &prefixAttrs);
5615 struct ObjCImplParsingDataRAII {
5619 typedef SmallVector<LexedMethod *, 8> LateParsedObjCMethodContainer;
5620 LateParsedObjCMethodContainer LateParsedObjCMethods;
5622 ObjCImplParsingDataRAII(
Parser &parser, Decl *D)
5623 : P(parser), Dcl(D), HasCFunction(
false) {
5624 P.CurParsedObjCImpl =
this;
5627 ~ObjCImplParsingDataRAII();
5629 void finish(SourceRange AtEnd);
5630 bool isFinished()
const {
return Finished; }
5635 ObjCImplParsingDataRAII *CurParsedObjCImpl;
5639 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
5653 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
5654 ParsedAttributes &Attrs);
5662 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
5677 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
5688 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
5700 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
5708 bool isTokIdentifier_in()
const;
5717 ParsedAttributes *ParamAttrs);
5731 Decl *ParseObjCMethodPrototype(
5733 bool MethodDefinition =
true);
5765 Decl *ParseObjCMethodDecl(
5768 bool MethodDefinition =
true);
5798 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
5804 Decl *ParseObjCMethodDefinition();
5808 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
5809 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
5816 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
5825 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
5834 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
5836 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
5837 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
5844 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
5850 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
5856 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
5862 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
5869 bool isSimpleObjCMessageExpression();
5924 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
5925 SourceLocation SuperLoc,
5927 Expr *ReceiverExpr);
5953 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
5958 enum class ParsedStmtContext;
5960 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
5961 ParsedStmtContext StmtCtx);
5976 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
5983 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
5990 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
5997 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
6024 bool isStartOfObjCClassMessageMissingOpenBracket();
6056 bool OpenACCDirectiveParsing =
false;
6060 bool AllowOpenACCArraySections =
false;
6064 class OpenACCArraySectionRAII {
6068 OpenACCArraySectionRAII(
Parser &P) : P(P) {
6069 assert(!P.AllowOpenACCArraySections);
6070 P.AllowOpenACCArraySections =
true;
6072 ~OpenACCArraySectionRAII() {
6073 assert(P.AllowOpenACCArraySections);
6074 P.AllowOpenACCArraySections =
false;
6081 struct OpenACCDirectiveParseInfo {
6083 SourceLocation StartLoc;
6084 SourceLocation DirLoc;
6085 SourceLocation LParenLoc;
6086 SourceLocation RParenLoc;
6087 SourceLocation EndLoc;
6088 SourceLocation MiscLoc;
6090 SmallVector<Expr *> Exprs;
6091 SmallVector<OpenACCClause *> Clauses;
6096 struct OpenACCWaitParseInfo {
6097 bool Failed =
false;
6098 Expr *DevNumExpr =
nullptr;
6099 SourceLocation QueuesLoc;
6100 SmallVector<Expr *> QueueIdExprs;
6102 SmallVector<Expr *> getAllExprs() {
6103 SmallVector<Expr *>
Out;
6104 Out.push_back(DevNumExpr);
6105 llvm::append_range(Out, QueueIdExprs);
6109 struct OpenACCCacheParseInfo {
6110 bool Failed =
false;
6111 SourceLocation ReadOnlyLoc;
6112 SmallVector<Expr *> Vars;
6117 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
6123 using OpenACCClauseParseResult =
6124 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
6126 OpenACCClauseParseResult OpenACCCanContinue();
6127 OpenACCClauseParseResult OpenACCCannotContinue();
6128 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
6132 OpenACCDirectiveParseInfo ParseOpenACCDirective();
6142 OpenACCCacheParseInfo ParseOpenACCCacheVarList();
6148 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
6174 OpenACCClauseParseResult
6175 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
6177 SourceLocation ClauseLoc);
6181 OpenACCClauseParseResult
6182 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
6192 SmallVector<OpenACCClause *>
6201 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation Loc,
6206 std::variant<std::monostate, StringLiteral *, IdentifierInfo *>
6207 ParseOpenACCBindClauseArgument();
6212 using OpenACCIntExprParseResult =
6213 std::pair<ExprResult, OpenACCParseCanContinue>;
6218 SourceLocation Loc);
6223 llvm::SmallVectorImpl<Expr *> &IntExprs);
6236 bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
6250 SourceLocation Loc);
6265 llvm::SmallVectorImpl<Expr *> &SizeExprs);
6277 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
6278 llvm::SmallVectorImpl<OpenACCGangKind> &GKs,
6279 llvm::SmallVectorImpl<Expr *> &IntExprs);
6281 using OpenACCGangArgRes = std::pair<OpenACCGangKind, ExprResult>;
6285 OpenACCGangArgRes ParseOpenACCGangArg(SourceLocation GangLoc);
6289 ParseOpenACCAfterRoutineDecl(
AccessSpecifier &AS, ParsedAttributes &Attrs,
6291 OpenACCDirectiveParseInfo &DirInfo);
6292 StmtResult ParseOpenACCAfterRoutineStmt(OpenACCDirectiveParseInfo &DirInfo);
6310 bool OpenMPDirectiveParsing =
false;
6315 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
6318 if (!OpenMPTokens.empty()) {
6319 PP.EnterToken(Tok,
true);
6320 PP.EnterTokenStream(OpenMPTokens,
true,
6332 SourceLocation Loc);
6336 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
6337 llvm::omp::TraitSet
Set,
6338 llvm::omp::TraitSelector Selector,
6339 llvm::StringMap<SourceLocation> &Seen);
6342 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
6343 llvm::omp::TraitSet
Set,
6344 llvm::StringMap<SourceLocation> &Seen);
6347 void parseOMPTraitSetKind(OMPTraitSet &TISet,
6348 llvm::StringMap<SourceLocation> &Seen);
6351 void parseOMPContextProperty(OMPTraitSelector &TISelector,
6352 llvm::omp::TraitSet
Set,
6353 llvm::StringMap<SourceLocation> &Seen);
6360 void parseOMPContextSelector(OMPTraitSelector &TISelector,
6361 llvm::omp::TraitSet
Set,
6362 llvm::StringMap<SourceLocation> &SeenSelectors);
6369 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
6370 llvm::StringMap<SourceLocation> &SeenSets);
6377 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
6380 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
6384 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
6385 OMPTraitInfo *ParentTI);
6390 SourceLocation Loc);
6409 void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
6410 SourceLocation Loc);
6413 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
6430 void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
6431 SmallVectorImpl<clang::OMPClause *> &Clauses,
6432 SourceLocation Loc);
6435 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
6438 void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind BeginDKind,
6439 OpenMPDirectiveKind EndDKind,
6440 SourceLocation Loc);
6444 void skipUntilPragmaOpenMPEnd(OpenMPDirectiveKind DKind);
6450 void parseOMPEndDirective(OpenMPDirectiveKind BeginKind,
6451 OpenMPDirectiveKind ExpectedKind,
6452 OpenMPDirectiveKind FoundKind,
6453 SourceLocation MatchingLoc, SourceLocation FoundLoc,
6454 bool SkipUntilOpenMPEnd);
6495 AccessSpecifier &AS, ParsedAttributes &Attrs,
bool Delayed =
false,
6497 Decl *TagDecl =
nullptr);
6511 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(AccessSpecifier AS);
6515 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
6527 DeclGroupPtrTy ParseOpenMPDeclareMapperDirective(AccessSpecifier AS);
6530 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
6531 DeclarationName &Name,
6532 AccessSpecifier AS =
AS_none);
6546 bool ParseOpenMPSimpleVarList(
6547 OpenMPDirectiveKind Kind,
6548 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)>
6550 bool AllowScopeSpecifier);
6599 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
6600 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
6610 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
6611 OpenMPDirectiveKind DKind, SourceLocation Loc,
6612 bool ReadDirectiveWithinMetadirective);
6621 StmtResult ParseOpenMPInformationalDirective(
6622 ParsedStmtContext StmtCtx, OpenMPDirectiveKind DKind, SourceLocation Loc,
6623 bool ReadDirectiveWithinMetadirective);
6652 OMPClause *ParseOpenMPClause(OpenMPDirectiveKind DKind,
6707 OMPClause *ParseOpenMPSingleExprClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6737 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6762 OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
6767 OMPClause *ParseOpenMPLoopRangeClause();
6770 OMPClause *ParseOpenMPSizesClause();
6773 OMPClause *ParseOpenMPPermutationClause();
6807 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
6877 OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
6891 SourceLocation &ClauseNameLoc,
6892 SourceLocation &OpenLoc,
6893 SourceLocation &CloseLoc,
6894 SmallVectorImpl<Expr *> &Exprs,
6895 bool ReqIntConst =
false);
6910 OMPClause *ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind);
6913 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
6944 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6951 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
6958 bool IsAddressOfOperand =
false);
6962 SemaOpenMP::OpenMPVarListDataTy &
Data,
6963 const LangOptions &LangOpts);
6966 SmallVectorImpl<Expr *> &Vars,
6967 SemaOpenMP::OpenMPVarListDataTy &
Data);
7002 std::unique_ptr<PragmaHandler> AlignHandler;
7003 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
7004 std::unique_ptr<PragmaHandler> OptionsHandler;
7005 std::unique_ptr<PragmaHandler> PackHandler;
7006 std::unique_ptr<PragmaHandler> MSStructHandler;
7007 std::unique_ptr<PragmaHandler> UnusedHandler;
7008 std::unique_ptr<PragmaHandler> WeakHandler;
7009 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
7010 std::unique_ptr<PragmaHandler> FPContractHandler;
7011 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
7012 std::unique_ptr<PragmaHandler> OpenMPHandler;
7013 std::unique_ptr<PragmaHandler> OpenACCHandler;
7014 std::unique_ptr<PragmaHandler> PCSectionHandler;
7015 std::unique_ptr<PragmaHandler> MSCommentHandler;
7016 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
7017 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
7018 std::unique_ptr<PragmaHandler> FloatControlHandler;
7019 std::unique_ptr<PragmaHandler> MSPointersToMembers;
7020 std::unique_ptr<PragmaHandler> MSVtorDisp;
7021 std::unique_ptr<PragmaHandler> MSInitSeg;
7022 std::unique_ptr<PragmaHandler> MSDataSeg;
7023 std::unique_ptr<PragmaHandler> MSBSSSeg;
7024 std::unique_ptr<PragmaHandler> MSConstSeg;
7025 std::unique_ptr<PragmaHandler> MSCodeSeg;
7026 std::unique_ptr<PragmaHandler> MSSection;
7027 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
7028 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
7029 std::unique_ptr<PragmaHandler> MSIntrinsic;
7030 std::unique_ptr<PragmaHandler> MSFunction;
7031 std::unique_ptr<PragmaHandler> MSOptimize;
7032 std::unique_ptr<PragmaHandler> MSFenvAccess;
7033 std::unique_ptr<PragmaHandler> MSAllocText;
7034 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
7035 std::unique_ptr<PragmaHandler> OptimizeHandler;
7036 std::unique_ptr<PragmaHandler> LoopHintHandler;
7037 std::unique_ptr<PragmaHandler> UnrollHintHandler;
7038 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
7039 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
7040 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
7041 std::unique_ptr<PragmaHandler> FPHandler;
7042 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
7043 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
7044 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
7045 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
7046 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
7047 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
7048 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
7049 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7052 void initializePragmaHandlers();
7055 void resetPragmaHandlers();
7062 void HandlePragmaUnused();
7066 void HandlePragmaVisibility();
7070 void HandlePragmaPack();
7074 void HandlePragmaMSStruct();
7076 void HandlePragmaMSPointersToMembers();
7078 void HandlePragmaMSVtorDisp();
7080 void HandlePragmaMSPragma();
7081 bool HandlePragmaMSSection(StringRef PragmaName,
7082 SourceLocation PragmaLocation);
7083 bool HandlePragmaMSSegment(StringRef PragmaName,
7084 SourceLocation PragmaLocation);
7087 bool HandlePragmaMSInitSeg(StringRef PragmaName,
7088 SourceLocation PragmaLocation);
7093 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
7094 SourceLocation PragmaLocation);
7095 bool HandlePragmaMSFunction(StringRef PragmaName,
7096 SourceLocation PragmaLocation);
7097 bool HandlePragmaMSAllocText(StringRef PragmaName,
7098 SourceLocation PragmaLocation);
7101 bool HandlePragmaMSOptimize(StringRef PragmaName,
7102 SourceLocation PragmaLocation);
7105 bool HandlePragmaMSIntrinsic(StringRef PragmaName,
7106 SourceLocation PragmaLocation);
7110 void HandlePragmaAlign();
7114 void HandlePragmaDump();
7118 void HandlePragmaWeak();
7122 void HandlePragmaWeakAlias();
7126 void HandlePragmaRedefineExtname();
7130 void HandlePragmaFPContract();
7134 void HandlePragmaFEnvAccess();
7138 void HandlePragmaFEnvRound();
7142 void HandlePragmaCXLimitedRange();
7146 void HandlePragmaFloatControl();
7150 void HandlePragmaFP();
7154 void HandlePragmaOpenCLExtension();
7158 StmtResult HandlePragmaCaptured();
7162 bool HandlePragmaLoopHint(LoopHint &Hint);
7164 bool ParsePragmaAttributeSubjectMatchRuleSet(
7166 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
7168 void HandlePragmaAttribute();
7194 enum class ParsedStmtContext {
7197 AllowDeclarationsInC = 0x1,
7199 AllowStandaloneOpenMPDirectives = 0x2,
7206 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
7223 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt,
7278 ParseStatementOrDeclaration(
StmtVector &Stmts, ParsedStmtContext StmtCtx,
7282 StmtResult ParseStatementOrDeclarationAfterAttributes(
7283 StmtVector &Stmts, ParsedStmtContext StmtCtx,
7288 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
7302 ParsedStmtContext StmtCtx);
7311 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
7312 bool MissingCase =
false,
7322 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
7324 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
7350 StmtResult ParseCompoundStatement(
bool isStmtExpr,
unsigned ScopeFlags);
7355 void ParseCompoundStatementLeadingPragmas();
7357 void DiagnoseLabelAtEndOfCompoundStatement();
7367 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
7385 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
7501 StmtResult ParseBreakOrContinueStatement(
bool IsContinue);
7508 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
7555 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
7593 Decl *ParseFunctionStatementBody(
Decl *
Decl, ParseScope &BodyScope);
7602 Decl *ParseFunctionTryBlock(
Decl *
Decl, ParseScope &BodyScope);
7608 bool trySkippingFunctionBody();
7616 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
7618 return isCXXDeclarationStatement(DisambiguatingWithExpression);
7626 bool isForInitDeclaration() {
7630 return Tok.is(tok::kw_using) ||
7631 isCXXSimpleDeclaration(
true);
7636 bool isForRangeIdentifier();
7653 unsigned &NumLineToksConsumed,
7654 bool IsUnevaluated);
7697 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
7713 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
7714 SmallVectorImpl<Expr *> &Constraints,
7715 SmallVectorImpl<Expr *> &Exprs);
7717 class GNUAsmQualifiers {
7718 unsigned Qualifiers = AQ_unspecified;
7727 static const char *getQualifierName(AQ Qualifier);
7728 bool setAsmQualifier(AQ Qualifier);
7729 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
7730 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
7731 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
7735 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
7737 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
7738 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
7751 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
7775 unsigned TemplateParameterDepth;
7778 class TemplateParameterDepthRAII {
7780 unsigned AddedLevels;
7783 explicit TemplateParameterDepthRAII(
unsigned &Depth)
7784 : Depth(Depth), AddedLevels(0) {}
7786 ~TemplateParameterDepthRAII() { Depth -= AddedLevels; }
7792 void addDepth(
unsigned D) {
7796 void setAddedDepth(
unsigned D) {
7797 Depth = Depth - AddedLevels + D;
7801 unsigned getDepth()
const {
return Depth; }
7802 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
7807 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
7813 bool DelayTemplateIdDestruction =
false;
7815 void MaybeDestroyTemplateIds() {
7816 if (DelayTemplateIdDestruction)
7818 if (!TemplateIds.empty() &&
7819 (Tok.is(tok::eof) || !PP.mightHavePendingAnnotationTokens()))
7820 DestroyTemplateIds();
7822 void DestroyTemplateIds();
7826 struct DestroyTemplateIdAnnotationsRAIIObj {
7829 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
7830 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
7833 struct DelayTemplateIdDestructionRAII {
7835 bool PrevDelayTemplateIdDestruction;
7837 DelayTemplateIdDestructionRAII(
Parser &Self,
7838 bool DelayTemplateIdDestruction) noexcept
7840 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
7841 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
7844 ~DelayTemplateIdDestructionRAII() noexcept {
7845 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
7850 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
7862 struct AngleBracketTracker {
7865 enum Priority :
unsigned short {
7867 PotentialTypo = 0x0,
7869 DependentName = 0x2,
7872 SpaceBeforeLess = 0x0,
7874 NoSpaceBeforeLess = 0x1,
7905 if (!Locs.empty() && Locs.back().isActive(P)) {
7906 if (Locs.back().Priority <= Prio) {
7908 Locs.back().LessLoc = LessLoc;
7909 Locs.back().Priority = Prio;
7912 Locs.push_back({
TemplateName, LessLoc, Prio, P.ParenCount,
7913 P.BracketCount, P.BraceCount});
7921 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
7928 if (!Locs.empty() && Locs.back().isActive(P))
7929 return &Locs.back();
7934 AngleBracketTracker AngleBrackets;
7939 struct ParsedTemplateInfo {
7940 ParsedTemplateInfo()
7944 bool isSpecialization,
7945 bool lastParameterListWasEmpty =
false)
7948 TemplateParams(TemplateParams),
7949 LastParameterListWasEmpty(lastParameterListWasEmpty) {}
7951 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
7952 SourceLocation TemplateLoc)
7954 TemplateParams(
nullptr), ExternLoc(ExternLoc),
7955 TemplateLoc(TemplateLoc), LastParameterListWasEmpty(
false) {}
7965 SourceLocation ExternLoc;
7969 SourceLocation TemplateLoc;
7972 bool LastParameterListWasEmpty;
7974 SourceRange getSourceRange() const LLVM_READONLY;
7978 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
7981 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
7983 static
void LateTemplateParserCallback(
void *P, LateParsedTemplate &LPT);
7991 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
7992 bool checkPotentialAngleBracketDelimiter(const AngleBracketTracker::Loc &,
7993 const Token &OpToken);
7994 bool checkPotentialAngleBracketDelimiter(const Token &OpToken) {
7995 if (
auto *Info = AngleBrackets.getCurrent(*
this))
7996 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
8007 SourceLocation &DeclEnd,
8008 ParsedAttributes &AccessAttrs);
8055 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
8067 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
8068 SmallVectorImpl<NamedDecl *> &TemplateParams,
8069 SourceLocation &LAngleLoc,
8070 SourceLocation &RAngleLoc);
8082 bool ParseTemplateParameterList(
unsigned Depth,
8083 SmallVectorImpl<NamedDecl *> &TemplateParams);
8085 enum class TPResult;
8089 TPResult isStartOfTemplateTypeParameter();
8113 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
8126 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
8142 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
8152 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
8156 bool isTypeConstraintAnnotation();
8168 bool TryAnnotateTypeConstraint();
8170 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
8171 SourceLocation CorrectLoc,
8172 bool AlreadyHasEllipsis,
8173 bool IdentifierHasName);
8174 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
8177 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
8194 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
8195 SourceLocation &RAngleLoc,
8196 bool ConsumeLastToken,
8197 bool ObjCGenericList);
8210 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
8211 SourceLocation &LAngleLoc,
8212 TemplateArgList &TemplateArgs,
8213 SourceLocation &RAngleLoc,
8258 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8260 bool AllowTypeAnnotation =
true,
8261 bool TypeConstraint =
false);
8279 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
8281 bool IsClassName =
false);
8293 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
8297 ParsedTemplateArgument ParseTemplateTemplateArgument();
8309 ParsedTemplateArgument ParseTemplateArgument();
8321 SourceLocation ExternLoc,
8322 SourceLocation TemplateLoc,
8323 SourceLocation &DeclEnd,
8324 ParsedAttributes &AccessAttrs,
8333 Decl *ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
8334 SourceLocation &DeclEnd);
8362 class TentativeParsingAction {
8364 PreferredTypeBuilder PrevPreferredType;
8366 size_t PrevTentativelyDeclaredIdentifierCount;
8367 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
8371 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
8372 : P(p), PrevPreferredType(P.PreferredType) {
8374 PrevTentativelyDeclaredIdentifierCount =
8375 P.TentativelyDeclaredIdentifiers.size();
8376 PrevParenCount = P.ParenCount;
8377 PrevBracketCount = P.BracketCount;
8378 PrevBraceCount = P.BraceCount;
8379 P.PP.EnableBacktrackAtThisPos(Unannotated);
8383 assert(isActive &&
"Parsing action was finished!");
8384 P.TentativelyDeclaredIdentifiers.resize(
8385 PrevTentativelyDeclaredIdentifierCount);
8386 P.PP.CommitBacktrackedTokens();
8390 assert(isActive &&
"Parsing action was finished!");
8392 P.PreferredType = PrevPreferredType;
8394 P.TentativelyDeclaredIdentifiers.resize(
8395 PrevTentativelyDeclaredIdentifierCount);
8396 P.ParenCount = PrevParenCount;
8397 P.BracketCount = PrevBracketCount;
8398 P.BraceCount = PrevBraceCount;
8401 ~TentativeParsingAction() {
8402 assert(!isActive &&
"Forgot to call Commit or Revert!");
8408 class RevertingTentativeParsingAction
8409 :
private Parser::TentativeParsingAction {
8411 using TentativeParsingAction::TentativeParsingAction;
8413 ~RevertingTentativeParsingAction() { Revert(); }
8448 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
8474 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
8487 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
8491 struct ConditionDeclarationOrInitStatementState;
8492 enum class ConditionOrInitStatement {
8519 ConditionOrInitStatement
8520 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
8521 bool CanBeForRangeDecl);
8547 return isCXXTypeId(Context, isAmbiguous);
8561 bool isEnumBase(
bool AllowSemi);
8681 TPResult BracedCastResult = TPResult::False,
8682 bool *InvalidAsDeclSpec =
nullptr);
8687 bool isCXXDeclarationSpecifierAType();
8693 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
8698 TPResult isExplicitBool();
8703 bool isTentativelyDeclared(IdentifierInfo *II);
8722 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
8730 TPResult TryParseTypeofSpecifier();
8734 TPResult TryParseProtocolQualifiers();
8736 TPResult TryParsePtrOperatorSeq();
8758 TPResult TryParseOperatorId();
8789 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
8846 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
8847 bool mayHaveDirectInit =
false,
8848 bool mayHaveTrailingReturnType =
false);
8869 TPResult TryParseParameterDeclarationClause(
8870 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
8887 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
8893 bool NameAfterArrowIsNonType();
8899 TPResult TryParseBracketDeclarator();
8903 TPResult TryConsumeDeclarationSpecifier();
8907 bool TrySkipAttributes();
8949 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
8950 bool OuterMightBeMessageSend =
false);