13#ifndef LLVM_CLANG_PARSE_PARSER_H
14#define LLVM_CLANG_PARSE_PARSER_H
24#include "llvm/ADT/STLForwardCompat.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/Frontend/OpenMP/OMPContext.h"
27#include "llvm/Support/SaveAndRestore.h"
34class BalancedDelimiterTracker;
35class CorrectionCandidateCallback;
40class ParsingDeclRAIIObject;
42class ParsingDeclarator;
43class ParsingFieldDeclarator;
44class ColonProtectionRAIIObject;
45class InMessageExpressionRAIIObject;
46class PoisonSEHIdentifiersRAIIObject;
49class ObjCTypeParamList;
50struct OMPTraitProperty;
51struct OMPTraitSelector;
263 assert(!isTokenSpecial() &&
264 "Should consume special tokens with Consume*Token");
267 return PrevTokLocation;
273 assert(!isTokenSpecial() &&
274 "Should consume special tokens with Consume*Token");
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();
303 return ConsumeAnnotationToken();
317 if (N == 0 || Tok.
is(tok::eof))
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));
406 bool BeforeCompoundStmt =
false)
408 if (EnteredScope && !BeforeCompoundStmt)
409 Self->EnterScope(ScopeFlags);
411 if (BeforeCompoundStmt)
412 Self->incrementMSManglingNumber();
414 this->Self =
nullptr;
434 unsigned NumScopes = 0;
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) {
623 SourceLocation ConsumeAnnotationToken() {
633 SourceLocation ConsumeParen() {
634 assert(isTokenParen() &&
"wrong consume method");
635 if (Tok.
getKind() == tok::l_paren)
637 else if (ParenCount) {
638 AngleBrackets.clear(*
this);
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);
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);
675 return PrevTokLocation;
682 SourceLocation ConsumeStringToken() {
683 assert(isTokenStringLiteral() &&
684 "Should only consume string literals with this method");
687 return PrevTokLocation;
695 SourceLocation ConsumeCodeCompletionToken() {
696 assert(Tok.
is(tok::code_completion));
699 return PrevTokLocation;
707 SourceLocation handleUnexpectedCodeCompletionToken();
711 void cutOffParsing() {
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;
1087 void CodeCompleteInConditionalExclusion()
override;
1088 void CodeCompleteMacroName(
bool IsDefinition)
override;
1089 void CodeCompletePreprocessorExpression()
override;
1090 void CodeCompleteMacroArgument(IdentifierInfo *
Macro, MacroInfo *MacroInfo,
1091 unsigned ArgumentIndex)
override;
1092 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
1093 void CodeCompleteNaturalLanguage()
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 {
1161 IdentifierInfo *MacroII =
nullptr;
1162 SourceLocation AttrNameLoc;
1163 SmallVector<Decl *, 2> Decls;
1165 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1169 void ParseLexedAttributes()
override;
1171 void addDecl(Decl *
D) { Decls.push_back(
D); }
1178 class LateParsedPragma :
public LateParsedDeclaration {
1179 Parser *Self =
nullptr;
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;
1302 struct ReenterTemplateScopeRAII;
1306 struct ReenterClassScopeRAII;
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);
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);
2552 typedef void (Parser::*DirectDeclParseFunction)(
Declarator &);
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,
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);
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;
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,
5347 bool InMessageExpression;
5354 bool ParsingInObjCContainer;
5359 bool isObjCInstancetype() {
5361 if (Tok.isAnnotation())
5363 if (!Ident_instancetype)
5365 return Tok.getIdentifierInfo() == Ident_instancetype;
5371 class ObjCDeclContextSwitch {
5373 ObjCContainerDecl *DC;
5374 SaveAndRestore<bool> WithinObjCContainer;
5377 explicit ObjCDeclContextSwitch(Parser &p)
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);
5458 class ObjCTypeParamListScope;
5461 ObjCTypeParamList *parseObjCTypeParamList();
5489 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
5490 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
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);
6246 SourceLocation
Loc);
6273 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
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()) {
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);
6406 SourceLocation
Loc);
6409 void ParseOpenMPEndAssumesDirective(SourceLocation
Loc);
6427 SmallVectorImpl<clang::OMPClause *> &Clauses,
6428 SourceLocation
Loc);
6431 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
6436 SourceLocation
Loc);
6449 SourceLocation MatchingLoc, SourceLocation FoundLoc,
6450 bool SkipUntilOpenMPEnd);
6493 Decl *TagDecl =
nullptr);
6511 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
6527 DeclarationName &Name,
6542 bool ParseOpenMPSimpleVarList(
6544 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)>
6546 bool AllowScopeSpecifier);
6595 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
6596 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
6606 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
6608 bool ReadDirectiveWithinMetadirective);
6617 StmtResult ParseOpenMPInformationalDirective(
6619 bool ReadDirectiveWithinMetadirective);
6733 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
6763 OMPClause *ParseOpenMPSizesClause();
6766 OMPClause *ParseOpenMPPermutationClause();
6884 SourceLocation &ClauseNameLoc,
6885 SourceLocation &OpenLoc,
6886 SourceLocation &CloseLoc,
6887 SmallVectorImpl<Expr *> &Exprs,
6888 bool ReqIntConst =
false);
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();
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() &&
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 {
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});
7913 void clear(Parser &
P) {
7914 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
7920 Loc *getCurrent(Parser &
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;
7971 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
7974 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
7976 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
7982 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
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,
8252 UnqualifiedId &TemplateName,
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);
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
@ LLVM_MARK_AS_BITMASK_ENUM
Defines some OpenACC-specific enums and functions.
Defines and computes precedence levels for binary/ternary operators.
Defines the clang::Preprocessor interface.
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static bool isInvalid(LocType Loc, bool *Invalid)
Class to make it convenient to initialize TrapReason objects which can be used to attach the "trap re...
The result of parsing/analyzing an expression, statement etc.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Callback handler that receives notifications when performing code completion within the preprocessor.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
CompoundStmt - This represents a group of statements like { stmt stmt }.
static const TST TST_unspecified
Decl - This represents one declaration (or definition), e.g.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
This represents one expression.
One of these records is kept for each identifier that is lexed.
Represents the declaration of a label.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ObjCContainerDecl - Represents a container for method declarations.
Wrapper for void* pointer.
static OpaquePtr getFromOpaquePtr(void *P)
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
ParsedAttributes - A collection of parsed attributes.
Introduces zero or more scopes for parsing.
MultiParseScope(Parser &Self)
void Enter(unsigned ScopeFlags)
ParseScope - Introduces a new scope for parsing.
ParseScope(Parser *Self, unsigned ScopeFlags, bool EnteredScope=true, bool BeforeCompoundStmt=false)
Parser - This implements a parser for the C family of languages.
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr * > &Vars, SemaOpenMP::OpenMPVarListDataTy &Data)
Parses clauses with list.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation getEndOfPreviousToken() const
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope, ImplicitTypenameContext AllowImplicitTypename)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Preprocessor & getPreprocessor() const
bool parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data)
Parse map-type-modifiers in map clause.
Sema::FullExprArg FullExprArg
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
AttributeFactory & getAttrFactory()
void incrementMSManglingNumber() const
Sema & getActions() const
DiagnosticBuilder DiagCompat(unsigned CompatDiagId)
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
bool parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
ExprResult ParseConstantExpressionInExprEvalContext(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
SmallVector< Stmt *, 24 > StmtVector
A SmallVector of statements.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext=false)
friend class ColonProtectionRAIIObject
DeclGroupPtrTy ParseOpenACCDirectiveDecl(AccessSpecifier &AS, ParsedAttributes &Attrs, DeclSpec::TST TagType, Decl *TagDecl)
Parse OpenACC directive on a declaration.
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
const Token & GetLookAheadToken(unsigned N)
GetLookAheadToken - This peeks ahead N tokens and returns that token without consuming any tokens.
ExprResult ParseConstantExpression()
StmtResult ParseOpenACCDirectiveStmt()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
friend constexpr SkipUntilFlags operator|(SkipUntilFlags L, SkipUntilFlags R)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
ExprResult ParseArrayBoundExpression()
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
const TargetInfo & getTargetInfo() const
OpaquePtr< TemplateName > TemplateTy
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
const Token & getCurToken() const
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind...
friend class ObjCDeclContextSwitch
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
void ExitScope()
ExitScope - Pop a scope off the scope stack.
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
SourceLocation MisleadingIndentationElseLoc
The location of the first statement inside an else that might have a missleading indentation.
const LangOptions & getLangOpts() const
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result, Sema::ModuleImportState &ImportState)
Parse the first top-level declaration in a translation unit.
DiagnosticBuilder Diag(unsigned DiagID)
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
SkipUntilFlags
Control flags for SkipUntil functions.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
bool MightBeCXXScopeToken()
ExprResult ParseUnevaluatedStringLiteralExpression()
bool ParseOpenMPReservedLocator(OpenMPClauseKind Kind, SemaOpenMP::OpenMPVarListDataTy &Data, const LangOptions &LangOpts)
Parses a reserved locator like 'omp_all_memory'.
ObjCContainerDecl * getObjCDeclContext() const
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
friend class BalancedDelimiterTracker
bool TryConsumeToken(tok::TokenKind Expected, SourceLocation &Loc)
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
void Initialize()
Initialize - Warm up the parser.
unsigned ReenterTemplateScopes(MultiParseScope &S, Decl *D)
Re-enter a possible template scope, creating as many template parameter scopes as necessary.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
bool ParseOpenMPDeclareBeginVariantDirective(SourceLocation Loc)
Parses 'omp begin declare variant' directive.
Activates OpenACC parsing mode to preseve OpenACC specific annotation tokens.
Activates OpenMP parsing mode to preseve OpenMP specific annotation tokens.
Tracks expected type during expression parsing, for use in code completion.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void setCodeCompletionReached()
Note that we hit the code-completion point.
bool mightHavePendingAnnotationTokens()
Determine whether it's possible for a future call to Lex to produce an annotation token created by a ...
void Lex(Token &Result)
Lex the next token for this preprocessor.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
const TargetInfo & getTargetInfo() const
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
const LangOptions & getLangOpts() const
Scope - A scope is a transient data structure that is used while parsing the program.
ObjCContainerDecl * getObjCDeclContext() const
void startOpenMPLoop()
If the current region is a loop-based region, mark the start of the loop construct.
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
ProcessingContextState ParsingClassState
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
void incrementMSManglingNumber() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
bool Pop(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
CXX11AttributeKind
The kind of attribute specifier we have found.
@ NotAttributeSpecifier
This is not an attribute specifier.
@ AttributeSpecifier
This should be treated as an attribute-specifier.
@ InvalidAttributeSpecifier
The next tokens are '[[', but this is not an attribute-specifier.
TypoCorrectionTypeBehavior
If a typo should be encountered, should typo correction suggest type names, non type names,...
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
NullabilityKind
Describes the nullability of a particular type.
@ Success
Annotation was successful.
@ TentativeDecl
The identifier is a tentatively-declared name.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
IfExistsBehavior
Describes the behavior that should be taken for an __if_exists block.
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
@ Parse
Parse the block; this code is always used.
ActionResult< CXXCtorInitializer * > MemInitResult
@ Result
The result type of a method or function.
TentativeCXXTypeIdContext
Specifies the context in which type-id/expression disambiguation will occur.
@ AsGenericSelectionArgument
ParsedTemplateKind
The kind of template we are parsing.
@ Template
We are parsing a template declaration.
@ ExplicitSpecialization
We are parsing an explicit specialization.
@ ExplicitInstantiation
We are parsing an explicit instantiation.
@ NonTemplate
We are not parsing a template at all.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
ExtraSemiKind
The kind of extra semi diagnostic to emit.
@ AfterMemberFunctionDefinition
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
ActionResult< ParsedType > TypeResult
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
const FunctionProtoType * T
ParenExprKind
In a call to ParseParenExpression, are the initial parentheses part of an operator that requires the ...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
CastParseKind
Control what ParseCastExpression will parse.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ParenParseOption
ParenParseOption - Control what ParseParenExpression will parse.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< CXXBaseSpecifier * > BaseResult
unsigned short BracketCount
unsigned short BraceCount
AngleBracketTracker::Priority Priority
bool isActive(Parser &P) const
unsigned short ParenCount
bool isActiveOrNested(Parser &P) const