299 return Actions.incrementMSManglingNumber();
348 assert(!isTokenSpecial() &&
349 "Should consume special tokens with Consume*Token");
350 PrevTokLocation = Tok.getLocation();
352 return PrevTokLocation;
358 assert(!isTokenSpecial() &&
359 "Should consume special tokens with Consume*Token");
360 PrevTokLocation = Tok.getLocation();
368 Loc = PrevTokLocation;
377 return ConsumeParen();
378 if (isTokenBracket())
379 return ConsumeBracket();
381 return ConsumeBrace();
382 if (isTokenStringLiteral())
383 return ConsumeStringToken();
384 if (Tok.is(tok::code_completion))
385 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
386 : handleUnexpectedCodeCompletionToken();
387 if (Tok.isAnnotation())
388 return ConsumeAnnotationToken();
402 if (N == 0 || Tok.is(tok::eof))
404 return PP.LookAhead(N - 1);
413 if (!Tok.getAnnotationValue())
448 bool IsAddressOfOperand =
false);
474 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
475 (Tok.is(tok::annot_template_id) &&
477 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
494 ParseScope(
const ParseScope &) =
delete;
495 void operator=(
const ParseScope &) =
delete;
502 bool BeforeCompoundStmt =
false)
504 if (EnteredScope && !BeforeCompoundStmt)
505 Self->EnterScope(ScopeFlags);
507 if (BeforeCompoundStmt)
508 Self->incrementMSManglingNumber();
510 this->Self = nullptr;
528 class MultiParseScope {
530 unsigned NumScopes = 0;
532 MultiParseScope(
const MultiParseScope &) =
delete;
537 Self.EnterScope(ScopeFlags);
579 static_cast<unsigned>(R));
634 unsigned short ParenCount = 0, BracketCount = 0,
BraceCount = 0;
635 unsigned short MisplacedModuleBeginCount = 0;
646 static constexpr int ScopeCacheSize = 16;
647 unsigned NumCachedScopes;
648 Scope *ScopeCache[ScopeCacheSize];
654 *Ident_GetExceptionCode;
657 *Ident_GetExceptionInfo;
659 IdentifierInfo *Ident__abnormal_termination, *Ident___abnormal_termination,
660 *Ident_AbnormalTermination;
666 std::unique_ptr<CommentHandler> CommentSemaHandler;
671 bool CalledSignatureHelp =
false;
673 bool isTokenSEHExcept();
679 bool SkipFunctionBodies;
686 bool isTokenParen()
const {
return Tok.isOneOf(tok::l_paren, tok::r_paren); }
688 bool isTokenBracket()
const {
689 return Tok.isOneOf(tok::l_square, tok::r_square);
692 bool isTokenBrace()
const {
return Tok.isOneOf(tok::l_brace, tok::r_brace); }
694 bool isTokenStringLiteral()
const {
698 bool isTokenSpecial()
const {
699 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
700 isTokenBrace() || Tok.is(tok::code_completion) || Tok.isAnnotation();
705 bool isTokenEqualOrEqualTypo();
709 void UnconsumeToken(Token &Consumed) {
711 PP.EnterToken(Consumed,
true);
713 PP.EnterToken(
Next,
true);
716 SourceLocation ConsumeAnnotationToken() {
717 assert(Tok.isAnnotation() &&
"wrong consume method");
718 SourceLocation Loc = Tok.getLocation();
719 PrevTokLocation = Tok.getAnnotationEndLoc();
726 SourceLocation ConsumeParen() {
727 assert(isTokenParen() &&
"wrong consume method");
728 if (Tok.getKind() == tok::l_paren)
730 else if (ParenCount) {
731 AngleBrackets.clear(*
this);
734 PrevTokLocation = Tok.getLocation();
736 return PrevTokLocation;
741 SourceLocation ConsumeBracket() {
742 assert(isTokenBracket() &&
"wrong consume method");
743 if (Tok.getKind() == tok::l_square)
745 else if (BracketCount) {
746 AngleBrackets.clear(*
this);
750 PrevTokLocation = Tok.getLocation();
752 return PrevTokLocation;
757 SourceLocation ConsumeBrace() {
758 assert(isTokenBrace() &&
"wrong consume method");
759 if (Tok.getKind() == tok::l_brace)
761 else if (BraceCount) {
762 AngleBrackets.clear(*
this);
766 PrevTokLocation = Tok.getLocation();
768 return PrevTokLocation;
775 SourceLocation ConsumeStringToken() {
776 assert(isTokenStringLiteral() &&
777 "Should only consume string literals with this method");
778 PrevTokLocation = Tok.getLocation();
780 return PrevTokLocation;
788 SourceLocation ConsumeCodeCompletionToken() {
789 assert(Tok.is(tok::code_completion));
790 PrevTokLocation = Tok.getLocation();
792 return PrevTokLocation;
800 SourceLocation handleUnexpectedCodeCompletionToken();
804 void cutOffParsing() {
805 if (PP.isCodeCompletionEnabled())
806 PP.setCodeCompletionReached();
808 Tok.setKind(tok::eof);
815 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
816 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
817 Kind == tok::annot_repl_input_end;
820 static void setTypeAnnotation(Token &Tok,
TypeResult T) {
821 assert((
T.isInvalid() ||
T.get()) &&
822 "produced a valid-but-null type annotation?");
823 Tok.setAnnotationValue(
T.isInvalid() ?
nullptr :
T.get().getAsOpaquePtr());
826 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
827 return static_cast<NamedDecl *
>(Tok.getAnnotationValue());
830 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
831 Tok.setAnnotationValue(ND);
834 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
835 return static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
838 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
839 Tok.setAnnotationValue(ND);
844 static ExprResult getExprAnnotation(
const Token &Tok) {
845 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
850 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
851 Tok.setAnnotationValue(ER.getAsOpaquePointer());
865 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
870 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
877 bool TryKeywordIdentFallback(
bool DisableKeyword);
882 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
893 unsigned Diag = diag::err_expected,
894 StringRef DiagMsg =
"");
901 bool ExpectAndConsumeSemi(
unsigned DiagID, StringRef TokenUsed =
"");
906 bool isLikelyAtStartOfNewDeclaration();
917 bool expectIdentifier();
920 enum class CompoundToken {
935 void checkCompoundToken(SourceLocation FirstTokLoc,
938 void diagnoseUseOfC11Keyword(
const Token &Tok);
941 class ParseScopeFlags {
943 unsigned OldFlags = 0;
944 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
945 void operator=(
const ParseScopeFlags &) =
delete;
950 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
964 void SuggestParentheses(SourceLocation Loc,
unsigned DK,
965 SourceRange ParenRange);
1001 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1002 ParsedAttributes &DeclSpecAttrs,
1003 ParsingDeclSpec *DS =
nullptr);
1007 bool isDeclarationAfterDeclarator();
1011 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1014 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1035 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1036 ParsedAttributes &DeclSpecAttrs,
1037 ParsingDeclSpec &DS,
1040 void SkipFunctionBody();
1042 struct ParsedTemplateInfo;
1060 Decl *ParseFunctionDefinition(
1061 ParsingDeclarator &D,
1062 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1063 LateParsedAttrList *LateParsedAttrs =
nullptr);
1067 void ParseKNRParamDeclarations(Declarator &D);
1077 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1090 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1094 struct IfExistsCondition {
1096 SourceLocation KeywordLoc;
1112 bool ParseMicrosoftIfExistsCondition(IfExistsCondition &
Result);
1113 void ParseMicrosoftIfExistsExternalDeclaration();
1152 Decl *ParseModuleImport(SourceLocation AtLoc,
1159 bool parseMisplacedModuleImport();
1161 bool tryParseMisplacedModuleImport() {
1163 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
1164 Kind == tok::annot_module_include)
1165 return parseMisplacedModuleImport();
1178 bool ParseModuleName(SourceLocation UseLoc,
1179 SmallVectorImpl<IdentifierLoc> &Path,
bool IsImport);
1182 void DiagnoseInvalidCXXModuleImport();
1186 void CodeCompleteDirective(
bool InConditional)
override;
1188 void CodeCompleteMacroName(
bool IsDefinition)
override;
1190 void CodeCompleteMacroArgument(IdentifierInfo *
Macro, MacroInfo *MacroInfo,
1191 unsigned ArgumentIndex)
override;
1192 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
1194 void CodeCompleteModuleImport(SourceLocation ImportLoc,
1213 struct ParsingClass;
1219 LateParsedClass(
Parser *P, ParsingClass *
C);
1220 ~LateParsedClass()
override;
1229 LateParsedClass(
const LateParsedClass &) =
delete;
1230 LateParsedClass &operator=(
const LateParsedClass &) =
delete;
1234 ParsingClass *
Class;
1248 :
Self(P), AS(AS) {}
1250 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1260 struct LexedMethod :
public LateParsedDeclaration {
1265 explicit LexedMethod(
Parser *P, Decl *MD) : Self(P), D(MD) {}
1274 struct LateParsedDefaultArgument {
1275 explicit LateParsedDefaultArgument(
1276 Decl *P, std::unique_ptr<CachedTokens> Toks =
nullptr)
1277 : Param(P), Toks(std::move(Toks)) {}
1286 std::unique_ptr<CachedTokens> Toks;
1293 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1294 explicit LateParsedMethodDeclaration(
Parser *P, Decl *M)
1295 : Self(P), Method(M), ExceptionSpecTokens(
nullptr) {}
1309 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1319 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1320 LateParsedMemberInitializer(
Parser *P, Decl *FD) : Self(P), Field(FD) {}
1340 typedef SmallVector<LateParsedDeclaration *, 2>
1341 LateParsedDeclarationsContainer;
1355 const ParsedAttributesView &AccessAttrs,
1356 ParsingDeclarator &D,
1357 const ParsedTemplateInfo &TemplateInfo,
1358 const VirtSpecifiers &VS,
1359 SourceLocation PureSpecLoc);
1362 StringLiteral *ParseCXXDeletedFunctionMessage();
1367 void SkipDeletedFunctionBody();
1373 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1377 void ParseLexedAttributes(ParsingClass &
Class);
1380 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1382 ParsedAttributes *OutAttrs =
nullptr);
1391 ParsedAttributes *OutAttrs =
nullptr);
1397 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1398 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1403 void ParseLexedMethodDefs(ParsingClass &
Class);
1404 void ParseLexedMethodDef(LexedMethod &LM);
1410 void ParseLexedMemberInitializers(ParsingClass &
Class);
1411 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1445 ParsedAttributes *Attrs =
nullptr);
1451 IdentifierInfo *Ident_vector;
1452 IdentifierInfo *Ident_bool;
1453 IdentifierInfo *Ident_Bool;
1457 IdentifierInfo *Ident_pixel;
1460 IdentifierInfo *Ident_introduced;
1463 IdentifierInfo *Ident_deprecated;
1466 IdentifierInfo *Ident_obsoleted;
1469 IdentifierInfo *Ident_unavailable;
1472 IdentifierInfo *Ident_message;
1475 IdentifierInfo *Ident_strict;
1478 IdentifierInfo *Ident_replacement;
1481 IdentifierInfo *Ident_environment;
1484 IdentifierInfo *Ident_language, *Ident_defined_in,
1485 *Ident_generated_declaration, *Ident_USR;
1488 AttributeFactory AttrFactory;
1493 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
const char *&PrevSpec,
1498 if (Tok.getIdentifierInfo() != Ident_vector &&
1499 Tok.getIdentifierInfo() != Ident_bool &&
1500 Tok.getIdentifierInfo() != Ident_Bool &&
1501 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
1504 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
1510 bool TryAltiVecVectorToken() {
1512 Tok.getIdentifierInfo() != Ident_vector)
1514 return TryAltiVecVectorTokenOutOfLine();
1519 bool TryAltiVecVectorTokenOutOfLine();
1520 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
1521 const char *&PrevSpec,
unsigned &DiagID,
1525 ParsedAttributes &OutAttrs);
1535 static void TakeTypeAttrsAppendingFrom(LateParsedAttrList &To,
1536 LateParsedAttrList &From);
1538 void ParseLexedPragmas(ParsingClass &
Class);
1539 void ParseLexedPragma(LateParsedPragma &LP);
1547 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1563 bool ConsumeFinalToken =
true) {
1564 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1575 bool ConsumeFinalToken =
true);
1583 enum class DeclSpecContext {
1588 DSC_alias_declaration,
1593 DSC_template_type_arg,
1594 DSC_objc_method_result,
1603 static bool isTypeSpecifier(DeclSpecContext DSC) {
1605 case DeclSpecContext::DSC_normal:
1606 case DeclSpecContext::DSC_template_param:
1607 case DeclSpecContext::DSC_template_arg:
1608 case DeclSpecContext::DSC_class:
1609 case DeclSpecContext::DSC_top_level:
1610 case DeclSpecContext::DSC_objc_method_result:
1611 case DeclSpecContext::DSC_condition:
1614 case DeclSpecContext::DSC_template_type_arg:
1615 case DeclSpecContext::DSC_type_specifier:
1616 case DeclSpecContext::DSC_conv_operator:
1617 case DeclSpecContext::DSC_trailing:
1618 case DeclSpecContext::DSC_alias_declaration:
1619 case DeclSpecContext::DSC_association:
1620 case DeclSpecContext::DSC_new:
1623 llvm_unreachable(
"Missing DeclSpecContext case");
1627 enum class AllowDefiningTypeSpec {
1644 static AllowDefiningTypeSpec
1645 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
1647 case DeclSpecContext::DSC_normal:
1648 case DeclSpecContext::DSC_class:
1649 case DeclSpecContext::DSC_top_level:
1650 case DeclSpecContext::DSC_alias_declaration:
1651 case DeclSpecContext::DSC_objc_method_result:
1652 return AllowDefiningTypeSpec::Yes;
1654 case DeclSpecContext::DSC_condition:
1655 case DeclSpecContext::DSC_template_param:
1656 return AllowDefiningTypeSpec::YesButInvalid;
1658 case DeclSpecContext::DSC_template_type_arg:
1659 case DeclSpecContext::DSC_type_specifier:
1660 return AllowDefiningTypeSpec::NoButErrorRecovery;
1662 case DeclSpecContext::DSC_association:
1663 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
1664 : AllowDefiningTypeSpec::Yes;
1666 case DeclSpecContext::DSC_trailing:
1667 case DeclSpecContext::DSC_conv_operator:
1668 case DeclSpecContext::DSC_template_arg:
1669 case DeclSpecContext::DSC_new:
1670 return AllowDefiningTypeSpec::No;
1672 llvm_unreachable(
"Missing DeclSpecContext case");
1676 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
1678 case DeclSpecContext::DSC_normal:
1679 case DeclSpecContext::DSC_class:
1680 case DeclSpecContext::DSC_top_level:
1683 case DeclSpecContext::DSC_alias_declaration:
1684 case DeclSpecContext::DSC_objc_method_result:
1685 case DeclSpecContext::DSC_condition:
1686 case DeclSpecContext::DSC_template_param:
1687 case DeclSpecContext::DSC_template_type_arg:
1688 case DeclSpecContext::DSC_type_specifier:
1689 case DeclSpecContext::DSC_trailing:
1690 case DeclSpecContext::DSC_association:
1691 case DeclSpecContext::DSC_conv_operator:
1692 case DeclSpecContext::DSC_template_arg:
1693 case DeclSpecContext::DSC_new:
1697 llvm_unreachable(
"Missing DeclSpecContext case");
1702 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
1704 case DeclSpecContext::DSC_normal:
1705 case DeclSpecContext::DSC_template_param:
1706 case DeclSpecContext::DSC_template_arg:
1707 case DeclSpecContext::DSC_class:
1708 case DeclSpecContext::DSC_top_level:
1709 case DeclSpecContext::DSC_condition:
1710 case DeclSpecContext::DSC_type_specifier:
1711 case DeclSpecContext::DSC_association:
1712 case DeclSpecContext::DSC_conv_operator:
1713 case DeclSpecContext::DSC_new:
1716 case DeclSpecContext::DSC_objc_method_result:
1717 case DeclSpecContext::DSC_template_type_arg:
1718 case DeclSpecContext::DSC_trailing:
1719 case DeclSpecContext::DSC_alias_declaration:
1722 llvm_unreachable(
"Missing DeclSpecContext case");
1727 getImplicitTypenameContext(DeclSpecContext DSC) {
1729 case DeclSpecContext::DSC_class:
1730 case DeclSpecContext::DSC_top_level:
1731 case DeclSpecContext::DSC_type_specifier:
1732 case DeclSpecContext::DSC_template_type_arg:
1733 case DeclSpecContext::DSC_trailing:
1734 case DeclSpecContext::DSC_alias_declaration:
1735 case DeclSpecContext::DSC_template_param:
1736 case DeclSpecContext::DSC_new:
1737 case DeclSpecContext::DSC_conv_operator:
1740 case DeclSpecContext::DSC_normal:
1741 case DeclSpecContext::DSC_objc_method_result:
1742 case DeclSpecContext::DSC_condition:
1743 case DeclSpecContext::DSC_template_arg:
1744 case DeclSpecContext::DSC_association:
1747 llvm_unreachable(
"Missing DeclSpecContext case");
1752 struct ForRangeInit {
1753 SourceLocation ColonLoc;
1755 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
1756 CXXExpansionStmtDecl *ExpansionStmt =
nullptr;
1757 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
1759 struct ForRangeInfo : ForRangeInit {
1782 SourceLocation &DeclEnd,
1783 ParsedAttributes &DeclAttrs,
1784 ParsedAttributes &DeclSpecAttrs,
1785 SourceLocation *DeclSpecStart =
nullptr);
1812 ParsedAttributes &DeclAttrs,
1813 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
1814 ForRangeInit *FRI =
nullptr,
1815 SourceLocation *DeclSpecStart =
nullptr);
1825 ParsedAttributes &Attrs,
1826 ParsedTemplateInfo &TemplateInfo,
1827 SourceLocation *DeclEnd =
nullptr,
1828 ForRangeInit *FRI =
nullptr);
1854 Decl *ParseDeclarationAfterDeclarator(
1856 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1860 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
1861 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
1863 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1864 ForRangeInit *FRI =
nullptr);
1875 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
1877 DeclSpecContext DSC, ParsedAttributes &Attrs);
1887 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1889 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
1890 LateParsedAttrList *LateAttrs =
nullptr) {
1891 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
1892 getImplicitTypenameContext(DSC));
1925 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1927 LateParsedAttrList *LateAttrs,
1937 bool DiagnoseMissingSemiAfterTagDefinition(
1939 LateParsedAttrList *LateAttrs =
nullptr);
1941 void ParseSpecifierQualifierList(
1943 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
1944 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
1955 void ParseSpecifierQualifierList(
1958 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
1992 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
1993 const ParsedTemplateInfo &TemplateInfo,
2008 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
2009 SkipBodyInfo *SkipBody =
nullptr);
2023 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2024 RecordDecl *TagDecl);
2049 void ParseStructDeclaration(
2050 ParsingDeclSpec &DS,
2051 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2052 LateParsedAttrList *LateFieldAttrs =
nullptr);
2064 bool DisambiguatingWithExpression =
false);
2068 bool isTypeSpecifierQualifier(
const Token &Tok);
2073 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2078 bool isConstructorDeclarator(
2081 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2085 void DiagnoseBitIntUse(
const Token &Tok);
2089 bool CheckProhibitedCXX11Attribute() {
2090 assert(Tok.is(tok::l_square));
2093 return DiagnoseProhibitedCXX11Attribute();
2104 bool DiagnoseProhibitedCXX11Attribute();
2106 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2107 SourceLocation CorrectLocation) {
2108 if (!Tok.isRegularKeywordAttribute() &&
2109 (Tok.isNot(tok::l_square) ||
NextToken().
isNot(tok::l_square)) &&
2110 Tok.isNot(tok::kw_alignas))
2112 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2119 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2120 SourceLocation CorrectLocation);
2130 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2134 void ProhibitAttributes(ParsedAttributes &Attrs,
2135 SourceLocation FixItLoc = SourceLocation()) {
2136 if (Attrs.Range.isInvalid())
2138 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2142 void ProhibitAttributes(ParsedAttributesView &Attrs,
2143 SourceLocation FixItLoc = SourceLocation()) {
2144 if (Attrs.Range.isInvalid())
2146 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2147 Attrs.clearListOnly();
2149 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2150 SourceLocation FixItLoc);
2158 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2159 unsigned KeywordDiagId,
2160 bool DiagnoseEmptyAttrs =
false,
2161 bool WarnOnUnknownAttrs =
false);
2165 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2167 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2174 bool ParseAttributeArgumentList(
2175 const IdentifierInfo &AttrName, SmallVectorImpl<Expr *> &Exprs,
2176 ParsedAttributeArgumentsProperties ArgsProperties,
unsigned Arg);
2183 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2184 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2185 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2186 ParsedAttr::Form Form);
2188 enum ParseAttrKindMask {
2190 PAKM_Declspec = 1 << 1,
2191 PAKM_CXX11 = 1 << 2,
2210 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2211 LateParsedAttrList *LateAttrs =
nullptr);
2214 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2215 LateParsedAttrList *LateAttrs =
nullptr) {
2216 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2217 isAllowedCXX11AttributeSpecifier()) {
2218 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2224 void MaybeParseGNUAttributes(Declarator &D,
2225 LateParsedAttrList *LateAttrs =
nullptr) {
2226 if (Tok.is(tok::kw___attribute)) {
2227 ParsedAttributes Attrs(AttrFactory);
2228 ParseGNUAttributes(Attrs, LateAttrs, &D);
2229 D.takeAttributesAppending(Attrs);
2233 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2234 LateParsedAttrList *LateAttrs =
nullptr) {
2235 if (Tok.is(tok::kw___attribute)) {
2236 ParseGNUAttributes(Attrs, LateAttrs);
2258 bool ParseSingleGNUAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc,
2259 LateParsedAttrList *LateAttrs =
nullptr,
2260 Declarator *D =
nullptr);
2305 void ParseGNUAttributes(ParsedAttributes &Attrs,
2306 LateParsedAttrList *LateAttrs =
nullptr,
2307 Declarator *D =
nullptr);
2311 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2312 SourceLocation AttrNameLoc,
2313 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2314 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2315 ParsedAttr::Form Form, Declarator *D);
2316 IdentifierLoc *ParseIdentifierLoc();
2319 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2320 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2321 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2322 ParsedAttr::Form Form);
2324 void MaybeParseCXX11Attributes(Declarator &D) {
2325 if (isAllowedCXX11AttributeSpecifier()) {
2326 ParsedAttributes Attrs(AttrFactory);
2327 ParseCXX11Attributes(Attrs);
2328 D.takeAttributesAppending(Attrs);
2332 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2333 bool OuterMightBeMessageSend =
false) {
2334 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2335 ParseCXX11Attributes(Attrs);
2341 bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2342 bool AttrsParsed =
false;
2344 Tok.is(tok::l_square)) {
2345 ParsedAttributes AttrsWithRange(AttrFactory);
2346 ParseMicrosoftAttributes(AttrsWithRange);
2347 AttrsParsed = !AttrsWithRange.empty();
2348 Attrs.takeAllAppendingFrom(AttrsWithRange);
2352 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
2353 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
2354 ParseMicrosoftDeclSpecs(Attrs);
2368 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
2369 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
2370 SourceLocation AttrNameLoc,
2371 ParsedAttributes &Attrs);
2372 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
2373 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
2374 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2375 SourceLocation SkipExtendedMicrosoftTypeAttributes();
2377 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
2378 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
2379 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
2380 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
2381 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
2382 bool isHLSLQualifier(
const Token &Tok)
const;
2383 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
2395 VersionTuple ParseVersionTuple(SourceRange &Range);
2424 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
2425 SourceLocation AvailabilityLoc,
2426 ParsedAttributes &attrs,
2427 SourceLocation *endLoc,
2428 IdentifierInfo *ScopeName,
2429 SourceLocation ScopeLoc,
2430 ParsedAttr::Form Form);
2448 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
2450 ParsedAttributes &Attrs,
2451 SourceLocation *EndLoc,
2452 IdentifierInfo *ScopeName,
2453 SourceLocation ScopeLoc,
2454 ParsedAttr::Form Form);
2469 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
2470 SourceLocation ObjCBridgeRelatedLoc,
2471 ParsedAttributes &Attrs,
2472 SourceLocation *EndLoc,
2473 IdentifierInfo *ScopeName,
2474 SourceLocation ScopeLoc,
2475 ParsedAttr::Form Form);
2477 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
2478 SourceLocation AttrNameLoc,
2479 ParsedAttributes &Attrs,
2480 SourceLocation *EndLoc,
2481 IdentifierInfo *ScopeName,
2482 SourceLocation ScopeLoc,
2483 ParsedAttr::Form Form);
2485 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
2486 SourceLocation AttrNameLoc,
2487 ParsedAttributes &Attrs,
2488 SourceLocation *EndLoc,
2489 IdentifierInfo *ScopeName,
2490 SourceLocation ScopeLoc,
2491 ParsedAttr::Form Form);
2493 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
2494 SourceLocation AttrNameLoc,
2495 ParsedAttributes &Attrs,
2496 IdentifierInfo *ScopeName,
2497 SourceLocation ScopeLoc,
2498 ParsedAttr::Form Form);
2500 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
2506 void ParseBoundsAttribute(IdentifierInfo &AttrName,
2507 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
2508 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2509 ParsedAttr::Form Form);
2525 void ParseTypeofSpecifier(DeclSpec &DS);
2532 void ParseAtomicSpecifier(DeclSpec &DS);
2542 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
2543 SourceLocation &EllipsisLoc,
bool &IsType,
2556 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
2557 SourceLocation *endLoc =
nullptr);
2566 void ParsePtrauthQualifier(ParsedAttributes &Attrs);
2571 class DeclaratorScopeObj {
2578 DeclaratorScopeObj(
Parser &p, CXXScopeSpec &ss)
2579 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2581 void EnterDeclaratorScope() {
2582 assert(!EnteredScope &&
"Already entered the scope!");
2583 assert(SS.isSet() &&
"C++ scope was not set!");
2585 CreatedScope =
true;
2588 if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS))
2589 EnteredScope =
true;
2592 ~DeclaratorScopeObj() {
2594 assert(SS.isSet() &&
"C++ scope was cleared ?");
2595 P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS);
2603 void ParseDeclarator(Declarator &D);
2634 void ParseDeclaratorInternal(Declarator &D,
2635 DirectDeclParseFunction DirectDeclParser);
2637 enum AttrRequirements {
2638 AR_NoAttributesParsed = 0,
2639 AR_GNUAttributesParsedAndRejected = 1 << 0,
2640 AR_GNUAttributesParsed = 1 << 1,
2641 AR_CXX11AttributesParsed = 1 << 2,
2642 AR_DeclspecAttributesParsed = 1 << 3,
2643 AR_AllAttributesParsed = AR_GNUAttributesParsed | AR_CXX11AttributesParsed |
2644 AR_DeclspecAttributesParsed,
2645 AR_VendorAttributesParsed =
2646 AR_GNUAttributesParsed | AR_DeclspecAttributesParsed
2663 void ParseTypeQualifierListOpt(
2664 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2665 bool AtomicOrPtrauthAllowed =
true,
bool IdentifierRequired =
false,
2666 llvm::function_ref<
void()> CodeCompletionHandler = {});
2716 void ParseDirectDeclarator(Declarator &D);
2717 void ParseDecompositionDeclarator(Declarator &D);
2735 void ParseParenDeclarator(Declarator &D);
2760 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
2762 bool IsAmbiguous,
bool RequiresArg =
false);
2763 void InitCXXThisScopeForDeclaratorIfRelevant(
2764 const Declarator &D,
const DeclSpec &DS,
2765 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
2769 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2770 SourceLocation &RefQualifierLoc);
2777 bool isFunctionDeclaratorIdentifierList();
2791 void ParseFunctionDeclaratorIdentifierList(
2792 Declarator &D, SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
2793 void ParseParameterDeclarationClause(
2794 Declarator &D, ParsedAttributes &attrs,
2795 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2796 SourceLocation &EllipsisLoc) {
2797 return ParseParameterDeclarationClause(
2798 D.getContext(), attrs, ParamInfo, EllipsisLoc,
2799 D.getCXXScopeSpec().isSet() &&
2800 D.isFunctionDeclaratorAFunctionDeclaration());
2838 void ParseParameterDeclarationClause(
2840 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2841 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
2852 void ParseBracketDeclarator(Declarator &D);
2855 void ParseMisplacedBracketDeclarator(Declarator &D);
2866 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
2867 SourceLocation IncludeLoc);
2883 mutable IdentifierInfo *Ident_sealed;
2884 mutable IdentifierInfo *Ident_abstract;
2887 mutable IdentifierInfo *Ident_final;
2888 mutable IdentifierInfo *Ident_GNU_final;
2889 mutable IdentifierInfo *Ident_override;
2894 struct ParsingClass {
2895 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
2896 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
2897 TagOrTemplate(TagOrTemplate) {}
2901 bool TopLevelClass : 1;
2904 bool IsInterface : 1;
2907 Decl *TagOrTemplate;
2912 LateParsedDeclarationsContainer LateParsedDeclarations;
2918 std::stack<ParsingClass *> ClassStack;
2920 ParsingClass &getCurrentClass() {
2921 assert(!ClassStack.empty() &&
"No lexed method stacks!");
2922 return *ClassStack.top();
2926 class ParsingClassDefinition {
2932 ParsingClassDefinition(
Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
2934 : P(P), Popped(
false),
2935 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
2940 assert(!Popped &&
"Nested class has already been popped");
2942 P.PopParsingClass(State);
2945 ~ParsingClassDefinition() {
2947 P.PopParsingClass(State);
2963 bool Delayed, SourceRange &SpecificationRange,
2964 SmallVectorImpl<ParsedType> &DynamicExceptions,
2965 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2983 ParseDynamicExceptionSpecification(SourceRange &SpecificationRange,
2984 SmallVectorImpl<ParsedType> &Exceptions,
2985 SmallVectorImpl<SourceRange> &Ranges);
2992 TypeResult ParseTrailingReturnType(SourceRange &Range,
2993 bool MayBeFollowedByDirectInit);
2996 void ParseTrailingRequiresClauseWithScope(Declarator &D);
2997 void ParseTrailingRequiresClause(Declarator &D);
2999 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
3000 ParsedAttributes &AccessAttrs,
3003 SourceLocation ParsePackIndexingType(DeclSpec &DS);
3004 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
3005 SourceLocation StartLoc,
3006 SourceLocation EndLoc);
3011 bool AnnotatePackIndexingTemplateName(CXXScopeSpec &SS, UnqualifiedId &Name,
3020 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
3021 bool OuterMightBeMessageSend =
false) {
3022 return (Tok.isRegularKeywordAttribute() ||
3023 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend) !=
3030 SourceLocation SkipCXX11Attributes();
3034 void DiagnoseAndSkipCXX11Attributes();
3036 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3065 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3067 SourceLocation *EndLoc =
nullptr);
3068 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3069 SourceLocation *EndLoc =
nullptr) {
3071 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3072 ReplayOpenMPAttributeTokens(OpenMPTokens);
3081 void ParseCXX11Attributes(ParsedAttributes &attrs);
3101 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3102 SourceLocation AttrNameLoc,
3103 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3104 IdentifierInfo *ScopeName,
3105 SourceLocation ScopeLoc,
3111 ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
3112 SourceLocation AttrNameLoc,
3113 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3114 SourceLocation *EndLoc, ParsedAttr::Form Form);
3125 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3126 SourceLocation &Loc,
3129 const IdentifierInfo *EnclosingScope =
nullptr);
3132 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3144 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3146 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3147 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3156 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3157 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3158 SourceLocation StartLoc,
3159 SourceLocation EndLoc);
3172 return isCXX11VirtSpecifier(Tok);
3182 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3183 SourceLocation FriendLoc);
3187 bool isCXX11FinalKeyword()
const;
3193 bool isClassCompatibleKeyword()
const;
3195 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3198 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3230 SourceLocation &DeclEnd,
3231 SourceLocation InlineLoc = SourceLocation());
3233 struct InnerNamespaceInfo {
3234 SourceLocation NamespaceLoc;
3235 SourceLocation InlineLoc;
3236 SourceLocation IdentLoc;
3237 IdentifierInfo *Ident;
3239 using InnerNamespaceInfoList = llvm::SmallVector<InnerNamespaceInfo, 4>;
3242 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3243 unsigned int index, SourceLocation &InlineLoc,
3244 ParsedAttributes &attrs,
3276 Decl *ParseExportDeclaration();
3282 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3297 SourceLocation &DeclEnd, ParsedAttributes &attrs);
3299 struct UsingDeclarator {
3300 SourceLocation TypenameLoc;
3303 SourceLocation EllipsisLoc;
3306 TypenameLoc = EllipsisLoc = SourceLocation();
3347 const ParsedTemplateInfo &TemplateInfo,
3348 SourceLocation UsingLoc,
3349 SourceLocation &DeclEnd,
3350 ParsedAttributes &Attrs,
3352 Decl *ParseAliasDeclarationAfterDeclarator(
3353 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3355 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3368 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3373 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3374 SourceLocation AliasLoc, IdentifierInfo *Alias,
3375 SourceLocation &DeclEnd);
3383 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3427 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3428 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3430 DeclSpecContext DSC, ParsedAttributes &Attributes);
3431 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3432 SourceLocation AttrFixitLoc,
unsigned TagType,
3443 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3444 SourceLocation AttrFixitLoc,
3445 ParsedAttributes &Attrs,
unsigned TagType,
3470 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3471 SourceLocation &EqualLoc);
3475 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3478 LateParsedAttrList &LateAttrs);
3483 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3484 VirtSpecifiers &VS);
3540 ParsedTemplateInfo &TemplateInfo,
3541 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3544 ParsedAttributes &AccessAttrs,
3570 void ParseConstructorInitializer(Decl *ConstructorDecl);
3592 void HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
3620 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3621 SourceLocation &EndLocation);
3633 void ParseBaseClause(Decl *ClassDecl);
3648 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3664 bool isClassCompatibleKeyword(Token Tok)
const;
3666 void ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs);
3841 bool GreaterThanIsOperator;
3845 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
3864 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
3868 void DeallocateParsedClasses(ParsingClass *
Class);
4089 bool isAddressOfOperand,
bool &NotCastExpr,
4091 bool isVectorLiteral =
false,
4092 bool *NotPrimaryExpression =
nullptr);
4094 bool isAddressOfOperand =
false,
4097 bool isVectorLiteral =
false,
4098 bool *NotPrimaryExpression =
nullptr);
4101 bool isNotExpressionStart();
4105 bool isPostfixExpressionSuffixStart() {
4107 return (K == tok::l_square || K == tok::l_paren || K == tok::period ||
4108 K == tok::arrow || K == tok::plusplus || K == tok::minusminus);
4150 ExprResult ParseUnaryExprOrTypeTraitExpression();
4179 ExprResult ParseSYCLUniqueStableNameExpression();
4241 llvm::function_ref<
void()> ExpressionStarts =
4242 llvm::function_ref<
void()>(),
4243 bool FailImmediatelyOnInvalidExpr =
false,
4244 bool ParsingExpansionStmtInitList =
false);
4289 bool StopIfCastExpr,
4326 ExprResult ParseGenericSelectionExpression();
4345 void injectEmbedTokens();
4371 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
4373 Expr *ReceiverExpr);
4378 bool isKnownToBeDeclarationSpecifier() {
4392 bool isTypeIdForGenericSelection() {
4398 return isTypeSpecifierQualifier(Tok);
4404 bool isTypeIdUnambiguously() {
4409 return isTypeSpecifierQualifier(Tok);
4418 void ParseBlockId(SourceLocation CaretLoc);
4427 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
4428 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
4434 bool tryParseOpenMPArrayShapingCastPart();
4436 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
4489 bool ObjectHadErrors,
bool EnteringContext,
4490 bool AllowDestructorName,
bool AllowConstructorName,
4491 bool AllowDeductionGuide,
4492 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
4510 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand);
4561 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
4564 bool areTokensAdjacent(
const Token &A,
const Token &B);
4568 void CheckForTemplateAndDigraph(Token &
Next,
ParsedType ObjectTypePtr,
4569 bool EnteringContext, IdentifierInfo &II,
4632 bool ParseOptionalCXXScopeSpecifier(
4633 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
4634 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
4635 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
4636 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
4637 bool Disambiguation =
false,
bool IsAddressOfOperand =
false,
4638 bool IsInDeclarationContext =
false);
4640 bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
ParsedType ObjectType,
4641 bool ObjectHasErrors,
4642 bool EnteringContext,
4643 bool IsAddressOfOperand) {
4644 return ParseOptionalCXXScopeSpecifier(
4645 SS, ObjectType, ObjectHasErrors, EnteringContext,
4652 IsAddressOfOperand);
4659 enum class LambdaIntroducerTentativeParse {
4737 ParseLambdaIntroducer(LambdaIntroducer &Intro,
4738 LambdaIntroducerTentativeParse *Tentative =
nullptr);
4742 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
4745 bool isLambdaSpecifier();
4829 ExprResult ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc,
4884 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
4914 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
4929 bool ParseCXXTypeSpecifierSeq(
4947 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr *> &Exprs,
4959 void ParseDirectNewDeclarator(Declarator &D);
4992 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
5007 ExprResult ParseCXXDeleteExpression(
bool UseGlobal, SourceLocation Start);
5043 Sema::ConditionResult ParseCondition(
StmtResult *InitStmt, SourceLocation Loc,
5045 ForRangeInfo *FRI =
nullptr);
5047 ParsedAttributes &Attrs);
5094 bool isTypeIdInParens(
bool &isAmbiguous) {
5097 isAmbiguous =
false;
5098 return isTypeSpecifierQualifier(Tok);
5100 bool isTypeIdInParens() {
5102 return isTypeIdInParens(isAmbiguous);
5140 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
ParsedType ObjectType,
5141 bool ObjectHadErrors,
5142 SourceLocation TemplateKWLoc,
5143 IdentifierInfo *Name,
5144 SourceLocation NameLoc,
5145 bool EnteringContext, UnqualifiedId &Id,
5146 bool AssumeTemplateId);
5188 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
5255 bool MaybeParseHLSLAnnotations(Declarator &D,
5256 SourceLocation *EndLoc =
nullptr,
5257 bool CouldBeBitField =
false) {
5258 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5259 if (Tok.is(tok::colon)) {
5260 ParsedAttributes Attrs(AttrFactory);
5261 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
5262 D.takeAttributesAppending(Attrs);
5268 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
5269 SourceLocation *EndLoc =
nullptr) {
5270 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5271 if (Tok.is(tok::colon))
5272 ParseHLSLAnnotations(Attrs, EndLoc);
5275 struct ParsedSemantic {
5276 StringRef Name =
"";
5278 bool Explicit =
false;
5281 ParsedSemantic ParseHLSLSemantic();
5283 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
5284 SourceLocation *EndLoc =
nullptr,
5285 bool CouldBeBitField =
false);
5286 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd, ParsedAttributes &Attrs);
5310 ExprResult ParseInitializer(Decl *DeclForInitializer =
nullptr);
5315 bool MayBeDesignationStart();
5343 struct DesignatorCompletionInfo {
5344 SmallVectorImpl<Expr *> &InitExprs;
5345 QualType PreferredBaseType;
5394 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
5399 typedef SmallVector<Expr *, 12> ExprVector;
5403 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
5420 friend class ObjCDeclContextSwitch;
5423 return Actions.ObjC().getObjCDeclContext();
5429 return Actions.getNullabilityKeyword(nullability);
5445 bool InMessageExpression;
5452 bool ParsingInObjCContainer;
5457 bool isObjCInstancetype() {
5459 if (
Tok.isAnnotation())
5461 if (!Ident_instancetype)
5463 return Tok.getIdentifierInfo() == Ident_instancetype;
5471 ObjCContainerDecl *DC;
5472 SaveAndRestore<bool> WithinObjCContainer;
5477 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
5479 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
5481 ~ObjCDeclContextSwitch() {
5483 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
5487 void CheckNestedObjCContexts(SourceLocation AtLoc);
5489 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
5507 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
5508 ParsedAttributes &DeclSpecAttrs);
5519 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
5552 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
5553 ParsedAttributes &prefixAttrs);
5559 ObjCTypeParamList *parseObjCTypeParamList();
5587 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
5589 SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
5590 bool mayBeProtocolList =
true);
5592 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
5593 SourceLocation atLoc,
5595 SmallVectorImpl<Decl *> &AllIvarDecls,
5596 bool RBraceMissing);
5621 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
5623 SourceLocation atLoc);
5630 bool ParseObjCProtocolReferences(
5631 SmallVectorImpl<Decl *> &P, SmallVectorImpl<SourceLocation> &PLocs,
5632 bool WarnOnDeclarations,
bool ForObjCContainer, SourceLocation &LAngleLoc,
5633 SourceLocation &EndProtoLoc,
bool consumeLastToken);
5644 void parseObjCTypeArgsOrProtocolQualifiers(
5645 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5646 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5647 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5648 SmallVectorImpl<SourceLocation> &protocolLocs,
5649 SourceLocation &protocolRAngleLoc,
bool consumeLastToken,
5650 bool warnOnIncompleteProtocols);
5654 void parseObjCTypeArgsAndProtocolQualifiers(
5655 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5656 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5657 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5658 SmallVectorImpl<SourceLocation> &protocolLocs,
5659 SourceLocation &protocolRAngleLoc,
bool consumeLastToken);
5663 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
5667 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
5669 bool consumeLastToken,
5670 SourceLocation &endLoc);
5706 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
5707 ParsedAttributes &prefixAttrs);
5709 struct ObjCImplParsingDataRAII {
5713 typedef SmallVector<LexedMethod *, 8> LateParsedObjCMethodContainer;
5714 LateParsedObjCMethodContainer LateParsedObjCMethods;
5716 ObjCImplParsingDataRAII(
Parser &parser, Decl *D)
5717 : P(parser), Dcl(D), HasCFunction(
false),
5718 PrevParsedObjCImpl(parser.CurParsedObjCImpl) {
5719 P.CurParsedObjCImpl =
this;
5722 ~ObjCImplParsingDataRAII();
5724 void finish(SourceRange AtEnd);
5725 bool isFinished()
const {
return Finished; }
5733 ObjCImplParsingDataRAII *PrevParsedObjCImpl;
5736 ObjCImplParsingDataRAII *CurParsedObjCImpl;
5740 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
5754 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
5755 ParsedAttributes &Attrs);
5763 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
5778 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
5789 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
5801 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
5809 bool isTokIdentifier_in()
const;
5818 ParsedAttributes *ParamAttrs);
5832 Decl *ParseObjCMethodPrototype(
5834 bool MethodDefinition =
true);
5866 Decl *ParseObjCMethodDecl(
5869 bool MethodDefinition =
true);
5899 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
5905 Decl *ParseObjCMethodDefinition();
5909 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
5910 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
5917 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
5926 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
5935 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
5937 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
5938 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
5945 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
5951 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
5957 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
5963 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
5970 bool isSimpleObjCMessageExpression();
6025 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
6026 SourceLocation SuperLoc,
6028 Expr *ReceiverExpr);
6054 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
6059 enum class ParsedStmtContext;
6061 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
6062 ParsedStmtContext StmtCtx);
6077 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
6084 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
6091 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
6098 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
6125 bool isStartOfObjCClassMessageMissingOpenBracket();
6157 bool OpenACCDirectiveParsing =
false;
6161 bool AllowOpenACCArraySections =
false;
6165 class OpenACCArraySectionRAII {
6169 OpenACCArraySectionRAII(
Parser &P) : P(P) {
6170 assert(!P.AllowOpenACCArraySections);
6171 P.AllowOpenACCArraySections =
true;
6173 ~OpenACCArraySectionRAII() {
6174 assert(P.AllowOpenACCArraySections);
6175 P.AllowOpenACCArraySections =
false;
6182 struct OpenACCDirectiveParseInfo {
6184 SourceLocation StartLoc;
6185 SourceLocation DirLoc;
6186 SourceLocation LParenLoc;
6187 SourceLocation RParenLoc;
6188 SourceLocation EndLoc;
6189 SourceLocation MiscLoc;
6191 SmallVector<Expr *> Exprs;
6192 SmallVector<OpenACCClause *> Clauses;
6197 struct OpenACCWaitParseInfo {
6198 bool Failed =
false;
6199 Expr *DevNumExpr =
nullptr;
6200 SourceLocation QueuesLoc;
6201 SmallVector<Expr *> QueueIdExprs;
6203 SmallVector<Expr *> getAllExprs() {
6204 SmallVector<Expr *>
Out;
6205 Out.push_back(DevNumExpr);
6206 llvm::append_range(Out, QueueIdExprs);
6210 struct OpenACCCacheParseInfo {
6211 bool Failed =
false;
6212 SourceLocation ReadOnlyLoc;
6213 SmallVector<Expr *> Vars;
6218 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
6224 using OpenACCClauseParseResult =
6225 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
6227 OpenACCClauseParseResult OpenACCCanContinue();
6228 OpenACCClauseParseResult OpenACCCannotContinue();
6229 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
6233 OpenACCDirectiveParseInfo ParseOpenACCDirective();
6243 OpenACCCacheParseInfo ParseOpenACCCacheVarList();
6249 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
6275 OpenACCClauseParseResult
6276 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
6278 SourceLocation ClauseLoc);
6282 OpenACCClauseParseResult
6283 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
6293 SmallVector<OpenACCClause *>
6302 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation Loc,
6307 std::variant<std::monostate, StringLiteral *, IdentifierInfo *>
6308 ParseOpenACCBindClauseArgument();
6313 using OpenACCIntExprParseResult =
6314 std::pair<ExprResult, OpenACCParseCanContinue>;
6319 SourceLocation Loc);
6324 llvm::SmallVectorImpl<Expr *> &IntExprs);
6337 bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
6351 SourceLocation Loc);
6366 llvm::SmallVectorImpl<Expr *> &SizeExprs);
6378 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
6379 llvm::SmallVectorImpl<OpenACCGangKind> &GKs,
6380 llvm::SmallVectorImpl<Expr *> &IntExprs);
6382 using OpenACCGangArgRes = std::pair<OpenACCGangKind, ExprResult>;
6386 OpenACCGangArgRes ParseOpenACCGangArg(SourceLocation GangLoc);
6390 ParseOpenACCAfterRoutineDecl(
AccessSpecifier &AS, ParsedAttributes &Attrs,
6392 OpenACCDirectiveParseInfo &DirInfo);
6393 StmtResult ParseOpenACCAfterRoutineStmt(OpenACCDirectiveParseInfo &DirInfo);
6411 bool OpenMPDirectiveParsing =
false;
6416 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
6419 if (!OpenMPTokens.empty()) {
6420 PP.EnterToken(Tok,
true);
6421 PP.EnterTokenStream(OpenMPTokens,
true,
6433 SourceLocation Loc);
6438 llvm::omp::TraitSet
Set,
6439 llvm::omp::TraitSelector Selector,
6440 llvm::StringMap<SourceLocation> &Seen);
6444 llvm::omp::TraitSet
Set,
6445 llvm::StringMap<SourceLocation> &Seen);
6449 llvm::StringMap<SourceLocation> &Seen);
6453 llvm::omp::TraitSet
Set,
6454 llvm::StringMap<SourceLocation> &Seen);
6462 llvm::omp::TraitSet
Set,
6463 llvm::StringMap<SourceLocation> &SeenSelectors);
6470 void parseOMPContextSelectorSet(
OMPTraitSet &TISet,
6471 llvm::StringMap<SourceLocation> &SeenSets);
6478 bool parseOMPContextSelectors(SourceLocation Loc,
OMPTraitInfo &TI);
6481 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
6485 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc,
OMPTraitInfo &TI,
6491 SourceLocation Loc);
6510 void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
6511 SourceLocation Loc);
6514 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
6531 void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
6532 SmallVectorImpl<clang::OMPClause *> &Clauses,
6533 SourceLocation Loc);
6536 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
6539 void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind BeginDKind,
6540 OpenMPDirectiveKind EndDKind,
6541 SourceLocation Loc);
6545 void skipUntilPragmaOpenMPEnd(OpenMPDirectiveKind DKind);
6551 void parseOMPEndDirective(OpenMPDirectiveKind BeginKind,
6552 OpenMPDirectiveKind ExpectedKind,
6553 OpenMPDirectiveKind FoundKind,
6554 SourceLocation MatchingLoc, SourceLocation FoundLoc,
6555 bool SkipUntilOpenMPEnd);
6596 AccessSpecifier &AS, ParsedAttributes &Attrs,
bool Delayed =
false,
6598 Decl *TagDecl =
nullptr);
6612 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(AccessSpecifier AS);
6616 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
6628 DeclGroupPtrTy ParseOpenMPDeclareMapperDirective(AccessSpecifier AS);
6631 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
6632 DeclarationName &Name,
6633 AccessSpecifier AS =
AS_none);
6647 bool ParseOpenMPSimpleVarList(
6648 OpenMPDirectiveKind Kind,
6649 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)>
6651 bool AllowScopeSpecifier);
6700 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
6701 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
6711 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
6712 OpenMPDirectiveKind DKind, SourceLocation Loc,
6713 bool ReadDirectiveWithinMetadirective);
6722 StmtResult ParseOpenMPInformationalDirective(
6723 ParsedStmtContext StmtCtx, OpenMPDirectiveKind DKind, SourceLocation Loc,
6724 bool ReadDirectiveWithinMetadirective);
6753 OMPClause *ParseOpenMPClause(OpenMPDirectiveKind DKind,
6838 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6863 OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
6868 OMPClause *ParseOpenMPLoopRangeClause();
6877 OMPClause *ParseOpenMPPermutationClause();
6981 OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
6995 SourceLocation &ClauseNameLoc,
6996 SourceLocation &OpenLoc,
6997 SourceLocation &CloseLoc,
6998 SmallVectorImpl<Expr *> &Exprs,
6999 bool ReqIntConst =
false);
7014 OMPClause *ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind);
7017 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
7023 bool ParseOMPInteropAttrSelector(SmallVectorImpl<Expr *> &Attrs);
7061 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
7068 bool IsAddressOfOperand =
false);
7072 SemaOpenMP::OpenMPVarListDataTy &
Data,
7073 const LangOptions &LangOpts);
7076 SmallVectorImpl<Expr *> &Vars,
7077 SemaOpenMP::OpenMPVarListDataTy &
Data);
7112 std::unique_ptr<PragmaHandler> AlignHandler;
7113 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
7114 std::unique_ptr<PragmaHandler> OptionsHandler;
7115 std::unique_ptr<PragmaHandler> PackHandler;
7116 std::unique_ptr<PragmaHandler> MSStructHandler;
7117 std::unique_ptr<PragmaHandler> UnusedHandler;
7118 std::unique_ptr<PragmaHandler> WeakHandler;
7119 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
7120 std::unique_ptr<PragmaHandler> FPContractHandler;
7121 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
7122 std::unique_ptr<PragmaHandler> OpenMPHandler;
7123 std::unique_ptr<PragmaHandler> OpenACCHandler;
7124 std::unique_ptr<PragmaHandler> PCSectionHandler;
7125 std::unique_ptr<PragmaHandler> MSCommentHandler;
7126 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
7127 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
7128 std::unique_ptr<PragmaHandler> FloatControlHandler;
7129 std::unique_ptr<PragmaHandler> MSPointersToMembers;
7130 std::unique_ptr<PragmaHandler> MSVtorDisp;
7131 std::unique_ptr<PragmaHandler> MSInitSeg;
7132 std::unique_ptr<PragmaHandler> MSDataSeg;
7133 std::unique_ptr<PragmaHandler> MSBSSSeg;
7134 std::unique_ptr<PragmaHandler> MSConstSeg;
7135 std::unique_ptr<PragmaHandler> MSCodeSeg;
7136 std::unique_ptr<PragmaHandler> MSSection;
7137 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
7138 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
7139 std::unique_ptr<PragmaHandler> MSIntrinsic;
7140 std::unique_ptr<PragmaHandler> MSFunction;
7141 std::unique_ptr<PragmaHandler> MSOptimize;
7142 std::unique_ptr<PragmaHandler> MSFenvAccess;
7143 std::unique_ptr<PragmaHandler> MSAllocText;
7144 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
7145 std::unique_ptr<PragmaHandler> OptimizeHandler;
7146 std::unique_ptr<PragmaHandler> LoopHintHandler;
7147 std::unique_ptr<PragmaHandler> UnrollHintHandler;
7148 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
7149 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
7150 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
7151 std::unique_ptr<PragmaHandler> FPHandler;
7152 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
7153 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
7154 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
7155 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
7156 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
7157 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
7158 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
7159 std::unique_ptr<PragmaHandler> ExportHandler;
7160 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7163 void initializePragmaHandlers();
7166 void resetPragmaHandlers();
7173 void HandlePragmaUnused();
7177 void HandlePragmaVisibility();
7181 void HandlePragmaPack();
7185 void HandlePragmaMSStruct();
7187 void HandlePragmaMSPointersToMembers();
7189 void HandlePragmaMSVtorDisp();
7191 void HandlePragmaMSPragma();
7192 bool HandlePragmaMSSection(StringRef PragmaName,
7193 SourceLocation PragmaLocation);
7194 bool HandlePragmaMSSegment(StringRef PragmaName,
7195 SourceLocation PragmaLocation);
7198 bool HandlePragmaMSInitSeg(StringRef PragmaName,
7199 SourceLocation PragmaLocation);
7204 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
7205 SourceLocation PragmaLocation);
7206 bool HandlePragmaMSFunction(StringRef PragmaName,
7207 SourceLocation PragmaLocation);
7208 bool HandlePragmaMSAllocText(StringRef PragmaName,
7209 SourceLocation PragmaLocation);
7212 bool HandlePragmaMSOptimize(StringRef PragmaName,
7213 SourceLocation PragmaLocation);
7216 bool HandlePragmaMSIntrinsic(StringRef PragmaName,
7217 SourceLocation PragmaLocation);
7221 void HandlePragmaAlign();
7225 void HandlePragmaDump();
7229 void HandlePragmaWeak();
7233 void HandlePragmaWeakAlias();
7237 void HandlePragmaRedefineExtname();
7241 void HandlePragmaFPContract();
7245 void HandlePragmaFEnvAccess();
7249 void HandlePragmaFEnvRound();
7253 void HandlePragmaCXLimitedRange();
7257 void HandlePragmaFloatControl();
7261 void HandlePragmaFP();
7265 void HandlePragmaOpenCLExtension();
7269 StmtResult HandlePragmaCaptured();
7273 bool HandlePragmaLoopHint(LoopHint &Hint);
7275 bool ParsePragmaAttributeSubjectMatchRuleSet(
7277 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
7279 void HandlePragmaAttribute();
7285 void HandlePragmaExport();
7311 enum class ParsedStmtContext {
7314 AllowDeclarationsInC = 0x1,
7316 AllowStandaloneOpenMPDirectives = 0x2,
7323 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
7340 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt,
7395 ParseStatementOrDeclaration(
StmtVector &Stmts, ParsedStmtContext StmtCtx,
7399 StmtResult ParseStatementOrDeclarationAfterAttributes(
7400 StmtVector &Stmts, ParsedStmtContext StmtCtx,
7405 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
7419 ParsedStmtContext StmtCtx);
7428 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
7429 bool MissingCase =
false,
7439 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
7441 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
7467 StmtResult ParseCompoundStatement(
bool isStmtExpr,
unsigned ScopeFlags);
7472 void ParseCompoundStatementLeadingPragmas();
7474 void DiagnoseLabelAtEndOfCompoundStatement();
7484 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
7502 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
7576 void ParseForRangeInitializerAfterColon(ForRangeInit &FRI,
7622 StmtResult ParseBreakOrContinueStatement(
bool IsContinue);
7656 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
7703 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
7741 Decl *ParseFunctionStatementBody(
Decl *
Decl, ParseScope &BodyScope);
7750 Decl *ParseFunctionTryBlock(
Decl *
Decl, ParseScope &BodyScope);
7761 Decl *ParseFunctionBody(
Decl *D, ParseScope &BodyScope);
7767 bool trySkippingFunctionBody();
7775 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
7777 return isCXXDeclarationStatement(DisambiguatingWithExpression);
7785 bool isForInitDeclaration() {
7789 return Tok.is(tok::kw_using) ||
7790 isCXXSimpleDeclaration(
true);
7795 bool isForRangeIdentifier();
7812 unsigned &NumLineToksConsumed,
7813 bool IsUnevaluated);
7856 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
7872 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
7873 SmallVectorImpl<Expr *> &Constraints,
7874 SmallVectorImpl<Expr *> &Exprs);
7876 class GNUAsmQualifiers {
7877 unsigned Qualifiers = AQ_unspecified;
7886 static const char *getQualifierName(AQ Qualifier);
7887 bool setAsmQualifier(AQ Qualifier);
7888 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
7889 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
7890 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
7894 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
7896 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
7897 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
7910 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
7934 unsigned TemplateParameterDepth;
7937 class TemplateParameterDepthRAII {
7939 unsigned AddedLevels;
7942 explicit TemplateParameterDepthRAII(
unsigned &Depth)
7943 : Depth(Depth), AddedLevels(0) {}
7945 ~TemplateParameterDepthRAII() { Depth -= AddedLevels; }
7951 void addDepth(
unsigned D) {
7955 void setAddedDepth(
unsigned D) {
7956 Depth = Depth - AddedLevels + D;
7960 unsigned getDepth()
const {
return Depth; }
7961 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
7966 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
7972 bool DelayTemplateIdDestruction =
false;
7974 void MaybeDestroyTemplateIds() {
7975 if (DelayTemplateIdDestruction)
7977 if (!TemplateIds.empty() &&
7978 (Tok.is(tok::eof) || !PP.mightHavePendingAnnotationTokens()))
7979 DestroyTemplateIds();
7981 void DestroyTemplateIds();
7985 struct DestroyTemplateIdAnnotationsRAIIObj {
7988 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
7989 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
7992 struct DelayTemplateIdDestructionRAII {
7994 bool PrevDelayTemplateIdDestruction;
7996 DelayTemplateIdDestructionRAII(
Parser &Self,
7997 bool DelayTemplateIdDestruction) noexcept
7999 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
8000 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
8003 ~DelayTemplateIdDestructionRAII() noexcept {
8004 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
8009 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
8021 struct AngleBracketTracker {
8024 enum Priority :
unsigned short {
8026 PotentialTypo = 0x0,
8028 DependentName = 0x2,
8031 SpaceBeforeLess = 0x0,
8033 NoSpaceBeforeLess = 0x1,
8064 if (!Locs.empty() && Locs.back().isActive(P)) {
8065 if (Locs.back().Priority <= Prio) {
8067 Locs.back().LessLoc = LessLoc;
8068 Locs.back().Priority = Prio;
8071 Locs.push_back({
TemplateName, LessLoc, Prio, P.ParenCount,
8072 P.BracketCount, P.BraceCount});
8080 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
8087 if (!Locs.empty() && Locs.back().isActive(P))
8088 return &Locs.back();
8093 AngleBracketTracker AngleBrackets;
8098 struct ParsedTemplateInfo {
8099 ParsedTemplateInfo()
8103 bool isSpecialization,
8104 bool lastParameterListWasEmpty =
false)
8107 TemplateParams(TemplateParams),
8108 LastParameterListWasEmpty(lastParameterListWasEmpty) {}
8110 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
8111 SourceLocation TemplateLoc)
8113 TemplateParams(
nullptr), ExternLoc(ExternLoc),
8114 TemplateLoc(TemplateLoc), LastParameterListWasEmpty(
false) {}
8124 SourceLocation ExternLoc;
8128 SourceLocation TemplateLoc;
8131 bool LastParameterListWasEmpty;
8133 SourceRange getSourceRange() const LLVM_READONLY;
8137 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
8140 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
8142 static
void LateTemplateParserCallback(
void *P, LateParsedTemplate &LPT);
8150 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
8151 bool checkPotentialAngleBracketDelimiter(const AngleBracketTracker::Loc &,
8152 const Token &OpToken);
8153 bool checkPotentialAngleBracketDelimiter(const Token &OpToken) {
8154 if (
auto *Info = AngleBrackets.getCurrent(*
this))
8155 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
8166 SourceLocation &DeclEnd,
8167 ParsedAttributes &AccessAttrs);
8214 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
8226 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
8227 SmallVectorImpl<NamedDecl *> &TemplateParams,
8228 SourceLocation &LAngleLoc,
8229 SourceLocation &RAngleLoc);
8241 bool ParseTemplateParameterList(
unsigned Depth,
8242 SmallVectorImpl<NamedDecl *> &TemplateParams);
8244 enum class TPResult;
8248 TPResult isStartOfTemplateTypeParameter();
8272 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
8285 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
8301 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
8311 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
8315 bool isTypeConstraintAnnotation();
8327 bool TryAnnotateTypeConstraint();
8329 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
8330 SourceLocation CorrectLoc,
8331 bool AlreadyHasEllipsis,
8332 bool IdentifierHasName);
8333 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
8336 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
8353 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
8354 SourceLocation &RAngleLoc,
8355 bool ConsumeLastToken,
8356 bool ObjCGenericList);
8369 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
8370 SourceLocation &LAngleLoc,
8371 TemplateArgList &TemplateArgs,
8372 SourceLocation &RAngleLoc,
8417 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8419 bool AllowTypeAnnotation =
true,
8420 bool TypeConstraint =
false);
8438 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
8440 bool IsClassName =
false);
8452 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
8456 ParsedTemplateArgument ParseTemplateTemplateArgument();
8468 ParsedTemplateArgument ParseTemplateArgument();
8480 SourceLocation ExternLoc,
8481 SourceLocation TemplateLoc,
8482 SourceLocation &DeclEnd,
8483 ParsedAttributes &AccessAttrs,
8492 Decl *ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
8493 SourceLocation &DeclEnd);
8521 class TentativeParsingAction {
8523 PreferredTypeBuilder PrevPreferredType;
8525 size_t PrevTentativelyDeclaredIdentifierCount;
8526 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
8530 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
8531 : P(p), PrevPreferredType(P.PreferredType) {
8533 PrevTentativelyDeclaredIdentifierCount =
8534 P.TentativelyDeclaredIdentifiers.size();
8535 PrevParenCount = P.ParenCount;
8536 PrevBracketCount = P.BracketCount;
8537 PrevBraceCount = P.BraceCount;
8538 P.PP.EnableBacktrackAtThisPos(Unannotated);
8542 assert(isActive &&
"Parsing action was finished!");
8543 P.TentativelyDeclaredIdentifiers.resize(
8544 PrevTentativelyDeclaredIdentifierCount);
8545 P.PP.CommitBacktrackedTokens();
8549 assert(isActive &&
"Parsing action was finished!");
8551 P.PreferredType = PrevPreferredType;
8553 P.TentativelyDeclaredIdentifiers.resize(
8554 PrevTentativelyDeclaredIdentifierCount);
8555 P.ParenCount = PrevParenCount;
8556 P.BracketCount = PrevBracketCount;
8557 P.BraceCount = PrevBraceCount;
8560 ~TentativeParsingAction() {
8561 assert(!isActive &&
"Forgot to call Commit or Revert!");
8567 class RevertingTentativeParsingAction
8568 :
private Parser::TentativeParsingAction {
8570 using TentativeParsingAction::TentativeParsingAction;
8572 ~RevertingTentativeParsingAction() { Revert(); }
8607 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
8633 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
8646 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
8650 struct ConditionDeclarationOrInitStatementState;
8651 enum class ConditionOrInitStatement {
8678 ConditionOrInitStatement
8679 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
8680 bool CanBeForRangeDecl);
8706 return isCXXTypeId(Context, isAmbiguous);
8720 bool isEnumBase(
bool AllowSemi);
8840 TPResult BracedCastResult = TPResult::False,
8841 bool *InvalidAsDeclSpec =
nullptr);
8846 bool isCXXDeclarationSpecifierAType();
8852 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
8857 TPResult isExplicitBool();
8862 bool isTentativelyDeclared(IdentifierInfo *II);
8881 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
8889 TPResult TryParseTypeofSpecifier();
8893 TPResult TryParseProtocolQualifiers();
8895 TPResult TryParsePtrOperatorSeq();
8917 TPResult TryParseOperatorId();
8948 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
9005 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
9006 bool mayHaveDirectInit =
false,
9007 bool mayHaveTrailingReturnType =
false);
9028 TPResult TryParseParameterDeclarationClause(
9029 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
9046 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
9052 bool NameAfterArrowIsNonType();
9058 TPResult TryParseBracketDeclarator();
9062 TPResult TryConsumeDeclarationSpecifier();
9066 bool TrySkipAttributes();
9070 bool hasLambdaLikeContinuation();
9112 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
9113 bool OuterMightBeMessageSend =
false);