214 return Actions.incrementMSManglingNumber();
263 assert(!isTokenSpecial() &&
264 "Should consume special tokens with Consume*Token");
265 PrevTokLocation = Tok.getLocation();
267 return PrevTokLocation;
273 assert(!isTokenSpecial() &&
274 "Should consume special tokens with Consume*Token");
275 PrevTokLocation = Tok.getLocation();
283 Loc = PrevTokLocation;
292 return ConsumeParen();
293 if (isTokenBracket())
294 return ConsumeBracket();
296 return ConsumeBrace();
297 if (isTokenStringLiteral())
298 return ConsumeStringToken();
299 if (Tok.is(tok::code_completion))
300 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
301 : handleUnexpectedCodeCompletionToken();
302 if (Tok.isAnnotation())
303 return ConsumeAnnotationToken();
317 if (N == 0 || Tok.is(tok::eof))
319 return PP.LookAhead(N - 1);
328 if (!Tok.getAnnotationValue())
378 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
379 (Tok.is(tok::annot_template_id) &&
381 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
398 ParseScope(
const ParseScope &) =
delete;
399 void operator=(
const ParseScope &) =
delete;
406 bool BeforeCompoundStmt =
false)
408 if (EnteredScope && !BeforeCompoundStmt)
409 Self->EnterScope(ScopeFlags);
411 if (BeforeCompoundStmt)
412 Self->incrementMSManglingNumber();
414 this->Self = nullptr;
432 class MultiParseScope {
434 unsigned NumScopes = 0;
436 MultiParseScope(
const MultiParseScope &) =
delete;
441 Self.EnterScope(ScopeFlags);
483 static_cast<unsigned>(R));
538 unsigned short ParenCount = 0, BracketCount = 0,
BraceCount = 0;
539 unsigned short MisplacedModuleBeginCount = 0;
550 static constexpr int ScopeCacheSize = 16;
551 unsigned NumCachedScopes;
552 Scope *ScopeCache[ScopeCacheSize];
558 *Ident_GetExceptionCode;
561 *Ident_GetExceptionInfo;
563 IdentifierInfo *Ident__abnormal_termination, *Ident___abnormal_termination,
564 *Ident_AbnormalTermination;
573 std::unique_ptr<CommentHandler> CommentSemaHandler;
578 bool CalledSignatureHelp =
false;
586 bool SkipFunctionBodies;
593 bool isTokenParen()
const {
return Tok.isOneOf(tok::l_paren, tok::r_paren); }
595 bool isTokenBracket()
const {
596 return Tok.isOneOf(tok::l_square, tok::r_square);
599 bool isTokenBrace()
const {
return Tok.isOneOf(tok::l_brace, tok::r_brace); }
601 bool isTokenStringLiteral()
const {
605 bool isTokenSpecial()
const {
606 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
607 isTokenBrace() || Tok.is(tok::code_completion) || Tok.isAnnotation();
612 bool isTokenEqualOrEqualTypo();
616 void UnconsumeToken(Token &Consumed) {
618 PP.EnterToken(Consumed,
true);
620 PP.EnterToken(
Next,
true);
623 SourceLocation ConsumeAnnotationToken() {
624 assert(Tok.isAnnotation() &&
"wrong consume method");
625 SourceLocation Loc = Tok.getLocation();
626 PrevTokLocation = Tok.getAnnotationEndLoc();
633 SourceLocation ConsumeParen() {
634 assert(isTokenParen() &&
"wrong consume method");
635 if (Tok.getKind() == tok::l_paren)
637 else if (ParenCount) {
638 AngleBrackets.clear(*
this);
641 PrevTokLocation = Tok.getLocation();
643 return PrevTokLocation;
648 SourceLocation ConsumeBracket() {
649 assert(isTokenBracket() &&
"wrong consume method");
650 if (Tok.getKind() == tok::l_square)
652 else if (BracketCount) {
653 AngleBrackets.clear(*
this);
657 PrevTokLocation = Tok.getLocation();
659 return PrevTokLocation;
664 SourceLocation ConsumeBrace() {
665 assert(isTokenBrace() &&
"wrong consume method");
666 if (Tok.getKind() == tok::l_brace)
668 else if (BraceCount) {
669 AngleBrackets.clear(*
this);
673 PrevTokLocation = Tok.getLocation();
675 return PrevTokLocation;
682 SourceLocation ConsumeStringToken() {
683 assert(isTokenStringLiteral() &&
684 "Should only consume string literals with this method");
685 PrevTokLocation = Tok.getLocation();
687 return PrevTokLocation;
695 SourceLocation ConsumeCodeCompletionToken() {
696 assert(Tok.is(tok::code_completion));
697 PrevTokLocation = Tok.getLocation();
699 return PrevTokLocation;
707 SourceLocation handleUnexpectedCodeCompletionToken();
711 void cutOffParsing() {
712 if (PP.isCodeCompletionEnabled())
713 PP.setCodeCompletionReached();
715 Tok.setKind(tok::eof);
722 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
723 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
724 Kind == tok::annot_repl_input_end;
727 static void setTypeAnnotation(Token &Tok,
TypeResult T) {
728 assert((
T.isInvalid() ||
T.get()) &&
729 "produced a valid-but-null type annotation?");
730 Tok.setAnnotationValue(
T.isInvalid() ?
nullptr :
T.get().getAsOpaquePtr());
733 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
734 return static_cast<NamedDecl *
>(Tok.getAnnotationValue());
737 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
738 Tok.setAnnotationValue(ND);
741 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
742 return static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
745 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
746 Tok.setAnnotationValue(ND);
751 static ExprResult getExprAnnotation(
const Token &Tok) {
752 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
757 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
758 Tok.setAnnotationValue(ER.getAsOpaquePointer());
772 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
777 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
784 bool TryKeywordIdentFallback(
bool DisableKeyword);
789 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
800 unsigned Diag = diag::err_expected,
801 StringRef DiagMsg =
"");
808 bool ExpectAndConsumeSemi(
unsigned DiagID, StringRef TokenUsed =
"");
819 bool expectIdentifier();
822 enum class CompoundToken {
837 void checkCompoundToken(SourceLocation FirstTokLoc,
840 void diagnoseUseOfC11Keyword(
const Token &Tok);
843 class ParseScopeFlags {
845 unsigned OldFlags = 0;
846 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
847 void operator=(
const ParseScopeFlags &) =
delete;
852 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
866 void SuggestParentheses(SourceLocation Loc,
unsigned DK,
867 SourceRange ParenRange);
903 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
904 ParsedAttributes &DeclSpecAttrs,
905 ParsingDeclSpec *DS =
nullptr);
909 bool isDeclarationAfterDeclarator();
913 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
916 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
937 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
938 ParsedAttributes &DeclSpecAttrs,
942 void SkipFunctionBody();
944 struct ParsedTemplateInfo;
945 class LateParsedAttrList;
963 Decl *ParseFunctionDefinition(
964 ParsingDeclarator &D,
965 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
966 LateParsedAttrList *LateParsedAttrs =
nullptr);
970 void ParseKNRParamDeclarations(Declarator &D);
980 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
993 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
997 struct IfExistsCondition {
999 SourceLocation KeywordLoc;
1015 bool ParseMicrosoftIfExistsCondition(IfExistsCondition &
Result);
1016 void ParseMicrosoftIfExistsExternalDeclaration();
1055 Decl *ParseModuleImport(SourceLocation AtLoc,
1062 bool parseMisplacedModuleImport();
1064 bool tryParseMisplacedModuleImport() {
1066 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
1067 Kind == tok::annot_module_include)
1068 return parseMisplacedModuleImport();
1081 bool ParseModuleName(SourceLocation UseLoc,
1082 SmallVectorImpl<IdentifierLoc> &Path,
bool IsImport);
1086 void CodeCompleteDirective(
bool InConditional)
override;
1088 void CodeCompleteMacroName(
bool IsDefinition)
override;
1090 void CodeCompleteMacroArgument(IdentifierInfo *
Macro, MacroInfo *MacroInfo,
1091 unsigned ArgumentIndex)
override;
1092 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
1108 struct ParsingClass;
1118 class LateParsedDeclaration {
1120 virtual ~LateParsedDeclaration();
1122 virtual void ParseLexedMethodDeclarations();
1123 virtual void ParseLexedMemberInitializers();
1124 virtual void ParseLexedMethodDefs();
1125 virtual void ParseLexedAttributes();
1126 virtual void ParseLexedPragmas();
1131 class LateParsedClass :
public LateParsedDeclaration {
1133 LateParsedClass(
Parser *P, ParsingClass *
C);
1134 ~LateParsedClass()
override;
1136 void ParseLexedMethodDeclarations()
override;
1137 void ParseLexedMemberInitializers()
override;
1138 void ParseLexedMethodDefs()
override;
1139 void ParseLexedAttributes()
override;
1140 void ParseLexedPragmas()
override;
1143 LateParsedClass(
const LateParsedClass &) =
delete;
1144 LateParsedClass &operator=(
const LateParsedClass &) =
delete;
1148 ParsingClass *Class;
1157 struct LateParsedAttribute :
public LateParsedDeclaration {
1160 IdentifierInfo &AttrName;
1161 IdentifierInfo *MacroII =
nullptr;
1162 SourceLocation AttrNameLoc;
1163 SmallVector<Decl *, 2> Decls;
1165 explicit LateParsedAttribute(
Parser *P, IdentifierInfo &Name,
1167 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1169 void ParseLexedAttributes()
override;
1171 void addDecl(Decl *D) { Decls.push_back(D); }
1178 class LateParsedPragma :
public LateParsedDeclaration {
1185 : Self(P), AS(AS) {}
1187 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1191 void ParseLexedPragmas()
override;
1195 class LateParsedAttrList :
public SmallVector<LateParsedAttribute *, 2> {
1197 LateParsedAttrList(
bool PSoon =
false,
1198 bool LateAttrParseExperimentalExtOnly =
false)
1200 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1202 bool parseSoon() {
return ParseSoon; }
1205 bool lateAttrParseExperimentalExtOnly() {
1206 return LateAttrParseExperimentalExtOnly;
1211 bool LateAttrParseExperimentalExtOnly;
1217 struct LexedMethod :
public LateParsedDeclaration {
1222 explicit LexedMethod(
Parser *P, Decl *MD) : Self(P), D(MD) {}
1224 void ParseLexedMethodDefs()
override;
1231 struct LateParsedDefaultArgument {
1232 explicit LateParsedDefaultArgument(
1233 Decl *P, std::unique_ptr<CachedTokens> Toks =
nullptr)
1234 : Param(P), Toks(std::move(Toks)) {}
1243 std::unique_ptr<CachedTokens> Toks;
1250 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1251 explicit LateParsedMethodDeclaration(
Parser *P, Decl *M)
1252 : Self(P), Method(M), ExceptionSpecTokens(
nullptr) {}
1254 void ParseLexedMethodDeclarations()
override;
1266 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1276 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1277 LateParsedMemberInitializer(
Parser *P, Decl *FD) : Self(P), Field(FD) {}
1279 void ParseLexedMemberInitializers()
override;
1297 typedef SmallVector<LateParsedDeclaration *, 2>
1298 LateParsedDeclarationsContainer;
1312 const ParsedAttributesView &AccessAttrs,
1313 ParsingDeclarator &D,
1314 const ParsedTemplateInfo &TemplateInfo,
1315 const VirtSpecifiers &VS,
1316 SourceLocation PureSpecLoc);
1319 StringLiteral *ParseCXXDeletedFunctionMessage();
1324 void SkipDeletedFunctionBody();
1330 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1334 void ParseLexedAttributes(ParsingClass &
Class);
1337 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1345 void ParseLexedAttribute(LateParsedAttribute &LA,
bool EnterScope,
1352 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1353 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1358 void ParseLexedMethodDefs(ParsingClass &
Class);
1359 void ParseLexedMethodDef(LexedMethod &LM);
1365 void ParseLexedMemberInitializers(ParsingClass &
Class);
1366 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1400 ParsedAttributes *Attrs =
nullptr);
1406 IdentifierInfo *Ident_vector;
1407 IdentifierInfo *Ident_bool;
1408 IdentifierInfo *Ident_Bool;
1412 IdentifierInfo *Ident_pixel;
1415 IdentifierInfo *Ident_introduced;
1418 IdentifierInfo *Ident_deprecated;
1421 IdentifierInfo *Ident_obsoleted;
1424 IdentifierInfo *Ident_unavailable;
1427 IdentifierInfo *Ident_message;
1430 IdentifierInfo *Ident_strict;
1433 IdentifierInfo *Ident_replacement;
1436 IdentifierInfo *Ident_environment;
1439 IdentifierInfo *Ident_language, *Ident_defined_in,
1440 *Ident_generated_declaration, *Ident_USR;
1443 AttributeFactory AttrFactory;
1448 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
const char *&PrevSpec,
1453 if (Tok.getIdentifierInfo() != Ident_vector &&
1454 Tok.getIdentifierInfo() != Ident_bool &&
1455 Tok.getIdentifierInfo() != Ident_Bool &&
1456 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
1459 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
1465 bool TryAltiVecVectorToken() {
1467 Tok.getIdentifierInfo() != Ident_vector)
1469 return TryAltiVecVectorTokenOutOfLine();
1474 bool TryAltiVecVectorTokenOutOfLine();
1475 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
1476 const char *&PrevSpec,
unsigned &DiagID,
1479 void ParseLexedCAttributeList(LateParsedAttrList &LA,
bool EnterScope,
1480 ParsedAttributes *OutAttrs =
nullptr);
1487 void ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
1488 ParsedAttributes *OutAttrs =
nullptr);
1490 void ParseLexedPragmas(ParsingClass &
Class);
1491 void ParseLexedPragma(LateParsedPragma &LP);
1499 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1515 bool ConsumeFinalToken =
true) {
1516 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1527 bool ConsumeFinalToken =
true);
1535 enum class DeclSpecContext {
1540 DSC_alias_declaration,
1545 DSC_template_type_arg,
1546 DSC_objc_method_result,
1555 static bool isTypeSpecifier(DeclSpecContext DSC) {
1557 case DeclSpecContext::DSC_normal:
1558 case DeclSpecContext::DSC_template_param:
1559 case DeclSpecContext::DSC_template_arg:
1560 case DeclSpecContext::DSC_class:
1561 case DeclSpecContext::DSC_top_level:
1562 case DeclSpecContext::DSC_objc_method_result:
1563 case DeclSpecContext::DSC_condition:
1566 case DeclSpecContext::DSC_template_type_arg:
1567 case DeclSpecContext::DSC_type_specifier:
1568 case DeclSpecContext::DSC_conv_operator:
1569 case DeclSpecContext::DSC_trailing:
1570 case DeclSpecContext::DSC_alias_declaration:
1571 case DeclSpecContext::DSC_association:
1572 case DeclSpecContext::DSC_new:
1575 llvm_unreachable(
"Missing DeclSpecContext case");
1579 enum class AllowDefiningTypeSpec {
1596 static AllowDefiningTypeSpec
1597 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
1599 case DeclSpecContext::DSC_normal:
1600 case DeclSpecContext::DSC_class:
1601 case DeclSpecContext::DSC_top_level:
1602 case DeclSpecContext::DSC_alias_declaration:
1603 case DeclSpecContext::DSC_objc_method_result:
1604 return AllowDefiningTypeSpec::Yes;
1606 case DeclSpecContext::DSC_condition:
1607 case DeclSpecContext::DSC_template_param:
1608 return AllowDefiningTypeSpec::YesButInvalid;
1610 case DeclSpecContext::DSC_template_type_arg:
1611 case DeclSpecContext::DSC_type_specifier:
1612 return AllowDefiningTypeSpec::NoButErrorRecovery;
1614 case DeclSpecContext::DSC_association:
1615 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
1616 : AllowDefiningTypeSpec::Yes;
1618 case DeclSpecContext::DSC_trailing:
1619 case DeclSpecContext::DSC_conv_operator:
1620 case DeclSpecContext::DSC_template_arg:
1621 case DeclSpecContext::DSC_new:
1622 return AllowDefiningTypeSpec::No;
1624 llvm_unreachable(
"Missing DeclSpecContext case");
1628 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
1630 case DeclSpecContext::DSC_normal:
1631 case DeclSpecContext::DSC_class:
1632 case DeclSpecContext::DSC_top_level:
1635 case DeclSpecContext::DSC_alias_declaration:
1636 case DeclSpecContext::DSC_objc_method_result:
1637 case DeclSpecContext::DSC_condition:
1638 case DeclSpecContext::DSC_template_param:
1639 case DeclSpecContext::DSC_template_type_arg:
1640 case DeclSpecContext::DSC_type_specifier:
1641 case DeclSpecContext::DSC_trailing:
1642 case DeclSpecContext::DSC_association:
1643 case DeclSpecContext::DSC_conv_operator:
1644 case DeclSpecContext::DSC_template_arg:
1645 case DeclSpecContext::DSC_new:
1649 llvm_unreachable(
"Missing DeclSpecContext case");
1654 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
1656 case DeclSpecContext::DSC_normal:
1657 case DeclSpecContext::DSC_template_param:
1658 case DeclSpecContext::DSC_template_arg:
1659 case DeclSpecContext::DSC_class:
1660 case DeclSpecContext::DSC_top_level:
1661 case DeclSpecContext::DSC_condition:
1662 case DeclSpecContext::DSC_type_specifier:
1663 case DeclSpecContext::DSC_association:
1664 case DeclSpecContext::DSC_conv_operator:
1665 case DeclSpecContext::DSC_new:
1668 case DeclSpecContext::DSC_objc_method_result:
1669 case DeclSpecContext::DSC_template_type_arg:
1670 case DeclSpecContext::DSC_trailing:
1671 case DeclSpecContext::DSC_alias_declaration:
1674 llvm_unreachable(
"Missing DeclSpecContext case");
1679 getImplicitTypenameContext(DeclSpecContext DSC) {
1681 case DeclSpecContext::DSC_class:
1682 case DeclSpecContext::DSC_top_level:
1683 case DeclSpecContext::DSC_type_specifier:
1684 case DeclSpecContext::DSC_template_type_arg:
1685 case DeclSpecContext::DSC_trailing:
1686 case DeclSpecContext::DSC_alias_declaration:
1687 case DeclSpecContext::DSC_template_param:
1688 case DeclSpecContext::DSC_new:
1691 case DeclSpecContext::DSC_normal:
1692 case DeclSpecContext::DSC_objc_method_result:
1693 case DeclSpecContext::DSC_condition:
1694 case DeclSpecContext::DSC_template_arg:
1695 case DeclSpecContext::DSC_conv_operator:
1696 case DeclSpecContext::DSC_association:
1699 llvm_unreachable(
"Missing DeclSpecContext case");
1704 struct ForRangeInit {
1705 SourceLocation ColonLoc;
1707 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
1708 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
1710 struct ForRangeInfo : ForRangeInit {
1733 SourceLocation &DeclEnd,
1734 ParsedAttributes &DeclAttrs,
1735 ParsedAttributes &DeclSpecAttrs,
1736 SourceLocation *DeclSpecStart =
nullptr);
1763 ParsedAttributes &DeclAttrs,
1764 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
1765 ForRangeInit *FRI =
nullptr,
1766 SourceLocation *DeclSpecStart =
nullptr);
1776 ParsedAttributes &Attrs,
1777 ParsedTemplateInfo &TemplateInfo,
1778 SourceLocation *DeclEnd =
nullptr,
1779 ForRangeInit *FRI =
nullptr);
1805 Decl *ParseDeclarationAfterDeclarator(
1807 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1811 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
1812 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
1814 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1815 ForRangeInit *FRI =
nullptr);
1826 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
1828 DeclSpecContext DSC, ParsedAttributes &Attrs);
1838 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1840 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
1841 LateParsedAttrList *LateAttrs =
nullptr) {
1842 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
1843 getImplicitTypenameContext(DSC));
1876 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
1878 LateParsedAttrList *LateAttrs,
1888 bool DiagnoseMissingSemiAfterTagDefinition(
1890 LateParsedAttrList *LateAttrs =
nullptr);
1892 void ParseSpecifierQualifierList(
1894 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
1895 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
1906 void ParseSpecifierQualifierList(
1909 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
1943 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
1944 const ParsedTemplateInfo &TemplateInfo,
1959 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl,
1960 SkipBodyInfo *SkipBody =
nullptr);
1974 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
1975 RecordDecl *TagDecl);
2000 void ParseStructDeclaration(
2001 ParsingDeclSpec &DS,
2002 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2003 LateParsedAttrList *LateFieldAttrs =
nullptr);
2015 bool DisambiguatingWithExpression =
false);
2019 bool isTypeSpecifierQualifier();
2024 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2029 bool isConstructorDeclarator(
2032 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2036 void DiagnoseBitIntUse(
const Token &Tok);
2040 bool CheckProhibitedCXX11Attribute() {
2041 assert(Tok.is(tok::l_square));
2044 return DiagnoseProhibitedCXX11Attribute();
2055 bool DiagnoseProhibitedCXX11Attribute();
2057 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2058 SourceLocation CorrectLocation) {
2059 if (!Tok.isRegularKeywordAttribute() &&
2060 (Tok.isNot(tok::l_square) ||
NextToken().
isNot(tok::l_square)) &&
2061 Tok.isNot(tok::kw_alignas))
2063 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2070 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2071 SourceLocation CorrectLocation);
2081 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2085 void ProhibitAttributes(ParsedAttributes &Attrs,
2086 SourceLocation FixItLoc = SourceLocation()) {
2087 if (Attrs.Range.isInvalid())
2089 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2093 void ProhibitAttributes(ParsedAttributesView &Attrs,
2094 SourceLocation FixItLoc = SourceLocation()) {
2095 if (Attrs.Range.isInvalid())
2097 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2098 Attrs.clearListOnly();
2100 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2101 SourceLocation FixItLoc);
2109 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2110 unsigned KeywordDiagId,
2111 bool DiagnoseEmptyAttrs =
false,
2112 bool WarnOnUnknownAttrs =
false);
2116 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2118 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2121 ParseAttributeArgumentList(
const clang::IdentifierInfo &AttrName,
2122 SmallVectorImpl<Expr *> &Exprs,
2123 ParsedAttributeArgumentsProperties ArgsProperties);
2130 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2131 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2132 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2133 ParsedAttr::Form Form);
2135 enum ParseAttrKindMask {
2137 PAKM_Declspec = 1 << 1,
2138 PAKM_CXX11 = 1 << 2,
2157 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2158 LateParsedAttrList *LateAttrs =
nullptr);
2161 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2162 LateParsedAttrList *LateAttrs =
nullptr) {
2163 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2164 isAllowedCXX11AttributeSpecifier()) {
2165 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2171 void MaybeParseGNUAttributes(Declarator &D,
2172 LateParsedAttrList *LateAttrs =
nullptr) {
2173 if (Tok.is(tok::kw___attribute)) {
2174 ParsedAttributes Attrs(AttrFactory);
2175 ParseGNUAttributes(Attrs, LateAttrs, &D);
2176 D.takeAttributes(Attrs);
2180 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2181 LateParsedAttrList *LateAttrs =
nullptr) {
2182 if (Tok.is(tok::kw___attribute)) {
2183 ParseGNUAttributes(Attrs, LateAttrs);
2205 bool ParseSingleGNUAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc,
2206 LateParsedAttrList *LateAttrs =
nullptr,
2207 Declarator *D =
nullptr);
2252 void ParseGNUAttributes(ParsedAttributes &Attrs,
2253 LateParsedAttrList *LateAttrs =
nullptr,
2254 Declarator *D =
nullptr);
2258 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2259 SourceLocation AttrNameLoc,
2260 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2261 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2262 ParsedAttr::Form Form, Declarator *D);
2263 IdentifierLoc *ParseIdentifierLoc();
2266 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2267 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2268 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2269 ParsedAttr::Form Form);
2271 void MaybeParseCXX11Attributes(Declarator &D) {
2272 if (isAllowedCXX11AttributeSpecifier()) {
2273 ParsedAttributes Attrs(AttrFactory);
2274 ParseCXX11Attributes(Attrs);
2275 D.takeAttributes(Attrs);
2279 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2280 bool OuterMightBeMessageSend =
false) {
2281 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2282 ParseCXX11Attributes(Attrs);
2288 bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2289 bool AttrsParsed =
false;
2291 Tok.is(tok::l_square)) {
2292 ParsedAttributes AttrsWithRange(AttrFactory);
2293 ParseMicrosoftAttributes(AttrsWithRange);
2294 AttrsParsed = !AttrsWithRange.empty();
2295 Attrs.takeAllFrom(AttrsWithRange);
2299 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
2300 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
2301 ParseMicrosoftDeclSpecs(Attrs);
2315 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
2316 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
2317 SourceLocation AttrNameLoc,
2318 ParsedAttributes &Attrs);
2319 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
2320 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
2321 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2322 SourceLocation SkipExtendedMicrosoftTypeAttributes();
2324 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
2325 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
2326 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
2327 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
2328 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
2329 bool isHLSLQualifier(
const Token &Tok)
const;
2330 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
2342 VersionTuple ParseVersionTuple(SourceRange &Range);
2371 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
2372 SourceLocation AvailabilityLoc,
2373 ParsedAttributes &attrs,
2374 SourceLocation *endLoc,
2375 IdentifierInfo *ScopeName,
2376 SourceLocation ScopeLoc,
2377 ParsedAttr::Form Form);
2395 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
2397 ParsedAttributes &Attrs,
2398 SourceLocation *EndLoc,
2399 IdentifierInfo *ScopeName,
2400 SourceLocation ScopeLoc,
2401 ParsedAttr::Form Form);
2416 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
2417 SourceLocation ObjCBridgeRelatedLoc,
2418 ParsedAttributes &Attrs,
2419 SourceLocation *EndLoc,
2420 IdentifierInfo *ScopeName,
2421 SourceLocation ScopeLoc,
2422 ParsedAttr::Form Form);
2424 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
2425 SourceLocation AttrNameLoc,
2426 ParsedAttributes &Attrs,
2427 SourceLocation *EndLoc,
2428 IdentifierInfo *ScopeName,
2429 SourceLocation ScopeLoc,
2430 ParsedAttr::Form Form);
2432 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
2433 SourceLocation AttrNameLoc,
2434 ParsedAttributes &Attrs,
2435 SourceLocation *EndLoc,
2436 IdentifierInfo *ScopeName,
2437 SourceLocation ScopeLoc,
2438 ParsedAttr::Form Form);
2440 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
2441 SourceLocation AttrNameLoc,
2442 ParsedAttributes &Attrs,
2443 IdentifierInfo *ScopeName,
2444 SourceLocation ScopeLoc,
2445 ParsedAttr::Form Form);
2447 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
2453 void ParseBoundsAttribute(IdentifierInfo &AttrName,
2454 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
2455 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2456 ParsedAttr::Form Form);
2472 void ParseTypeofSpecifier(DeclSpec &DS);
2479 void ParseAtomicSpecifier(DeclSpec &DS);
2489 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
2490 SourceLocation &EllipsisLoc,
bool &IsType,
2503 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
2504 SourceLocation *endLoc =
nullptr);
2513 void ParsePtrauthQualifier(ParsedAttributes &Attrs);
2518 class DeclaratorScopeObj {
2525 DeclaratorScopeObj(
Parser &p, CXXScopeSpec &ss)
2526 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2528 void EnterDeclaratorScope() {
2529 assert(!EnteredScope &&
"Already entered the scope!");
2530 assert(SS.isSet() &&
"C++ scope was not set!");
2532 CreatedScope =
true;
2535 if (!P.Actions.ActOnCXXEnterDeclaratorScope(P.getCurScope(), SS))
2536 EnteredScope =
true;
2539 ~DeclaratorScopeObj() {
2541 assert(SS.isSet() &&
"C++ scope was cleared ?");
2542 P.Actions.ActOnCXXExitDeclaratorScope(P.getCurScope(), SS);
2550 void ParseDeclarator(Declarator &D);
2581 void ParseDeclaratorInternal(Declarator &D,
2582 DirectDeclParseFunction DirectDeclParser);
2584 enum AttrRequirements {
2585 AR_NoAttributesParsed = 0,
2586 AR_GNUAttributesParsedAndRejected = 1 << 0,
2587 AR_GNUAttributesParsed = 1 << 1,
2588 AR_CXX11AttributesParsed = 1 << 2,
2589 AR_DeclspecAttributesParsed = 1 << 3,
2590 AR_AllAttributesParsed = AR_GNUAttributesParsed | AR_CXX11AttributesParsed |
2591 AR_DeclspecAttributesParsed,
2592 AR_VendorAttributesParsed =
2593 AR_GNUAttributesParsed | AR_DeclspecAttributesParsed
2610 void ParseTypeQualifierListOpt(
2611 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2612 bool AtomicOrPtrauthAllowed =
true,
bool IdentifierRequired =
false,
2613 llvm::function_ref<
void()> CodeCompletionHandler = {});
2663 void ParseDirectDeclarator(Declarator &D);
2664 void ParseDecompositionDeclarator(Declarator &D);
2682 void ParseParenDeclarator(Declarator &D);
2707 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
2709 bool IsAmbiguous,
bool RequiresArg =
false);
2710 void InitCXXThisScopeForDeclaratorIfRelevant(
2711 const Declarator &D,
const DeclSpec &DS,
2712 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
2716 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2717 SourceLocation &RefQualifierLoc);
2724 bool isFunctionDeclaratorIdentifierList();
2738 void ParseFunctionDeclaratorIdentifierList(
2739 Declarator &D, SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
2740 void ParseParameterDeclarationClause(
2741 Declarator &D, ParsedAttributes &attrs,
2742 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2743 SourceLocation &EllipsisLoc) {
2744 return ParseParameterDeclarationClause(
2745 D.getContext(), attrs, ParamInfo, EllipsisLoc,
2746 D.getCXXScopeSpec().isSet() &&
2747 D.isFunctionDeclaratorAFunctionDeclaration());
2785 void ParseParameterDeclarationClause(
2787 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2788 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
2799 void ParseBracketDeclarator(Declarator &D);
2802 void ParseMisplacedBracketDeclarator(Declarator &D);
2813 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
2814 SourceLocation IncludeLoc);
2830 mutable IdentifierInfo *Ident_sealed;
2831 mutable IdentifierInfo *Ident_abstract;
2834 mutable IdentifierInfo *Ident_final;
2835 mutable IdentifierInfo *Ident_GNU_final;
2836 mutable IdentifierInfo *Ident_override;
2837 mutable IdentifierInfo *Ident_trivially_relocatable_if_eligible;
2838 mutable IdentifierInfo *Ident_replaceable_if_eligible;
2843 struct ParsingClass {
2844 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
2845 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
2846 TagOrTemplate(TagOrTemplate) {}
2850 bool TopLevelClass : 1;
2853 bool IsInterface : 1;
2856 Decl *TagOrTemplate;
2861 LateParsedDeclarationsContainer LateParsedDeclarations;
2867 std::stack<ParsingClass *> ClassStack;
2869 ParsingClass &getCurrentClass() {
2870 assert(!ClassStack.empty() &&
"No lexed method stacks!");
2871 return *ClassStack.top();
2875 class ParsingClassDefinition {
2881 ParsingClassDefinition(
Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
2883 : P(P), Popped(
false),
2884 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
2889 assert(!Popped &&
"Nested class has already been popped");
2891 P.PopParsingClass(State);
2894 ~ParsingClassDefinition() {
2896 P.PopParsingClass(State);
2912 bool Delayed, SourceRange &SpecificationRange,
2913 SmallVectorImpl<ParsedType> &DynamicExceptions,
2914 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2932 ParseDynamicExceptionSpecification(SourceRange &SpecificationRange,
2933 SmallVectorImpl<ParsedType> &Exceptions,
2934 SmallVectorImpl<SourceRange> &Ranges);
2941 TypeResult ParseTrailingReturnType(SourceRange &Range,
2942 bool MayBeFollowedByDirectInit);
2945 void ParseTrailingRequiresClause(Declarator &D);
2947 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2948 ParsedAttributes &AccessAttrs,
2951 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2952 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2953 SourceLocation StartLoc,
2954 SourceLocation EndLoc);
2961 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2962 bool OuterMightBeMessageSend =
false) {
2963 return (Tok.isRegularKeywordAttribute() ||
2964 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend) !=
2971 SourceLocation SkipCXX11Attributes();
2975 void DiagnoseAndSkipCXX11Attributes();
2977 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3006 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3008 SourceLocation *EndLoc =
nullptr);
3009 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3010 SourceLocation *EndLoc =
nullptr) {
3012 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3013 ReplayOpenMPAttributeTokens(OpenMPTokens);
3022 void ParseCXX11Attributes(ParsedAttributes &attrs);
3042 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3043 SourceLocation AttrNameLoc,
3044 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3045 IdentifierInfo *ScopeName,
3046 SourceLocation ScopeLoc,
3052 ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs, IdentifierInfo *AttrName,
3053 SourceLocation AttrNameLoc,
3054 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3055 SourceLocation *EndLoc, ParsedAttr::Form Form);
3066 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3067 SourceLocation &Loc,
3070 const IdentifierInfo *EnclosingScope =
nullptr);
3073 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3085 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3087 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3088 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3097 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3098 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3099 SourceLocation StartLoc,
3100 SourceLocation EndLoc);
3113 return isCXX11VirtSpecifier(Tok);
3123 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3124 SourceLocation FriendLoc);
3128 bool isCXX11FinalKeyword()
const;
3134 bool isClassCompatibleKeyword()
const;
3136 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3139 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3171 SourceLocation &DeclEnd,
3172 SourceLocation InlineLoc = SourceLocation());
3174 struct InnerNamespaceInfo {
3175 SourceLocation NamespaceLoc;
3176 SourceLocation InlineLoc;
3177 SourceLocation IdentLoc;
3178 IdentifierInfo *Ident;
3180 using InnerNamespaceInfoList = llvm::SmallVector<InnerNamespaceInfo, 4>;
3183 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3184 unsigned int index, SourceLocation &InlineLoc,
3185 ParsedAttributes &attrs,
3217 Decl *ParseExportDeclaration();
3223 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3238 SourceLocation &DeclEnd, ParsedAttributes &attrs);
3240 struct UsingDeclarator {
3241 SourceLocation TypenameLoc;
3244 SourceLocation EllipsisLoc;
3247 TypenameLoc = EllipsisLoc = SourceLocation();
3288 const ParsedTemplateInfo &TemplateInfo,
3289 SourceLocation UsingLoc,
3290 SourceLocation &DeclEnd,
3291 ParsedAttributes &Attrs,
3293 Decl *ParseAliasDeclarationAfterDeclarator(
3294 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3296 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3309 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3314 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3315 SourceLocation AliasLoc, IdentifierInfo *Alias,
3316 SourceLocation &DeclEnd);
3324 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3368 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3369 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3371 DeclSpecContext DSC, ParsedAttributes &Attributes);
3372 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3373 SourceLocation AttrFixitLoc,
unsigned TagType,
3384 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3385 SourceLocation AttrFixitLoc,
3386 ParsedAttributes &Attrs,
unsigned TagType,
3411 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3412 SourceLocation &EqualLoc);
3416 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3419 LateParsedAttrList &LateAttrs);
3424 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3425 VirtSpecifiers &VS);
3481 ParsedTemplateInfo &TemplateInfo,
3482 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3485 ParsedAttributes &AccessAttrs,
3511 void ParseConstructorInitializer(Decl *ConstructorDecl);
3533 void HandleMemberFunctionDeclDelays(Declarator &DeclaratorInfo,
3561 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3562 SourceLocation &EndLocation);
3574 void ParseBaseClause(Decl *ClassDecl);
3589 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3602 bool isCXX2CTriviallyRelocatableKeyword(Token Tok)
const;
3603 bool isCXX2CTriviallyRelocatableKeyword()
const;
3604 void ParseCXX2CTriviallyRelocatableSpecifier(SourceLocation &TRS);
3606 bool isCXX2CReplaceableKeyword(Token Tok)
const;
3607 bool isCXX2CReplaceableKeyword()
const;
3608 void ParseCXX2CReplaceableSpecifier(SourceLocation &MRS);
3613 bool isClassCompatibleKeyword(Token Tok)
const;
3615 void ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs);
3790 bool GreaterThanIsOperator;
3794 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
3813 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
3817 void DeallocateParsedClasses(ParsingClass *
Class);
4035 bool isAddressOfOperand,
bool &NotCastExpr,
4037 bool isVectorLiteral =
false,
4038 bool *NotPrimaryExpression =
nullptr);
4040 bool isAddressOfOperand =
false,
4043 bool isVectorLiteral =
false,
4044 bool *NotPrimaryExpression =
nullptr);
4047 bool isNotExpressionStart();
4051 bool isPostfixExpressionSuffixStart() {
4053 return (K == tok::l_square || K == tok::l_paren || K == tok::period ||
4054 K == tok::arrow || K == tok::plusplus || K == tok::minusminus);
4096 ExprResult ParseUnaryExprOrTypeTraitExpression();
4125 ExprResult ParseSYCLUniqueStableNameExpression();
4187 llvm::function_ref<
void()> ExpressionStarts =
4188 llvm::function_ref<
void()>(),
4189 bool FailImmediatelyOnInvalidExpr =
false);
4234 bool StopIfCastExpr,
4271 ExprResult ParseGenericSelectionExpression();
4290 void injectEmbedTokens();
4316 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
4318 Expr *ReceiverExpr);
4323 bool isKnownToBeDeclarationSpecifier() {
4337 bool isTypeIdForGenericSelection() {
4343 return isTypeSpecifierQualifier();
4349 bool isTypeIdUnambiguously() {
4354 return isTypeSpecifierQualifier();
4363 void ParseBlockId(SourceLocation CaretLoc);
4372 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
4373 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
4379 bool tryParseOpenMPArrayShapingCastPart();
4381 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
4434 bool ObjectHadErrors,
bool EnteringContext,
4435 bool AllowDestructorName,
bool AllowConstructorName,
4436 bool AllowDeductionGuide,
4437 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
4455 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
4456 Token &Replacement);
4507 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
4510 bool areTokensAdjacent(
const Token &A,
const Token &B);
4514 void CheckForTemplateAndDigraph(Token &
Next,
ParsedType ObjectTypePtr,
4515 bool EnteringContext, IdentifierInfo &II,
4570 bool ParseOptionalCXXScopeSpecifier(
4571 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
4572 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
4573 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
4574 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
4575 bool Disambiguation =
false);
4581 enum class LambdaIntroducerTentativeParse {
4659 ParseLambdaIntroducer(LambdaIntroducer &Intro,
4660 LambdaIntroducerTentativeParse *Tentative =
nullptr);
4664 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
4748 ExprResult ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc,
4803 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
4833 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
4848 bool ParseCXXTypeSpecifierSeq(
4866 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr *> &Exprs,
4878 void ParseDirectNewDeclarator(Declarator &D);
4911 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
4926 ExprResult ParseCXXDeleteExpression(
bool UseGlobal, SourceLocation Start);
4965 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
4969 ForRangeInfo *FRI =
nullptr,
4970 bool EnterForConditionScope =
false);
4972 ParsedAttributes &Attrs);
5019 bool isTypeIdInParens(
bool &isAmbiguous) {
5022 isAmbiguous =
false;
5023 return isTypeSpecifierQualifier();
5025 bool isTypeIdInParens() {
5027 return isTypeIdInParens(isAmbiguous);
5065 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
ParsedType ObjectType,
5066 bool ObjectHadErrors,
5067 SourceLocation TemplateKWLoc,
5068 IdentifierInfo *Name,
5069 SourceLocation NameLoc,
5070 bool EnteringContext, UnqualifiedId &Id,
5071 bool AssumeTemplateId);
5113 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
5171 bool MaybeParseHLSLAnnotations(Declarator &D,
5172 SourceLocation *EndLoc =
nullptr,
5173 bool CouldBeBitField =
false) {
5174 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5175 if (Tok.is(tok::colon)) {
5176 ParsedAttributes Attrs(AttrFactory);
5177 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
5178 D.takeAttributes(Attrs);
5184 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
5185 SourceLocation *EndLoc =
nullptr) {
5186 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
5187 if (Tok.is(tok::colon))
5188 ParseHLSLAnnotations(Attrs, EndLoc);
5191 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
5192 SourceLocation *EndLoc =
nullptr,
5193 bool CouldBeBitField =
false);
5194 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd, ParsedAttributes &Attrs);
5219 if (Tok.isNot(tok::l_brace))
5221 return ParseBraceInitializer();
5227 bool MayBeDesignationStart();
5245 struct DesignatorCompletionInfo {
5246 SmallVectorImpl<Expr *> &InitExprs;
5247 QualType PreferredBaseType;
5296 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
5301 typedef SmallVector<Expr *, 12> ExprVector;
5305 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
5322 friend class ObjCDeclContextSwitch;
5325 return Actions.ObjC().getObjCDeclContext();
5331 return Actions.getNullabilityKeyword(nullability);
5347 bool InMessageExpression;
5354 bool ParsingInObjCContainer;
5359 bool isObjCInstancetype() {
5361 if (
Tok.isAnnotation())
5363 if (!Ident_instancetype)
5365 return Tok.getIdentifierInfo() == Ident_instancetype;
5373 ObjCContainerDecl *DC;
5374 SaveAndRestore<bool> WithinObjCContainer;
5379 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
5381 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
5383 ~ObjCDeclContextSwitch() {
5385 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
5389 void CheckNestedObjCContexts(SourceLocation AtLoc);
5391 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
5409 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
5410 ParsedAttributes &DeclSpecAttrs);
5421 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
5454 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
5455 ParsedAttributes &prefixAttrs);
5461 ObjCTypeParamList *parseObjCTypeParamList();
5489 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
5491 SmallVectorImpl<IdentifierLoc> &protocolIdents, SourceLocation &rAngleLoc,
5492 bool mayBeProtocolList =
true);
5494 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
5495 SourceLocation atLoc,
5497 SmallVectorImpl<Decl *> &AllIvarDecls,
5498 bool RBraceMissing);
5523 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
5525 SourceLocation atLoc);
5532 bool ParseObjCProtocolReferences(
5533 SmallVectorImpl<Decl *> &P, SmallVectorImpl<SourceLocation> &PLocs,
5534 bool WarnOnDeclarations,
bool ForObjCContainer, SourceLocation &LAngleLoc,
5535 SourceLocation &EndProtoLoc,
bool consumeLastToken);
5546 void parseObjCTypeArgsOrProtocolQualifiers(
5547 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5548 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5549 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5550 SmallVectorImpl<SourceLocation> &protocolLocs,
5551 SourceLocation &protocolRAngleLoc,
bool consumeLastToken,
5552 bool warnOnIncompleteProtocols);
5556 void parseObjCTypeArgsAndProtocolQualifiers(
5557 ParsedType baseType, SourceLocation &typeArgsLAngleLoc,
5558 SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc,
5559 SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols,
5560 SmallVectorImpl<SourceLocation> &protocolLocs,
5561 SourceLocation &protocolRAngleLoc,
bool consumeLastToken);
5565 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
5569 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
5571 bool consumeLastToken,
5572 SourceLocation &endLoc);
5608 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
5609 ParsedAttributes &prefixAttrs);
5611 struct ObjCImplParsingDataRAII {
5615 typedef SmallVector<LexedMethod *, 8> LateParsedObjCMethodContainer;
5616 LateParsedObjCMethodContainer LateParsedObjCMethods;
5618 ObjCImplParsingDataRAII(
Parser &parser, Decl *D)
5619 : P(parser), Dcl(D), HasCFunction(
false) {
5620 P.CurParsedObjCImpl =
this;
5623 ~ObjCImplParsingDataRAII();
5625 void finish(SourceRange AtEnd);
5626 bool isFinished()
const {
return Finished; }
5631 ObjCImplParsingDataRAII *CurParsedObjCImpl;
5635 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
5649 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
5650 ParsedAttributes &Attrs);
5658 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
5673 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
5684 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
5696 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
5704 bool isTokIdentifier_in()
const;
5713 ParsedAttributes *ParamAttrs);
5727 Decl *ParseObjCMethodPrototype(
5729 bool MethodDefinition =
true);
5761 Decl *ParseObjCMethodDecl(
5764 bool MethodDefinition =
true);
5794 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
5800 Decl *ParseObjCMethodDefinition();
5804 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
5805 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
5812 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
5821 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
5830 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
5832 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
5833 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
5840 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
5846 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
5852 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
5858 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
5865 bool isSimpleObjCMessageExpression();
5920 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
5921 SourceLocation SuperLoc,
5923 Expr *ReceiverExpr);
5949 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
5954 enum class ParsedStmtContext;
5956 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
5957 ParsedStmtContext StmtCtx);
5972 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
5979 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
5986 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
5993 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
6020 bool isStartOfObjCClassMessageMissingOpenBracket();
6052 bool OpenACCDirectiveParsing =
false;
6056 bool AllowOpenACCArraySections =
false;
6060 class OpenACCArraySectionRAII {
6064 OpenACCArraySectionRAII(
Parser &P) : P(P) {
6065 assert(!P.AllowOpenACCArraySections);
6066 P.AllowOpenACCArraySections =
true;
6068 ~OpenACCArraySectionRAII() {
6069 assert(P.AllowOpenACCArraySections);
6070 P.AllowOpenACCArraySections =
false;
6077 struct OpenACCDirectiveParseInfo {
6079 SourceLocation StartLoc;
6080 SourceLocation DirLoc;
6081 SourceLocation LParenLoc;
6082 SourceLocation RParenLoc;
6083 SourceLocation EndLoc;
6084 SourceLocation MiscLoc;
6086 SmallVector<Expr *> Exprs;
6087 SmallVector<OpenACCClause *> Clauses;
6092 struct OpenACCWaitParseInfo {
6093 bool Failed =
false;
6094 Expr *DevNumExpr =
nullptr;
6095 SourceLocation QueuesLoc;
6096 SmallVector<Expr *> QueueIdExprs;
6098 SmallVector<Expr *> getAllExprs() {
6099 SmallVector<Expr *>
Out;
6100 Out.push_back(DevNumExpr);
6101 llvm::append_range(Out, QueueIdExprs);
6105 struct OpenACCCacheParseInfo {
6106 bool Failed =
false;
6107 SourceLocation ReadOnlyLoc;
6108 SmallVector<Expr *> Vars;
6113 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
6119 using OpenACCClauseParseResult =
6120 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
6122 OpenACCClauseParseResult OpenACCCanContinue();
6123 OpenACCClauseParseResult OpenACCCannotContinue();
6124 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
6128 OpenACCDirectiveParseInfo ParseOpenACCDirective();
6138 OpenACCCacheParseInfo ParseOpenACCCacheVarList();
6144 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
6170 OpenACCClauseParseResult
6171 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
6173 SourceLocation ClauseLoc);
6177 OpenACCClauseParseResult
6178 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
6188 SmallVector<OpenACCClause *>
6197 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation Loc,
6202 std::variant<std::monostate, StringLiteral *, IdentifierInfo *>
6203 ParseOpenACCBindClauseArgument();
6208 using OpenACCIntExprParseResult =
6209 std::pair<ExprResult, OpenACCParseCanContinue>;
6214 SourceLocation Loc);
6219 llvm::SmallVectorImpl<Expr *> &IntExprs);
6232 bool ParseOpenACCDeviceTypeList(llvm::SmallVector<IdentifierLoc> &Archs);
6246 SourceLocation Loc);
6261 llvm::SmallVectorImpl<Expr *> &SizeExprs);
6273 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
6274 llvm::SmallVectorImpl<OpenACCGangKind> &GKs,
6275 llvm::SmallVectorImpl<Expr *> &IntExprs);
6277 using OpenACCGangArgRes = std::pair<OpenACCGangKind, ExprResult>;
6281 OpenACCGangArgRes ParseOpenACCGangArg(SourceLocation GangLoc);
6285 ParseOpenACCAfterRoutineDecl(
AccessSpecifier &AS, ParsedAttributes &Attrs,
6287 OpenACCDirectiveParseInfo &DirInfo);
6288 StmtResult ParseOpenACCAfterRoutineStmt(OpenACCDirectiveParseInfo &DirInfo);
6306 bool OpenMPDirectiveParsing =
false;
6311 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
6314 if (!OpenMPTokens.empty()) {
6315 PP.EnterToken(Tok,
true);
6316 PP.EnterTokenStream(OpenMPTokens,
true,
6328 SourceLocation Loc);
6332 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
6333 llvm::omp::TraitSet
Set,
6334 llvm::omp::TraitSelector Selector,
6335 llvm::StringMap<SourceLocation> &Seen);
6338 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
6339 llvm::omp::TraitSet
Set,
6340 llvm::StringMap<SourceLocation> &Seen);
6343 void parseOMPTraitSetKind(OMPTraitSet &TISet,
6344 llvm::StringMap<SourceLocation> &Seen);
6347 void parseOMPContextProperty(OMPTraitSelector &TISelector,
6348 llvm::omp::TraitSet
Set,
6349 llvm::StringMap<SourceLocation> &Seen);
6356 void parseOMPContextSelector(OMPTraitSelector &TISelector,
6357 llvm::omp::TraitSet
Set,
6358 llvm::StringMap<SourceLocation> &SeenSelectors);
6365 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
6366 llvm::StringMap<SourceLocation> &SeenSets);
6373 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
6376 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
6380 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
6381 OMPTraitInfo *ParentTI);
6386 SourceLocation Loc);
6405 void ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
6406 SourceLocation Loc);
6409 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
6426 void ParseOpenMPClauses(OpenMPDirectiveKind DKind,
6427 SmallVectorImpl<clang::OMPClause *> &Clauses,
6428 SourceLocation Loc);
6431 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
6434 void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind BeginDKind,
6435 OpenMPDirectiveKind EndDKind,
6436 SourceLocation Loc);
6440 void skipUntilPragmaOpenMPEnd(OpenMPDirectiveKind DKind);
6446 void parseOMPEndDirective(OpenMPDirectiveKind BeginKind,
6447 OpenMPDirectiveKind ExpectedKind,
6448 OpenMPDirectiveKind FoundKind,
6449 SourceLocation MatchingLoc, SourceLocation FoundLoc,
6450 bool SkipUntilOpenMPEnd);
6491 AccessSpecifier &AS, ParsedAttributes &Attrs,
bool Delayed =
false,
6493 Decl *TagDecl =
nullptr);
6507 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(AccessSpecifier AS);
6511 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
6523 DeclGroupPtrTy ParseOpenMPDeclareMapperDirective(AccessSpecifier AS);
6526 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
6527 DeclarationName &Name,
6528 AccessSpecifier AS =
AS_none);
6542 bool ParseOpenMPSimpleVarList(
6543 OpenMPDirectiveKind Kind,
6544 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)>
6546 bool AllowScopeSpecifier);
6595 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
6596 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
6606 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
6607 OpenMPDirectiveKind DKind, SourceLocation Loc,
6608 bool ReadDirectiveWithinMetadirective);
6617 StmtResult ParseOpenMPInformationalDirective(
6618 ParsedStmtContext StmtCtx, OpenMPDirectiveKind DKind, SourceLocation Loc,
6619 bool ReadDirectiveWithinMetadirective);
6648 OMPClause *ParseOpenMPClause(OpenMPDirectiveKind DKind,
6703 OMPClause *ParseOpenMPSingleExprClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6733 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6758 OMPClause *ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
6763 OMPClause *ParseOpenMPSizesClause();
6766 OMPClause *ParseOpenMPPermutationClause();
6800 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
6870 OMPClause *ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
6884 SourceLocation &ClauseNameLoc,
6885 SourceLocation &OpenLoc,
6886 SourceLocation &CloseLoc,
6887 SmallVectorImpl<Expr *> &Exprs,
6888 bool ReqIntConst =
false);
6903 OMPClause *ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind);
6906 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
6937 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
6944 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
6951 bool IsAddressOfOperand =
false);
6955 SemaOpenMP::OpenMPVarListDataTy &
Data,
6956 const LangOptions &LangOpts);
6959 SmallVectorImpl<Expr *> &Vars,
6960 SemaOpenMP::OpenMPVarListDataTy &
Data);
6995 std::unique_ptr<PragmaHandler> AlignHandler;
6996 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
6997 std::unique_ptr<PragmaHandler> OptionsHandler;
6998 std::unique_ptr<PragmaHandler> PackHandler;
6999 std::unique_ptr<PragmaHandler> MSStructHandler;
7000 std::unique_ptr<PragmaHandler> UnusedHandler;
7001 std::unique_ptr<PragmaHandler> WeakHandler;
7002 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
7003 std::unique_ptr<PragmaHandler> FPContractHandler;
7004 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
7005 std::unique_ptr<PragmaHandler> OpenMPHandler;
7006 std::unique_ptr<PragmaHandler> OpenACCHandler;
7007 std::unique_ptr<PragmaHandler> PCSectionHandler;
7008 std::unique_ptr<PragmaHandler> MSCommentHandler;
7009 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
7010 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
7011 std::unique_ptr<PragmaHandler> FloatControlHandler;
7012 std::unique_ptr<PragmaHandler> MSPointersToMembers;
7013 std::unique_ptr<PragmaHandler> MSVtorDisp;
7014 std::unique_ptr<PragmaHandler> MSInitSeg;
7015 std::unique_ptr<PragmaHandler> MSDataSeg;
7016 std::unique_ptr<PragmaHandler> MSBSSSeg;
7017 std::unique_ptr<PragmaHandler> MSConstSeg;
7018 std::unique_ptr<PragmaHandler> MSCodeSeg;
7019 std::unique_ptr<PragmaHandler> MSSection;
7020 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
7021 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
7022 std::unique_ptr<PragmaHandler> MSIntrinsic;
7023 std::unique_ptr<PragmaHandler> MSFunction;
7024 std::unique_ptr<PragmaHandler> MSOptimize;
7025 std::unique_ptr<PragmaHandler> MSFenvAccess;
7026 std::unique_ptr<PragmaHandler> MSAllocText;
7027 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
7028 std::unique_ptr<PragmaHandler> OptimizeHandler;
7029 std::unique_ptr<PragmaHandler> LoopHintHandler;
7030 std::unique_ptr<PragmaHandler> UnrollHintHandler;
7031 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
7032 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
7033 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
7034 std::unique_ptr<PragmaHandler> FPHandler;
7035 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
7036 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
7037 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
7038 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
7039 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
7040 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
7041 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
7042 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
7045 void initializePragmaHandlers();
7048 void resetPragmaHandlers();
7055 void HandlePragmaUnused();
7059 void HandlePragmaVisibility();
7063 void HandlePragmaPack();
7067 void HandlePragmaMSStruct();
7069 void HandlePragmaMSPointersToMembers();
7071 void HandlePragmaMSVtorDisp();
7073 void HandlePragmaMSPragma();
7074 bool HandlePragmaMSSection(StringRef PragmaName,
7075 SourceLocation PragmaLocation);
7076 bool HandlePragmaMSSegment(StringRef PragmaName,
7077 SourceLocation PragmaLocation);
7080 bool HandlePragmaMSInitSeg(StringRef PragmaName,
7081 SourceLocation PragmaLocation);
7086 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
7087 SourceLocation PragmaLocation);
7088 bool HandlePragmaMSFunction(StringRef PragmaName,
7089 SourceLocation PragmaLocation);
7090 bool HandlePragmaMSAllocText(StringRef PragmaName,
7091 SourceLocation PragmaLocation);
7094 bool HandlePragmaMSOptimize(StringRef PragmaName,
7095 SourceLocation PragmaLocation);
7098 bool HandlePragmaMSIntrinsic(StringRef PragmaName,
7099 SourceLocation PragmaLocation);
7103 void HandlePragmaAlign();
7107 void HandlePragmaDump();
7111 void HandlePragmaWeak();
7115 void HandlePragmaWeakAlias();
7119 void HandlePragmaRedefineExtname();
7123 void HandlePragmaFPContract();
7127 void HandlePragmaFEnvAccess();
7131 void HandlePragmaFEnvRound();
7135 void HandlePragmaCXLimitedRange();
7139 void HandlePragmaFloatControl();
7143 void HandlePragmaFP();
7147 void HandlePragmaOpenCLExtension();
7151 StmtResult HandlePragmaCaptured();
7155 bool HandlePragmaLoopHint(LoopHint &Hint);
7157 bool ParsePragmaAttributeSubjectMatchRuleSet(
7159 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
7161 void HandlePragmaAttribute();
7187 enum class ParsedStmtContext {
7190 AllowDeclarationsInC = 0x1,
7192 AllowStandaloneOpenMPDirectives = 0x2,
7199 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
7216 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt,
7271 ParseStatementOrDeclaration(
StmtVector &Stmts, ParsedStmtContext StmtCtx,
7275 StmtResult ParseStatementOrDeclarationAfterAttributes(
7276 StmtVector &Stmts, ParsedStmtContext StmtCtx,
7281 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
7295 ParsedStmtContext StmtCtx);
7304 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
7305 bool MissingCase =
false,
7315 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
7317 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
7343 StmtResult ParseCompoundStatement(
bool isStmtExpr,
unsigned ScopeFlags);
7348 void ParseCompoundStatementLeadingPragmas();
7350 void DiagnoseLabelAtEndOfCompoundStatement();
7360 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
7378 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
7494 StmtResult ParseBreakOrContinueStatement(
bool IsContinue);
7501 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
7548 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
7586 Decl *ParseFunctionStatementBody(
Decl *
Decl, ParseScope &BodyScope);
7595 Decl *ParseFunctionTryBlock(
Decl *
Decl, ParseScope &BodyScope);
7601 bool trySkippingFunctionBody();
7609 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
7611 return isCXXDeclarationStatement(DisambiguatingWithExpression);
7619 bool isForInitDeclaration() {
7623 return Tok.is(tok::kw_using) ||
7624 isCXXSimpleDeclaration(
true);
7629 bool isForRangeIdentifier();
7646 unsigned &NumLineToksConsumed,
7647 bool IsUnevaluated);
7690 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
7706 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
7707 SmallVectorImpl<Expr *> &Constraints,
7708 SmallVectorImpl<Expr *> &Exprs);
7710 class GNUAsmQualifiers {
7711 unsigned Qualifiers = AQ_unspecified;
7720 static const char *getQualifierName(AQ Qualifier);
7721 bool setAsmQualifier(AQ Qualifier);
7722 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
7723 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
7724 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
7728 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
7730 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
7731 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
7744 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
7768 unsigned TemplateParameterDepth;
7771 class TemplateParameterDepthRAII {
7773 unsigned AddedLevels;
7776 explicit TemplateParameterDepthRAII(
unsigned &Depth)
7777 : Depth(Depth), AddedLevels(0) {}
7779 ~TemplateParameterDepthRAII() { Depth -= AddedLevels; }
7785 void addDepth(
unsigned D) {
7789 void setAddedDepth(
unsigned D) {
7790 Depth = Depth - AddedLevels + D;
7794 unsigned getDepth()
const {
return Depth; }
7795 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
7800 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
7806 bool DelayTemplateIdDestruction =
false;
7808 void MaybeDestroyTemplateIds() {
7809 if (DelayTemplateIdDestruction)
7811 if (!TemplateIds.empty() &&
7812 (Tok.is(tok::eof) || !PP.mightHavePendingAnnotationTokens()))
7813 DestroyTemplateIds();
7815 void DestroyTemplateIds();
7819 struct DestroyTemplateIdAnnotationsRAIIObj {
7822 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
7823 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
7826 struct DelayTemplateIdDestructionRAII {
7828 bool PrevDelayTemplateIdDestruction;
7830 DelayTemplateIdDestructionRAII(
Parser &Self,
7831 bool DelayTemplateIdDestruction) noexcept
7833 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
7834 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
7837 ~DelayTemplateIdDestructionRAII() noexcept {
7838 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
7843 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
7855 struct AngleBracketTracker {
7858 enum Priority :
unsigned short {
7860 PotentialTypo = 0x0,
7862 DependentName = 0x2,
7865 SpaceBeforeLess = 0x0,
7867 NoSpaceBeforeLess = 0x1,
7898 if (!Locs.empty() && Locs.back().isActive(P)) {
7899 if (Locs.back().Priority <= Prio) {
7901 Locs.back().LessLoc = LessLoc;
7902 Locs.back().Priority = Prio;
7905 Locs.push_back({
TemplateName, LessLoc, Prio, P.ParenCount,
7906 P.BracketCount, P.BraceCount});
7914 while (!Locs.empty() && Locs.back().isActiveOrNested(P))
7921 if (!Locs.empty() && Locs.back().isActive(P))
7922 return &Locs.back();
7927 AngleBracketTracker AngleBrackets;
7932 struct ParsedTemplateInfo {
7933 ParsedTemplateInfo()
7937 bool isSpecialization,
7938 bool lastParameterListWasEmpty =
false)
7941 TemplateParams(TemplateParams),
7942 LastParameterListWasEmpty(lastParameterListWasEmpty) {}
7944 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
7945 SourceLocation TemplateLoc)
7947 TemplateParams(
nullptr), ExternLoc(ExternLoc),
7948 TemplateLoc(TemplateLoc), LastParameterListWasEmpty(
false) {}
7958 SourceLocation ExternLoc;
7962 SourceLocation TemplateLoc;
7965 bool LastParameterListWasEmpty;
7967 SourceRange getSourceRange() const LLVM_READONLY;
7971 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
7974 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
7976 static
void LateTemplateParserCallback(
void *P, LateParsedTemplate &LPT);
7984 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
7985 bool checkPotentialAngleBracketDelimiter(const AngleBracketTracker::Loc &,
7986 const Token &OpToken);
7987 bool checkPotentialAngleBracketDelimiter(const Token &OpToken) {
7988 if (
auto *Info = AngleBrackets.getCurrent(*
this))
7989 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
8000 SourceLocation &DeclEnd,
8001 ParsedAttributes &AccessAttrs);
8048 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
8060 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
8061 SmallVectorImpl<NamedDecl *> &TemplateParams,
8062 SourceLocation &LAngleLoc,
8063 SourceLocation &RAngleLoc);
8075 bool ParseTemplateParameterList(
unsigned Depth,
8076 SmallVectorImpl<NamedDecl *> &TemplateParams);
8078 enum class TPResult;
8082 TPResult isStartOfTemplateTypeParameter();
8106 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
8119 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
8135 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
8145 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
8149 bool isTypeConstraintAnnotation();
8161 bool TryAnnotateTypeConstraint();
8163 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
8164 SourceLocation CorrectLoc,
8165 bool AlreadyHasEllipsis,
8166 bool IdentifierHasName);
8167 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
8170 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
8187 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
8188 SourceLocation &RAngleLoc,
8189 bool ConsumeLastToken,
8190 bool ObjCGenericList);
8203 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
8204 SourceLocation &LAngleLoc,
8205 TemplateArgList &TemplateArgs,
8206 SourceLocation &RAngleLoc,
8251 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8253 bool AllowTypeAnnotation =
true,
8254 bool TypeConstraint =
false);
8272 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
8274 bool IsClassName =
false);
8286 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
8290 ParsedTemplateArgument ParseTemplateTemplateArgument();
8302 ParsedTemplateArgument ParseTemplateArgument();
8314 SourceLocation ExternLoc,
8315 SourceLocation TemplateLoc,
8316 SourceLocation &DeclEnd,
8317 ParsedAttributes &AccessAttrs,
8326 Decl *ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
8327 SourceLocation &DeclEnd);
8355 class TentativeParsingAction {
8357 PreferredTypeBuilder PrevPreferredType;
8359 size_t PrevTentativelyDeclaredIdentifierCount;
8360 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
8364 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
8365 : P(p), PrevPreferredType(P.PreferredType) {
8367 PrevTentativelyDeclaredIdentifierCount =
8368 P.TentativelyDeclaredIdentifiers.size();
8369 PrevParenCount = P.ParenCount;
8370 PrevBracketCount = P.BracketCount;
8371 PrevBraceCount = P.BraceCount;
8372 P.PP.EnableBacktrackAtThisPos(Unannotated);
8376 assert(isActive &&
"Parsing action was finished!");
8377 P.TentativelyDeclaredIdentifiers.resize(
8378 PrevTentativelyDeclaredIdentifierCount);
8379 P.PP.CommitBacktrackedTokens();
8383 assert(isActive &&
"Parsing action was finished!");
8385 P.PreferredType = PrevPreferredType;
8387 P.TentativelyDeclaredIdentifiers.resize(
8388 PrevTentativelyDeclaredIdentifierCount);
8389 P.ParenCount = PrevParenCount;
8390 P.BracketCount = PrevBracketCount;
8391 P.BraceCount = PrevBraceCount;
8394 ~TentativeParsingAction() {
8395 assert(!isActive &&
"Forgot to call Commit or Revert!");
8401 class RevertingTentativeParsingAction
8402 :
private Parser::TentativeParsingAction {
8404 using TentativeParsingAction::TentativeParsingAction;
8406 ~RevertingTentativeParsingAction() { Revert(); }
8441 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
8467 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
8480 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
8484 struct ConditionDeclarationOrInitStatementState;
8485 enum class ConditionOrInitStatement {
8512 ConditionOrInitStatement
8513 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
8514 bool CanBeForRangeDecl);
8540 return isCXXTypeId(Context, isAmbiguous);
8554 bool isEnumBase(
bool AllowSemi);
8674 TPResult BracedCastResult = TPResult::False,
8675 bool *InvalidAsDeclSpec =
nullptr);
8680 bool isCXXDeclarationSpecifierAType();
8686 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
8691 TPResult isExplicitBool();
8696 bool isTentativelyDeclared(IdentifierInfo *II);
8715 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
8723 TPResult TryParseTypeofSpecifier();
8727 TPResult TryParseProtocolQualifiers();
8729 TPResult TryParsePtrOperatorSeq();
8751 TPResult TryParseOperatorId();
8782 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
8839 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
8840 bool mayHaveDirectInit =
false,
8841 bool mayHaveTrailingReturnType =
false);
8862 TPResult TryParseParameterDeclarationClause(
8863 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
8880 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
8886 bool NameAfterArrowIsNonType();
8892 TPResult TryParseBracketDeclarator();
8896 TPResult TryConsumeDeclarationSpecifier();
8900 bool TrySkipAttributes();
8942 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
8943 bool OuterMightBeMessageSend =
false);