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;
569 std::unique_ptr<CommentHandler> CommentSemaHandler;
574 bool CalledSignatureHelp =
false;
582 bool SkipFunctionBodies;
589 bool isTokenParen()
const {
return Tok.isOneOf(tok::l_paren, tok::r_paren); }
591 bool isTokenBracket()
const {
592 return Tok.isOneOf(tok::l_square, tok::r_square);
595 bool isTokenBrace()
const {
return Tok.isOneOf(tok::l_brace, tok::r_brace); }
597 bool isTokenStringLiteral()
const {
601 bool isTokenSpecial()
const {
602 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
603 isTokenBrace() || Tok.is(tok::code_completion) || Tok.isAnnotation();
608 bool isTokenEqualOrEqualTypo();
612 void UnconsumeToken(Token &Consumed) {
614 PP.EnterToken(Consumed,
true);
616 PP.EnterToken(
Next,
true);
619 SourceLocation ConsumeAnnotationToken() {
620 assert(Tok.isAnnotation() &&
"wrong consume method");
621 SourceLocation Loc = Tok.getLocation();
622 PrevTokLocation = Tok.getAnnotationEndLoc();
629 SourceLocation ConsumeParen() {
630 assert(isTokenParen() &&
"wrong consume method");
631 if (Tok.getKind() == tok::l_paren)
633 else if (ParenCount) {
634 AngleBrackets.clear(*
this);
637 PrevTokLocation = Tok.getLocation();
639 return PrevTokLocation;
644 SourceLocation ConsumeBracket() {
645 assert(isTokenBracket() &&
"wrong consume method");
646 if (Tok.getKind() == tok::l_square)
648 else if (BracketCount) {
649 AngleBrackets.clear(*
this);
653 PrevTokLocation = Tok.getLocation();
655 return PrevTokLocation;
660 SourceLocation ConsumeBrace() {
661 assert(isTokenBrace() &&
"wrong consume method");
662 if (Tok.getKind() == tok::l_brace)
664 else if (BraceCount) {
665 AngleBrackets.clear(*
this);
669 PrevTokLocation = Tok.getLocation();
671 return PrevTokLocation;
678 SourceLocation ConsumeStringToken() {
679 assert(isTokenStringLiteral() &&
680 "Should only consume string literals with this method");
681 PrevTokLocation = Tok.getLocation();
683 return PrevTokLocation;
691 SourceLocation ConsumeCodeCompletionToken() {
692 assert(Tok.is(tok::code_completion));
693 PrevTokLocation = Tok.getLocation();
695 return PrevTokLocation;
703 SourceLocation handleUnexpectedCodeCompletionToken();
707 void cutOffParsing() {
708 if (PP.isCodeCompletionEnabled())
709 PP.setCodeCompletionReached();
711 Tok.setKind(tok::eof);
718 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
719 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
720 Kind == tok::annot_repl_input_end;
723 static void setTypeAnnotation(Token &Tok,
TypeResult T) {
724 assert((
T.isInvalid() ||
T.get()) &&
725 "produced a valid-but-null type annotation?");
726 Tok.setAnnotationValue(
T.isInvalid() ?
nullptr :
T.get().getAsOpaquePtr());
729 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
730 return static_cast<NamedDecl *
>(Tok.getAnnotationValue());
733 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
734 Tok.setAnnotationValue(ND);
737 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
738 return static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
741 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
742 Tok.setAnnotationValue(ND);
747 static ExprResult getExprAnnotation(
const Token &Tok) {
748 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
753 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
754 Tok.setAnnotationValue(ER.getAsOpaquePointer());
768 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
773 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
780 bool TryKeywordIdentFallback(
bool DisableKeyword);
785 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
796 unsigned Diag = diag::err_expected,
797 StringRef DiagMsg =
"");
804 bool ExpectAndConsumeSemi(
unsigned DiagID, StringRef TokenUsed =
"");
815 bool expectIdentifier();
818 enum class CompoundToken {
833 void checkCompoundToken(SourceLocation FirstTokLoc,
836 void diagnoseUseOfC11Keyword(
const Token &Tok);
839 class ParseScopeFlags {
841 unsigned OldFlags = 0;
842 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
843 void operator=(
const ParseScopeFlags &) =
delete;
848 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
862 void SuggestParentheses(SourceLocation Loc,
unsigned DK,
863 SourceRange ParenRange);
899 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
900 ParsedAttributes &DeclSpecAttrs,
901 ParsingDeclSpec *DS =
nullptr);
905 bool isDeclarationAfterDeclarator();
909 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
912 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
933 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
934 ParsedAttributes &DeclSpecAttrs,
938 void SkipFunctionBody();
940 struct ParsedTemplateInfo;
941 class LateParsedAttrList;
959 Decl *ParseFunctionDefinition(
960 ParsingDeclarator &D,
961 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
962 LateParsedAttrList *LateParsedAttrs =
nullptr);
966 void ParseKNRParamDeclarations(Declarator &D);
976 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
989 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
993 struct IfExistsCondition {
995 SourceLocation KeywordLoc;
1011 bool ParseMicrosoftIfExistsCondition(IfExistsCondition &
Result);
1012 void ParseMicrosoftIfExistsExternalDeclaration();
1051 Decl *ParseModuleImport(SourceLocation AtLoc,
1058 bool parseMisplacedModuleImport();
1060 bool tryParseMisplacedModuleImport() {
1062 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
1063 Kind == tok::annot_module_include)
1064 return parseMisplacedModuleImport();
1077 bool ParseModuleName(SourceLocation UseLoc,
1078 SmallVectorImpl<IdentifierLoc> &Path,
bool IsImport);
1081 void DiagnoseInvalidCXXModuleImport();
1085 void CodeCompleteDirective(
bool InConditional)
override;
1087 void CodeCompleteMacroName(
bool IsDefinition)
override;
1089 void CodeCompleteMacroArgument(IdentifierInfo *
Macro, MacroInfo *MacroInfo,
1090 unsigned ArgumentIndex)
override;
1091 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
1093 void CodeCompleteModuleImport(SourceLocation ImportLoc,
1109 struct ParsingClass;
1119 class LateParsedDeclaration {
1121 virtual ~LateParsedDeclaration();
1123 virtual void ParseLexedMethodDeclarations();
1124 virtual void ParseLexedMemberInitializers();
1125 virtual void ParseLexedMethodDefs();
1126 virtual void ParseLexedAttributes();
1127 virtual void ParseLexedPragmas();
1132 class LateParsedClass :
public LateParsedDeclaration {
1134 LateParsedClass(
Parser *P, ParsingClass *
C);
1135 ~LateParsedClass()
override;
1137 void ParseLexedMethodDeclarations()
override;
1138 void ParseLexedMemberInitializers()
override;
1139 void ParseLexedMethodDefs()
override;
1140 void ParseLexedAttributes()
override;
1141 void ParseLexedPragmas()
override;
1144 LateParsedClass(
const LateParsedClass &) =
delete;
1145 LateParsedClass &operator=(
const LateParsedClass &) =
delete;
1149 ParsingClass *Class;
1158 struct LateParsedAttribute :
public LateParsedDeclaration {
1161 IdentifierInfo &AttrName;
1162 IdentifierInfo *MacroII =
nullptr;
1163 SourceLocation AttrNameLoc;
1164 SmallVector<Decl *, 2> Decls;
1166 explicit LateParsedAttribute(
Parser *P, IdentifierInfo &Name,
1168 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1170 void ParseLexedAttributes()
override;
1172 void addDecl(Decl *D) { Decls.push_back(D); }
1179 class LateParsedPragma :
public LateParsedDeclaration {
1186 : Self(P), AS(AS) {}
1188 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1192 void ParseLexedPragmas()
override;
1196 class LateParsedAttrList :
public SmallVector<LateParsedAttribute *, 2> {
1198 LateParsedAttrList(
bool PSoon =
false,
1199 bool LateAttrParseExperimentalExtOnly =
false)
1201 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1203 bool parseSoon() {
return ParseSoon; }
1206 bool lateAttrParseExperimentalExtOnly() {
1207 return LateAttrParseExperimentalExtOnly;
1212 bool LateAttrParseExperimentalExtOnly;
1218 struct LexedMethod :
public LateParsedDeclaration {
1223 explicit LexedMethod(
Parser *P, Decl *MD) : Self(P), D(MD) {}
1225 void ParseLexedMethodDefs()
override;
1232 struct LateParsedDefaultArgument {
1233 explicit LateParsedDefaultArgument(
1234 Decl *P, std::unique_ptr<CachedTokens> Toks =
nullptr)
1235 : Param(P), Toks(std::move(Toks)) {}
1244 std::unique_ptr<CachedTokens> Toks;
1251 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1252 explicit LateParsedMethodDeclaration(
Parser *P, Decl *M)
1253 : Self(P), Method(M), ExceptionSpecTokens(
nullptr) {}
1255 void ParseLexedMethodDeclarations()
override;
1267 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1277 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1278 LateParsedMemberInitializer(
Parser *P, Decl *FD) : Self(P), Field(FD) {}
1280 void ParseLexedMemberInitializers()
override;
1298 typedef SmallVector<LateParsedDeclaration *, 2>
1299 LateParsedDeclarationsContainer;
1313 const ParsedAttributesView &AccessAttrs,
1314 ParsingDeclarator &D,
1315 const ParsedTemplateInfo &TemplateInfo,
1316 const VirtSpecifiers &VS,
1317 SourceLocation PureSpecLoc);
1320 StringLiteral *ParseCXXDeletedFunctionMessage();
1325 void SkipDeletedFunctionBody();
1331 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1335 void ParseLexedAttributes(ParsingClass &
Class);
1338 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1346 void ParseLexedAttribute(LateParsedAttribute &LA,
bool EnterScope,
1353 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1354 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1359 void ParseLexedMethodDefs(ParsingClass &
Class);
1360 void ParseLexedMethodDef(LexedMethod &LM);
1366 void ParseLexedMemberInitializers(ParsingClass &
Class);
1367 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1401 ParsedAttributes *Attrs =
nullptr);
1407 IdentifierInfo *Ident_vector;
1408 IdentifierInfo *Ident_bool;
1409 IdentifierInfo *Ident_Bool;
1413 IdentifierInfo *Ident_pixel;
1416 IdentifierInfo *Ident_introduced;
1419 IdentifierInfo *Ident_deprecated;
1422 IdentifierInfo *Ident_obsoleted;
1425 IdentifierInfo *Ident_unavailable;
1428 IdentifierInfo *Ident_message;
1431 IdentifierInfo *Ident_strict;
1434 IdentifierInfo *Ident_replacement;
1437 IdentifierInfo *Ident_environment;
1440 IdentifierInfo *Ident_language, *Ident_defined_in,
1441 *Ident_generated_declaration, *Ident_USR;
1444 AttributeFactory AttrFactory;
1449 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
const char *&PrevSpec,
1454 if (Tok.getIdentifierInfo() != Ident_vector &&
1455 Tok.getIdentifierInfo() != Ident_bool &&
1456 Tok.getIdentifierInfo() != Ident_Bool &&
1457 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
1460 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
1466 bool TryAltiVecVectorToken() {
1468 Tok.getIdentifierInfo() != Ident_vector)
1470 return TryAltiVecVectorTokenOutOfLine();
1475 bool TryAltiVecVectorTokenOutOfLine();
1476 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
1477 const char *&PrevSpec,
unsigned &DiagID,
1480 void ParseLexedCAttributeList(LateParsedAttrList &LA,
bool EnterScope,
1481 ParsedAttributes *OutAttrs =
nullptr);
1488 void ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
1489 ParsedAttributes *OutAttrs =
nullptr);
1491 void ParseLexedPragmas(ParsingClass &
Class);
1492 void ParseLexedPragma(LateParsedPragma &LP);
1500 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1516 bool ConsumeFinalToken =
true) {
1517 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1528 bool ConsumeFinalToken =
true);
1536 enum class DeclSpecContext {
1541 DSC_alias_declaration,
1546 DSC_template_type_arg,
1547 DSC_objc_method_result,
1556 static bool isTypeSpecifier(DeclSpecContext DSC) {
1558 case DeclSpecContext::DSC_normal:
1559 case DeclSpecContext::DSC_template_param:
1560 case DeclSpecContext::DSC_template_arg:
1561 case DeclSpecContext::DSC_class:
1562 case DeclSpecContext::DSC_top_level:
1563 case DeclSpecContext::DSC_objc_method_result:
1564 case DeclSpecContext::DSC_condition:
1567 case DeclSpecContext::DSC_template_type_arg:
1568 case DeclSpecContext::DSC_type_specifier:
1569 case DeclSpecContext::DSC_conv_operator:
1570 case DeclSpecContext::DSC_trailing:
1571 case DeclSpecContext::DSC_alias_declaration:
1572 case DeclSpecContext::DSC_association:
1573 case DeclSpecContext::DSC_new:
1576 llvm_unreachable(
"Missing DeclSpecContext case");
1580 enum class AllowDefiningTypeSpec {
1597 static AllowDefiningTypeSpec
1598 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
1600 case DeclSpecContext::DSC_normal:
1601 case DeclSpecContext::DSC_class:
1602 case DeclSpecContext::DSC_top_level:
1603 case DeclSpecContext::DSC_alias_declaration:
1604 case DeclSpecContext::DSC_objc_method_result:
1605 return AllowDefiningTypeSpec::Yes;
1607 case DeclSpecContext::DSC_condition:
1608 case DeclSpecContext::DSC_template_param:
1609 return AllowDefiningTypeSpec::YesButInvalid;
1611 case DeclSpecContext::DSC_template_type_arg:
1612 case DeclSpecContext::DSC_type_specifier:
1613 return AllowDefiningTypeSpec::NoButErrorRecovery;
1615 case DeclSpecContext::DSC_association:
1616 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
1617 : AllowDefiningTypeSpec::Yes;
1619 case DeclSpecContext::DSC_trailing:
1620 case DeclSpecContext::DSC_conv_operator:
1621 case DeclSpecContext::DSC_template_arg:
1622 case DeclSpecContext::DSC_new:
1623 return AllowDefiningTypeSpec::No;
1625 llvm_unreachable(
"Missing DeclSpecContext case");
1629 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
1631 case DeclSpecContext::DSC_normal:
1632 case DeclSpecContext::DSC_class:
1633 case DeclSpecContext::DSC_top_level:
1636 case DeclSpecContext::DSC_alias_declaration:
1637 case DeclSpecContext::DSC_objc_method_result:
1638 case DeclSpecContext::DSC_condition:
1639 case DeclSpecContext::DSC_template_param:
1640 case DeclSpecContext::DSC_template_type_arg:
1641 case DeclSpecContext::DSC_type_specifier:
1642 case DeclSpecContext::DSC_trailing:
1643 case DeclSpecContext::DSC_association:
1644 case DeclSpecContext::DSC_conv_operator:
1645 case DeclSpecContext::DSC_template_arg:
1646 case DeclSpecContext::DSC_new:
1650 llvm_unreachable(
"Missing DeclSpecContext case");
1655 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
1657 case DeclSpecContext::DSC_normal:
1658 case DeclSpecContext::DSC_template_param:
1659 case DeclSpecContext::DSC_template_arg:
1660 case DeclSpecContext::DSC_class:
1661 case DeclSpecContext::DSC_top_level:
1662 case DeclSpecContext::DSC_condition:
1663 case DeclSpecContext::DSC_type_specifier:
1664 case DeclSpecContext::DSC_association:
1665 case DeclSpecContext::DSC_conv_operator:
1666 case DeclSpecContext::DSC_new:
1669 case DeclSpecContext::DSC_objc_method_result:
1670 case DeclSpecContext::DSC_template_type_arg:
1671 case DeclSpecContext::DSC_trailing:
1672 case DeclSpecContext::DSC_alias_declaration:
1675 llvm_unreachable(
"Missing DeclSpecContext case");
1680 getImplicitTypenameContext(DeclSpecContext DSC) {
1682 case DeclSpecContext::DSC_class:
1683 case DeclSpecContext::DSC_top_level:
1684 case DeclSpecContext::DSC_type_specifier:
1685 case DeclSpecContext::DSC_template_type_arg:
1686 case DeclSpecContext::DSC_trailing:
1687 case DeclSpecContext::DSC_alias_declaration:
1688 case DeclSpecContext::DSC_template_param:
1689 case DeclSpecContext::DSC_new:
1692 case DeclSpecContext::DSC_normal:
1693 case DeclSpecContext::DSC_objc_method_result:
1694 case DeclSpecContext::DSC_condition:
1695 case DeclSpecContext::DSC_template_arg:
1696 case DeclSpecContext::DSC_conv_operator:
1697 case DeclSpecContext::DSC_association:
1700 llvm_unreachable(
"Missing DeclSpecContext case");
1705 struct ForRangeInit {
1706 SourceLocation ColonLoc;
1708 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
1709 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
1711 struct ForRangeInfo : ForRangeInit {
1734 SourceLocation &DeclEnd,
1735 ParsedAttributes &DeclAttrs,
1736 ParsedAttributes &DeclSpecAttrs,
1737 SourceLocation *DeclSpecStart =
nullptr);
1764 ParsedAttributes &DeclAttrs,
1765 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
1766 ForRangeInit *FRI =
nullptr,
1767 SourceLocation *DeclSpecStart =
nullptr);
1777 ParsedAttributes &Attrs,
1778 ParsedTemplateInfo &TemplateInfo,
1779 SourceLocation *DeclEnd =
nullptr,
1780 ForRangeInit *FRI =
nullptr);
1806 Decl *ParseDeclarationAfterDeclarator(
1808 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1812 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
1813 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
1815 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1816 ForRangeInit *FRI =
nullptr);
1827 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
1829 DeclSpecContext DSC, ParsedAttributes &Attrs);
1839 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1841 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
1842 LateParsedAttrList *LateAttrs =
nullptr) {
1843 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
1844 getImplicitTypenameContext(DSC));
1877 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1879 LateParsedAttrList *LateAttrs,
1889 bool DiagnoseMissingSemiAfterTagDefinition(
1891 LateParsedAttrList *LateAttrs =
nullptr);
1893 void ParseSpecifierQualifierList(
1895 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
1896 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
1907 void ParseSpecifierQualifierList(
1910 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
1944 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
1945 const ParsedTemplateInfo &TemplateInfo,
1960 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
1961 SkipBodyInfo *SkipBody =
nullptr);
1975 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
1976 RecordDecl *TagDecl);
2001 void ParseStructDeclaration(
2002 ParsingDeclSpec &DS,
2003 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2004 LateParsedAttrList *LateFieldAttrs =
nullptr);
2016 bool DisambiguatingWithExpression =
false);
2020 bool isTypeSpecifierQualifier();
2025 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2030 bool isConstructorDeclarator(
2033 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2037 void DiagnoseBitIntUse(
const Token &Tok);
2041 bool CheckProhibitedCXX11Attribute() {
2042 assert(Tok.is(tok::l_square));
2045 return DiagnoseProhibitedCXX11Attribute();
2056 bool DiagnoseProhibitedCXX11Attribute();
2058 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2059 SourceLocation CorrectLocation) {
2060 if (!Tok.isRegularKeywordAttribute() &&
2061 (Tok.isNot(tok::l_square) ||
NextToken().
isNot(tok::l_square)) &&
2062 Tok.isNot(tok::kw_alignas))
2064 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2071 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2072 SourceLocation CorrectLocation);
2082 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2086 void ProhibitAttributes(ParsedAttributes &Attrs,
2087 SourceLocation FixItLoc = SourceLocation()) {
2088 if (Attrs.Range.isInvalid())
2090 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2094 void ProhibitAttributes(ParsedAttributesView &Attrs,
2095 SourceLocation FixItLoc = SourceLocation()) {
2096 if (Attrs.Range.isInvalid())
2098 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2099 Attrs.clearListOnly();
2101 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2102 SourceLocation FixItLoc);
2110 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2111 unsigned KeywordDiagId,
2112 bool DiagnoseEmptyAttrs =
false,
2113 bool WarnOnUnknownAttrs =
false);
2117 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2119 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2126 bool ParseAttributeArgumentList(
2127 const IdentifierInfo &AttrName, SmallVectorImpl<Expr *> &Exprs,
2128 ParsedAttributeArgumentsProperties ArgsProperties,
unsigned Arg);
2135 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2136 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2137 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2138 ParsedAttr::Form Form);
2140 enum ParseAttrKindMask {
2142 PAKM_Declspec = 1 << 1,
2143 PAKM_CXX11 = 1 << 2,
2162 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2163 LateParsedAttrList *LateAttrs =
nullptr);
2166 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2167 LateParsedAttrList *LateAttrs =
nullptr) {
2168 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2169 isAllowedCXX11AttributeSpecifier()) {
2170 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2176 void MaybeParseGNUAttributes(Declarator &D,
2177 LateParsedAttrList *LateAttrs =
nullptr) {
2178 if (Tok.is(tok::kw___attribute)) {
2179 ParsedAttributes Attrs(AttrFactory);
2180 ParseGNUAttributes(Attrs, LateAttrs, &D);
2181 D.takeAttributesAppending(Attrs);
2185 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2186 LateParsedAttrList *LateAttrs =
nullptr) {
2187 if (Tok.is(tok::kw___attribute)) {
2188 ParseGNUAttributes(Attrs, LateAttrs);
2210 bool ParseSingleGNUAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc,
2211 LateParsedAttrList *LateAttrs =
nullptr,
2212 Declarator *D =
nullptr);
2257 void ParseGNUAttributes(ParsedAttributes &Attrs,
2258 LateParsedAttrList *LateAttrs =
nullptr,
2259 Declarator *D =
nullptr);
2263 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2264 SourceLocation AttrNameLoc,
2265 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2266 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2267 ParsedAttr::Form Form, Declarator *D);
2268 IdentifierLoc *ParseIdentifierLoc();
2271 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2272 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2273 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2274 ParsedAttr::Form Form);
2276 void MaybeParseCXX11Attributes(Declarator &D) {
2277 if (isAllowedCXX11AttributeSpecifier()) {
2278 ParsedAttributes Attrs(AttrFactory);
2279 ParseCXX11Attributes(Attrs);
2280 D.takeAttributesAppending(Attrs);
2284 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2285 bool OuterMightBeMessageSend =
false) {
2286 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2287 ParseCXX11Attributes(Attrs);
2293 bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2294 bool AttrsParsed =
false;
2296 Tok.is(tok::l_square)) {
2297 ParsedAttributes AttrsWithRange(AttrFactory);
2298 ParseMicrosoftAttributes(AttrsWithRange);
2299 AttrsParsed = !AttrsWithRange.empty();
2300 Attrs.takeAllAppendingFrom(AttrsWithRange);
2304 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
2305 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
2306 ParseMicrosoftDeclSpecs(Attrs);
2320 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
2321 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
2322 SourceLocation AttrNameLoc,
2323 ParsedAttributes &Attrs);
2324 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
2325 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
2326 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2327 SourceLocation SkipExtendedMicrosoftTypeAttributes();
2329 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
2330 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
2331 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
2332 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
2333 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
2334 bool isHLSLQualifier(
const Token &Tok)
const;
2335 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
2347 VersionTuple ParseVersionTuple(SourceRange &Range);
2376 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
2377 SourceLocation AvailabilityLoc,
2378 ParsedAttributes &attrs,
2379 SourceLocation *endLoc,
2380 IdentifierInfo *ScopeName,
2381 SourceLocation ScopeLoc,
2382 ParsedAttr::Form Form);
2400 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
2402 ParsedAttributes &Attrs,
2403 SourceLocation *EndLoc,
2404 IdentifierInfo *ScopeName,
2405 SourceLocation ScopeLoc,
2406 ParsedAttr::Form Form);
2421 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
2422 SourceLocation ObjCBridgeRelatedLoc,
2423 ParsedAttributes &Attrs,
2424 SourceLocation *EndLoc,
2425 IdentifierInfo *ScopeName,
2426 SourceLocation ScopeLoc,
2427 ParsedAttr::Form Form);
2429 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
2430 SourceLocation AttrNameLoc,
2431 ParsedAttributes &Attrs,
2432 SourceLocation *EndLoc,
2433 IdentifierInfo *ScopeName,
2434 SourceLocation ScopeLoc,
2435 ParsedAttr::Form Form);
2437 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
2438 SourceLocation AttrNameLoc,
2439 ParsedAttributes &Attrs,
2440 SourceLocation *EndLoc,
2441 IdentifierInfo *ScopeName,
2442 SourceLocation ScopeLoc,
2443 ParsedAttr::Form Form);
2445 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
2446 SourceLocation AttrNameLoc,
2447 ParsedAttributes &Attrs,
2448 IdentifierInfo *ScopeName,
2449 SourceLocation ScopeLoc,
2450 ParsedAttr::Form Form);
2452 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
2458 void ParseBoundsAttribute(IdentifierInfo &AttrName,
2459 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
2460 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2461 ParsedAttr::Form Form);
2477 void ParseTypeofSpecifier(DeclSpec &DS);
2484 void ParseAtomicSpecifier(DeclSpec &DS);
2494 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
2495 SourceLocation &EllipsisLoc,
bool &IsType,
2508 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
2509 SourceLocation *endLoc =
nullptr);
2518 void ParsePtrauthQualifier(ParsedAttributes &Attrs);
2523 class DeclaratorScopeObj {
2530 DeclaratorScopeObj(
Parser &p, CXXScopeSpec &ss)
2531 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2533 void EnterDeclaratorScope() {
2534 assert(!EnteredScope &&
"Already entered the scope!");
2535 assert(SS.isSet() &&
"C++ scope was not set!");
2537 CreatedScope =
true;
2540 if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS))
2541 EnteredScope =
true;
2544 ~DeclaratorScopeObj() {
2546 assert(SS.isSet() &&
"C++ scope was cleared ?");
2547 P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS);
2555 void ParseDeclarator(Declarator &D);
2586 void ParseDeclaratorInternal(Declarator &D,
2587 DirectDeclParseFunction DirectDeclParser);
2589 enum AttrRequirements {
2590 AR_NoAttributesParsed = 0,
2591 AR_GNUAttributesParsedAndRejected = 1 << 0,
2592 AR_GNUAttributesParsed = 1 << 1,
2593 AR_CXX11AttributesParsed = 1 << 2,
2594 AR_DeclspecAttributesParsed = 1 << 3,
2595 AR_AllAttributesParsed = AR_GNUAttributesParsed | AR_CXX11AttributesParsed |
2596 AR_DeclspecAttributesParsed,
2597 AR_VendorAttributesParsed =
2598 AR_GNUAttributesParsed | AR_DeclspecAttributesParsed
2615 void ParseTypeQualifierListOpt(
2616 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2617 bool AtomicOrPtrauthAllowed =
true,
bool IdentifierRequired =
false,
2618 llvm::function_ref<
void()> CodeCompletionHandler = {});
2668 void ParseDirectDeclarator(Declarator &D);
2669 void ParseDecompositionDeclarator(Declarator &D);
2687 void ParseParenDeclarator(Declarator &D);
2712 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
2714 bool IsAmbiguous,
bool RequiresArg =
false);
2715 void InitCXXThisScopeForDeclaratorIfRelevant(
2716 const Declarator &D,
const DeclSpec &DS,
2717 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
2721 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2722 SourceLocation &RefQualifierLoc);
2729 bool isFunctionDeclaratorIdentifierList();
2743 void ParseFunctionDeclaratorIdentifierList(
2744 Declarator &D, SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
2745 void ParseParameterDeclarationClause(
2746 Declarator &D, ParsedAttributes &attrs,
2747 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2748 SourceLocation &EllipsisLoc) {
2749 return ParseParameterDeclarationClause(
2750 D.getContext(), attrs, ParamInfo, EllipsisLoc,
2751 D.getCXXScopeSpec().isSet() &&
2752 D.isFunctionDeclaratorAFunctionDeclaration());
2790 void ParseParameterDeclarationClause(
2792 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2793 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
2804 void ParseBracketDeclarator(Declarator &D);
2807 void ParseMisplacedBracketDeclarator(Declarator &D);
2818 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
2819 SourceLocation IncludeLoc);
2835 mutable IdentifierInfo *Ident_sealed;
2836 mutable IdentifierInfo *Ident_abstract;
2839 mutable IdentifierInfo *Ident_final;
2840 mutable IdentifierInfo *Ident_GNU_final;
2841 mutable IdentifierInfo *Ident_override;
2846 struct ParsingClass {
2847 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
2848 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
2849 TagOrTemplate(TagOrTemplate) {}
2853 bool TopLevelClass : 1;
2856 bool IsInterface : 1;
2859 Decl *TagOrTemplate;
2864 LateParsedDeclarationsContainer LateParsedDeclarations;
2870 std::stack<ParsingClass *> ClassStack;
2872 ParsingClass &getCurrentClass() {
2873 assert(!ClassStack.empty() &&
"No lexed method stacks!");
2874 return *ClassStack.top();
2878 class ParsingClassDefinition {
2884 ParsingClassDefinition(
Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
2886 : P(P), Popped(
false),
2887 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
2892 assert(!Popped &&
"Nested class has already been popped");
2894 P.PopParsingClass(State);
2897 ~ParsingClassDefinition() {
2899 P.PopParsingClass(State);
2915 bool Delayed, SourceRange &SpecificationRange,
2916 SmallVectorImpl<ParsedType> &DynamicExceptions,
2917 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2935 ParseDynamicExceptionSpecification(SourceRange &SpecificationRange,
2936 SmallVectorImpl<ParsedType> &Exceptions,
2937 SmallVectorImpl<SourceRange> &Ranges);
2944 TypeResult ParseTrailingReturnType(SourceRange &Range,
2945 bool MayBeFollowedByDirectInit);
2948 void ParseTrailingRequiresClause(Declarator &D);
2950 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2951 ParsedAttributes &AccessAttrs,
2954 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2955 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2956 SourceLocation StartLoc,
2957 SourceLocation EndLoc);
2964 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2965 bool OuterMightBeMessageSend =
false) {
2966 return (Tok.isRegularKeywordAttribute() ||
2967 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend) !=
2974 SourceLocation SkipCXX11Attributes();
2978 void DiagnoseAndSkipCXX11Attributes();
2980 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3009 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3011 SourceLocation *EndLoc =
nullptr);
3012 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3013 SourceLocation *EndLoc =
nullptr) {
3015 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3016 ReplayOpenMPAttributeTokens(OpenMPTokens);
3025 void ParseCXX11Attributes(ParsedAttributes &attrs);
3045 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3046 SourceLocation AttrNameLoc,
3047 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3048 IdentifierInfo *ScopeName,
3049 SourceLocation ScopeLoc,
3055 ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
3056 SourceLocation AttrNameLoc,
3057 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3058 SourceLocation *EndLoc, ParsedAttr::Form Form);
3069 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3070 SourceLocation &Loc,
3073 const IdentifierInfo *EnclosingScope =
nullptr);
3076 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3088 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3090 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3091 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3100 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3101 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3102 SourceLocation StartLoc,
3103 SourceLocation EndLoc);
3116 return isCXX11VirtSpecifier(Tok);
3126 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3127 SourceLocation FriendLoc);
3131 bool isCXX11FinalKeyword()
const;
3137 bool isClassCompatibleKeyword()
const;
3139 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3142 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3174 SourceLocation &DeclEnd,
3175 SourceLocation InlineLoc = SourceLocation());
3177 struct InnerNamespaceInfo {
3178 SourceLocation NamespaceLoc;
3179 SourceLocation InlineLoc;
3180 SourceLocation IdentLoc;
3181 IdentifierInfo *Ident;
3183 using InnerNamespaceInfoList = llvm::SmallVector<InnerNamespaceInfo, 4>;
3186 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3187 unsigned int index, SourceLocation &InlineLoc,
3188 ParsedAttributes &attrs,
3220 Decl *ParseExportDeclaration();
3226 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3241 SourceLocation &DeclEnd, ParsedAttributes &attrs);
3243 struct UsingDeclarator {
3244 SourceLocation TypenameLoc;
3247 SourceLocation EllipsisLoc;
3250 TypenameLoc = EllipsisLoc = SourceLocation();
3291 const ParsedTemplateInfo &TemplateInfo,
3292 SourceLocation UsingLoc,
3293 SourceLocation &DeclEnd,
3294 ParsedAttributes &Attrs,
3296 Decl *ParseAliasDeclarationAfterDeclarator(
3297 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3299 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3312 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3317 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3318 SourceLocation AliasLoc, IdentifierInfo *Alias,
3319 SourceLocation &DeclEnd);
3327 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3371 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3372 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3374 DeclSpecContext DSC, ParsedAttributes &Attributes);
3375 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3376 SourceLocation AttrFixitLoc,
unsigned TagType,
3387 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3388 SourceLocation AttrFixitLoc,
3389 ParsedAttributes &Attrs,
unsigned TagType,
3414 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3415 SourceLocation &EqualLoc);
3419 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3422 LateParsedAttrList &LateAttrs);
3427 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3428 VirtSpecifiers &VS);
3484 ParsedTemplateInfo &TemplateInfo,
3485 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3488 ParsedAttributes &AccessAttrs,
3514 void ParseConstructorInitializer(Decl *ConstructorDecl);
3536 void HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
3564 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3565 SourceLocation &EndLocation);
3577 void ParseBaseClause(Decl *ClassDecl);
3592 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
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);
6332 llvm::omp::TraitSet
Set,
6333 llvm::omp::TraitSelector Selector,
6334 llvm::StringMap<SourceLocation> &Seen);
6338 llvm::omp::TraitSet
Set,
6339 llvm::StringMap<SourceLocation> &Seen);
6343 llvm::StringMap<SourceLocation> &Seen);
6347 llvm::omp::TraitSet
Set,
6348 llvm::StringMap<SourceLocation> &Seen);
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,
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,
6732 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6757 OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
6762 OMPClause *ParseOpenMPLoopRangeClause();
6768 OMPClause *ParseOpenMPPermutationClause();
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);
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> ExportHandler;
7045 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7048 void initializePragmaHandlers();
7051 void resetPragmaHandlers();
7058 void HandlePragmaUnused();
7062 void HandlePragmaVisibility();
7066 void HandlePragmaPack();
7070 void HandlePragmaMSStruct();
7072 void HandlePragmaMSPointersToMembers();
7074 void HandlePragmaMSVtorDisp();
7076 void HandlePragmaMSPragma();
7077 bool HandlePragmaMSSection(StringRef PragmaName,
7078 SourceLocation PragmaLocation);
7079 bool HandlePragmaMSSegment(StringRef PragmaName,
7080 SourceLocation PragmaLocation);
7083 bool HandlePragmaMSInitSeg(StringRef PragmaName,
7084 SourceLocation PragmaLocation);
7089 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
7090 SourceLocation PragmaLocation);
7091 bool HandlePragmaMSFunction(StringRef PragmaName,
7092 SourceLocation PragmaLocation);
7093 bool HandlePragmaMSAllocText(StringRef PragmaName,
7094 SourceLocation PragmaLocation);
7097 bool HandlePragmaMSOptimize(StringRef PragmaName,
7098 SourceLocation PragmaLocation);
7101 bool HandlePragmaMSIntrinsic(StringRef PragmaName,
7102 SourceLocation PragmaLocation);
7106 void HandlePragmaAlign();
7110 void HandlePragmaDump();
7114 void HandlePragmaWeak();
7118 void HandlePragmaWeakAlias();
7122 void HandlePragmaRedefineExtname();
7126 void HandlePragmaFPContract();
7130 void HandlePragmaFEnvAccess();
7134 void HandlePragmaFEnvRound();
7138 void HandlePragmaCXLimitedRange();
7142 void HandlePragmaFloatControl();
7146 void HandlePragmaFP();
7150 void HandlePragmaOpenCLExtension();
7154 StmtResult HandlePragmaCaptured();
7158 bool HandlePragmaLoopHint(LoopHint &Hint);
7160 bool ParsePragmaAttributeSubjectMatchRuleSet(
7162 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
7164 void HandlePragmaAttribute();
7170 void HandlePragmaExport();
7196 enum class ParsedStmtContext {
7199 AllowDeclarationsInC = 0x1,
7201 AllowStandaloneOpenMPDirectives = 0x2,
7208 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
7225 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt,
7280 ParseStatementOrDeclaration(
StmtVector &Stmts, ParsedStmtContext StmtCtx,
7284 StmtResult ParseStatementOrDeclarationAfterAttributes(
7285 StmtVector &Stmts, ParsedStmtContext StmtCtx,
7290 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
7304 ParsedStmtContext StmtCtx);
7313 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
7314 bool MissingCase =
false,
7324 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
7326 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
7352 StmtResult ParseCompoundStatement(
bool isStmtExpr,
unsigned ScopeFlags);
7357 void ParseCompoundStatementLeadingPragmas();
7359 void DiagnoseLabelAtEndOfCompoundStatement();
7369 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
7387 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
7503 StmtResult ParseBreakOrContinueStatement(
bool IsContinue);
7520 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
7567 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
7605 Decl *ParseFunctionStatementBody(
Decl *
Decl, ParseScope &BodyScope);
7614 Decl *ParseFunctionTryBlock(
Decl *
Decl, ParseScope &BodyScope);
7620 bool trySkippingFunctionBody();
7628 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
7630 return isCXXDeclarationStatement(DisambiguatingWithExpression);
7638 bool isForInitDeclaration() {
7642 return Tok.is(tok::kw_using) ||
7643 isCXXSimpleDeclaration(
true);
7648 bool isForRangeIdentifier();
7665 unsigned &NumLineToksConsumed,
7666 bool IsUnevaluated);
7709 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
7725 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
7726 SmallVectorImpl<Expr *> &Constraints,
7727 SmallVectorImpl<Expr *> &Exprs);
7729 class GNUAsmQualifiers {
7730 unsigned Qualifiers = AQ_unspecified;
7739 static const char *getQualifierName(AQ Qualifier);
7740 bool setAsmQualifier(AQ Qualifier);
7741 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
7742 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
7743 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
7747 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
7749 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
7750 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
7763 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
7787 unsigned TemplateParameterDepth;
7790 class TemplateParameterDepthRAII {
7792 unsigned AddedLevels;
7795 explicit TemplateParameterDepthRAII(
unsigned &Depth)
7796 : Depth(Depth), AddedLevels(0) {}
7798 ~TemplateParameterDepthRAII() { Depth -= AddedLevels; }
7804 void addDepth(
unsigned D) {
7808 void setAddedDepth(
unsigned D) {
7809 Depth = Depth - AddedLevels + D;
7813 unsigned getDepth()
const {
return Depth; }
7814 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
7819 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
7825 bool DelayTemplateIdDestruction =
false;
7827 void MaybeDestroyTemplateIds() {
7828 if (DelayTemplateIdDestruction)
7830 if (!TemplateIds.empty() &&
7831 (Tok.is(tok::eof) || !PP.mightHavePendingAnnotationTokens()))
7832 DestroyTemplateIds();
7834 void DestroyTemplateIds();
7838 struct DestroyTemplateIdAnnotationsRAIIObj {
7841 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
7842 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
7845 struct DelayTemplateIdDestructionRAII {
7847 bool PrevDelayTemplateIdDestruction;
7849 DelayTemplateIdDestructionRAII(
Parser &Self,
7850 bool DelayTemplateIdDestruction) noexcept
7852 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
7853 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
7856 ~DelayTemplateIdDestructionRAII() noexcept {
7857 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
7862 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
7874 struct AngleBracketTracker {
7877 enum Priority :
unsigned short {
7879 PotentialTypo = 0x0,
7881 DependentName = 0x2,
7884 SpaceBeforeLess = 0x0,
7886 NoSpaceBeforeLess = 0x1,
7917 if (!Locs.empty() && Locs.back().isActive(P)) {
7918 if (Locs.back().Priority <= Prio) {
7920 Locs.back().LessLoc = LessLoc;
7921 Locs.back().Priority = Prio;
7924 Locs.push_back({
TemplateName, LessLoc, Prio, P.ParenCount,
7925 P.BracketCount, P.BraceCount});
7933 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
7940 if (!Locs.empty() && Locs.back().isActive(P))
7941 return &Locs.back();
7946 AngleBracketTracker AngleBrackets;
7951 struct ParsedTemplateInfo {
7952 ParsedTemplateInfo()
7956 bool isSpecialization,
7957 bool lastParameterListWasEmpty =
false)
7960 TemplateParams(TemplateParams),
7961 LastParameterListWasEmpty(lastParameterListWasEmpty) {}
7963 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
7964 SourceLocation TemplateLoc)
7966 TemplateParams(
nullptr), ExternLoc(ExternLoc),
7967 TemplateLoc(TemplateLoc), LastParameterListWasEmpty(
false) {}
7977 SourceLocation ExternLoc;
7981 SourceLocation TemplateLoc;
7984 bool LastParameterListWasEmpty;
7986 SourceRange getSourceRange() const LLVM_READONLY;
7990 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
7993 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
7995 static
void LateTemplateParserCallback(
void *P, LateParsedTemplate &LPT);
8003 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
8004 bool checkPotentialAngleBracketDelimiter(const AngleBracketTracker::Loc &,
8005 const Token &OpToken);
8006 bool checkPotentialAngleBracketDelimiter(const Token &OpToken) {
8007 if (
auto *Info = AngleBrackets.getCurrent(*
this))
8008 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
8019 SourceLocation &DeclEnd,
8020 ParsedAttributes &AccessAttrs);
8067 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
8079 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
8080 SmallVectorImpl<NamedDecl *> &TemplateParams,
8081 SourceLocation &LAngleLoc,
8082 SourceLocation &RAngleLoc);
8094 bool ParseTemplateParameterList(
unsigned Depth,
8095 SmallVectorImpl<NamedDecl *> &TemplateParams);
8097 enum class TPResult;
8101 TPResult isStartOfTemplateTypeParameter();
8125 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
8138 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
8154 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
8164 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
8168 bool isTypeConstraintAnnotation();
8180 bool TryAnnotateTypeConstraint();
8182 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
8183 SourceLocation CorrectLoc,
8184 bool AlreadyHasEllipsis,
8185 bool IdentifierHasName);
8186 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
8189 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
8206 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
8207 SourceLocation &RAngleLoc,
8208 bool ConsumeLastToken,
8209 bool ObjCGenericList);
8222 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
8223 SourceLocation &LAngleLoc,
8224 TemplateArgList &TemplateArgs,
8225 SourceLocation &RAngleLoc,
8270 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8272 bool AllowTypeAnnotation =
true,
8273 bool TypeConstraint =
false);
8291 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
8293 bool IsClassName =
false);
8305 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
8309 ParsedTemplateArgument ParseTemplateTemplateArgument();
8321 ParsedTemplateArgument ParseTemplateArgument();
8333 SourceLocation ExternLoc,
8334 SourceLocation TemplateLoc,
8335 SourceLocation &DeclEnd,
8336 ParsedAttributes &AccessAttrs,
8345 Decl *ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
8346 SourceLocation &DeclEnd);
8374 class TentativeParsingAction {
8376 PreferredTypeBuilder PrevPreferredType;
8378 size_t PrevTentativelyDeclaredIdentifierCount;
8379 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
8383 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
8384 : P(p), PrevPreferredType(P.PreferredType) {
8386 PrevTentativelyDeclaredIdentifierCount =
8387 P.TentativelyDeclaredIdentifiers.size();
8388 PrevParenCount = P.ParenCount;
8389 PrevBracketCount = P.BracketCount;
8390 PrevBraceCount = P.BraceCount;
8391 P.PP.EnableBacktrackAtThisPos(Unannotated);
8395 assert(isActive &&
"Parsing action was finished!");
8396 P.TentativelyDeclaredIdentifiers.resize(
8397 PrevTentativelyDeclaredIdentifierCount);
8398 P.PP.CommitBacktrackedTokens();
8402 assert(isActive &&
"Parsing action was finished!");
8404 P.PreferredType = PrevPreferredType;
8406 P.TentativelyDeclaredIdentifiers.resize(
8407 PrevTentativelyDeclaredIdentifierCount);
8408 P.ParenCount = PrevParenCount;
8409 P.BracketCount = PrevBracketCount;
8410 P.BraceCount = PrevBraceCount;
8413 ~TentativeParsingAction() {
8414 assert(!isActive &&
"Forgot to call Commit or Revert!");
8420 class RevertingTentativeParsingAction
8421 :
private Parser::TentativeParsingAction {
8423 using TentativeParsingAction::TentativeParsingAction;
8425 ~RevertingTentativeParsingAction() { Revert(); }
8460 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
8486 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
8499 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
8503 struct ConditionDeclarationOrInitStatementState;
8504 enum class ConditionOrInitStatement {
8531 ConditionOrInitStatement
8532 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
8533 bool CanBeForRangeDecl);
8559 return isCXXTypeId(Context, isAmbiguous);
8573 bool isEnumBase(
bool AllowSemi);
8693 TPResult BracedCastResult = TPResult::False,
8694 bool *InvalidAsDeclSpec =
nullptr);
8699 bool isCXXDeclarationSpecifierAType();
8705 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
8710 TPResult isExplicitBool();
8715 bool isTentativelyDeclared(IdentifierInfo *II);
8734 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
8742 TPResult TryParseTypeofSpecifier();
8746 TPResult TryParseProtocolQualifiers();
8748 TPResult TryParsePtrOperatorSeq();
8770 TPResult TryParseOperatorId();
8801 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
8858 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
8859 bool mayHaveDirectInit =
false,
8860 bool mayHaveTrailingReturnType =
false);
8881 TPResult TryParseParameterDeclarationClause(
8882 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
8899 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
8905 bool NameAfterArrowIsNonType();
8911 TPResult TryParseBracketDeclarator();
8915 TPResult TryConsumeDeclarationSpecifier();
8919 bool TrySkipAttributes();
8961 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
8962 bool OuterMightBeMessageSend =
false);