13#ifndef LLVM_CLANG_PARSE_PARSER_H
14#define LLVM_CLANG_PARSE_PARSER_H
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/Frontend/OpenMP/OMPContext.h"
26#include "llvm/Support/SaveAndRestore.h"
33 class BalancedDelimiterTracker;
34 class CorrectionCandidateCallback;
36 class DiagnosticBuilder;
39 class ParsingDeclRAIIObject;
40 class ParsingDeclSpec;
41 class ParsingDeclarator;
42 class ParsingFieldDeclarator;
43 class ColonProtectionRAIIObject;
44 class InMessageExpressionRAIIObject;
45 class PoisonSEHIdentifiersRAIIObject;
48 class ObjCTypeParamList;
49 struct OMPTraitProperty;
50 struct OMPTraitSelector;
85 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
86 unsigned short MisplacedModuleBeginCount = 0;
95 enum { ScopeCacheSize = 16 };
96 unsigned NumCachedScopes;
97 Scope *ScopeCache[ScopeCacheSize];
103 *Ident___exception_code,
104 *Ident_GetExceptionCode;
107 *Ident___exception_info,
108 *Ident_GetExceptionInfo;
111 *Ident___abnormal_termination,
112 *Ident_AbnormalTermination;
161 *Ident_generated_declaration, *Ident_USR;
174 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
176 std::unique_ptr<PragmaHandler> AlignHandler;
177 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
178 std::unique_ptr<PragmaHandler> OptionsHandler;
179 std::unique_ptr<PragmaHandler> PackHandler;
180 std::unique_ptr<PragmaHandler> MSStructHandler;
181 std::unique_ptr<PragmaHandler> UnusedHandler;
182 std::unique_ptr<PragmaHandler> WeakHandler;
183 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
184 std::unique_ptr<PragmaHandler> FPContractHandler;
185 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
186 std::unique_ptr<PragmaHandler> OpenMPHandler;
187 std::unique_ptr<PragmaHandler> OpenACCHandler;
188 std::unique_ptr<PragmaHandler> PCSectionHandler;
189 std::unique_ptr<PragmaHandler> MSCommentHandler;
190 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
191 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
192 std::unique_ptr<PragmaHandler> FloatControlHandler;
193 std::unique_ptr<PragmaHandler> MSPointersToMembers;
194 std::unique_ptr<PragmaHandler> MSVtorDisp;
195 std::unique_ptr<PragmaHandler> MSInitSeg;
196 std::unique_ptr<PragmaHandler> MSDataSeg;
197 std::unique_ptr<PragmaHandler> MSBSSSeg;
198 std::unique_ptr<PragmaHandler> MSConstSeg;
199 std::unique_ptr<PragmaHandler> MSCodeSeg;
200 std::unique_ptr<PragmaHandler> MSSection;
201 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
202 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
203 std::unique_ptr<PragmaHandler> MSIntrinsic;
204 std::unique_ptr<PragmaHandler> MSFunction;
205 std::unique_ptr<PragmaHandler> MSOptimize;
206 std::unique_ptr<PragmaHandler> MSFenvAccess;
207 std::unique_ptr<PragmaHandler> MSAllocText;
208 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
209 std::unique_ptr<PragmaHandler> OptimizeHandler;
210 std::unique_ptr<PragmaHandler> LoopHintHandler;
211 std::unique_ptr<PragmaHandler> UnrollHintHandler;
212 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
213 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
214 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
215 std::unique_ptr<PragmaHandler> FPHandler;
216 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
217 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
218 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
219 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
220 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
221 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
222 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
223 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
225 std::unique_ptr<CommentHandler> CommentSemaHandler;
231 bool GreaterThanIsOperator;
240 bool OpenMPDirectiveParsing =
false;
243 bool OpenACCDirectiveParsing =
false;
247 bool AllowOpenACCArraySections =
false;
251 class OpenACCArraySectionRAII {
255 OpenACCArraySectionRAII(
Parser &P) :
P(
P) {
256 assert(!
P.AllowOpenACCArraySections);
257 P.AllowOpenACCArraySections =
true;
259 ~OpenACCArraySectionRAII() {
260 assert(
P.AllowOpenACCArraySections);
261 P.AllowOpenACCArraySections =
false;
270 bool InMessageExpression;
275 bool CalledSignatureHelp =
false;
280 unsigned TemplateParameterDepth;
286 class TemplateParameterDepthRAII {
288 unsigned AddedLevels;
290 explicit TemplateParameterDepthRAII(
unsigned &Depth)
291 : Depth(Depth), AddedLevels(0) {}
293 ~TemplateParameterDepthRAII() {
294 Depth -= AddedLevels;
301 void addDepth(
unsigned D) {
305 void setAddedDepth(
unsigned D) {
306 Depth = Depth - AddedLevels +
D;
310 unsigned getDepth()
const {
return Depth; }
311 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
315 AttributeFactory AttrFactory;
319 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
325 bool DelayTemplateIdDestruction =
false;
327 void MaybeDestroyTemplateIds() {
328 if (DelayTemplateIdDestruction)
330 if (!TemplateIds.empty() &&
332 DestroyTemplateIds();
334 void DestroyTemplateIds();
338 struct DestroyTemplateIdAnnotationsRAIIObj {
341 DestroyTemplateIdAnnotationsRAIIObj(Parser &Self) : Self(Self) {}
342 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
345 struct DelayTemplateIdDestructionRAII {
347 bool PrevDelayTemplateIdDestruction;
349 DelayTemplateIdDestructionRAII(Parser &Self,
350 bool DelayTemplateIdDestruction) noexcept
352 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
353 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
356 ~DelayTemplateIdDestructionRAII() noexcept {
357 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
362 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
374 struct AngleBracketTracker {
384 SpaceBeforeLess = 0x0,
386 NoSpaceBeforeLess = 0x1,
417 if (!Locs.empty() && Locs.back().isActive(
P)) {
418 if (Locs.back().Priority <= Prio) {
420 Locs.back().LessLoc = LessLoc;
421 Locs.back().Priority = Prio;
424 Locs.push_back({TemplateName, LessLoc, Prio,
425 P.ParenCount,
P.BracketCount,
P.BraceCount});
432 void clear(Parser &
P) {
433 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
439 Loc *getCurrent(Parser &
P) {
440 if (!Locs.empty() && Locs.back().isActive(
P))
446 AngleBracketTracker AngleBrackets;
448 IdentifierInfo *getSEHExceptKeyword();
455 bool ParsingInObjCContainer;
461 bool SkipFunctionBodies;
466 SourceLocation ExprStatementTokLoc;
469 enum class ParsedStmtContext {
472 AllowDeclarationsInC = 0x1,
474 AllowStandaloneOpenMPDirectives = 0x2,
481 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
492 Parser(Preprocessor &PP, Sema &Actions,
bool SkipFunctionBodies);
549 assert(!isTokenSpecial() &&
550 "Should consume special tokens with Consume*Token");
553 return PrevTokLocation;
559 assert(!isTokenSpecial() &&
560 "Should consume special tokens with Consume*Token");
569 Loc = PrevTokLocation;
578 return ConsumeParen();
579 if (isTokenBracket())
580 return ConsumeBracket();
582 return ConsumeBrace();
583 if (isTokenStringLiteral())
584 return ConsumeStringToken();
585 if (Tok.
is(tok::code_completion))
586 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
587 : handleUnexpectedCodeCompletionToken();
589 return ConsumeAnnotationToken();
610 bool isTokenParen()
const {
611 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
614 bool isTokenBracket()
const {
615 return Tok.
isOneOf(tok::l_square, tok::r_square);
618 bool isTokenBrace()
const {
619 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
622 bool isTokenStringLiteral()
const {
626 bool isTokenSpecial()
const {
627 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
628 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
633 bool isTokenEqualOrEqualTypo();
637 void UnconsumeToken(Token &Consumed) {
644 SourceLocation ConsumeAnnotationToken() {
654 SourceLocation ConsumeParen() {
655 assert(isTokenParen() &&
"wrong consume method");
656 if (Tok.
getKind() == tok::l_paren)
658 else if (ParenCount) {
659 AngleBrackets.clear(*
this);
664 return PrevTokLocation;
669 SourceLocation ConsumeBracket() {
670 assert(isTokenBracket() &&
"wrong consume method");
671 if (Tok.
getKind() == tok::l_square)
673 else if (BracketCount) {
674 AngleBrackets.clear(*
this);
680 return PrevTokLocation;
685 SourceLocation ConsumeBrace() {
686 assert(isTokenBrace() &&
"wrong consume method");
687 if (Tok.
getKind() == tok::l_brace)
689 else if (BraceCount) {
690 AngleBrackets.clear(*
this);
696 return PrevTokLocation;
703 SourceLocation ConsumeStringToken() {
704 assert(isTokenStringLiteral() &&
705 "Should only consume string literals with this method");
708 return PrevTokLocation;
716 SourceLocation ConsumeCodeCompletionToken() {
717 assert(Tok.
is(tok::code_completion));
720 return PrevTokLocation;
728 SourceLocation handleUnexpectedCodeCompletionToken();
732 void cutOffParsing() {
743 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
744 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
745 Kind == tok::annot_repl_input_end;
755 void initializePragmaHandlers();
758 void resetPragmaHandlers();
761 void HandlePragmaUnused();
765 void HandlePragmaVisibility();
769 void HandlePragmaPack();
773 void HandlePragmaMSStruct();
775 void HandlePragmaMSPointersToMembers();
777 void HandlePragmaMSVtorDisp();
779 void HandlePragmaMSPragma();
780 bool HandlePragmaMSSection(StringRef PragmaName,
781 SourceLocation PragmaLocation);
782 bool HandlePragmaMSSegment(StringRef PragmaName,
783 SourceLocation PragmaLocation);
784 bool HandlePragmaMSInitSeg(StringRef PragmaName,
785 SourceLocation PragmaLocation);
786 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
787 SourceLocation PragmaLocation);
788 bool HandlePragmaMSFunction(StringRef PragmaName,
789 SourceLocation PragmaLocation);
790 bool HandlePragmaMSAllocText(StringRef PragmaName,
791 SourceLocation PragmaLocation);
792 bool HandlePragmaMSOptimize(StringRef PragmaName,
793 SourceLocation PragmaLocation);
797 void HandlePragmaAlign();
801 void HandlePragmaDump();
805 void HandlePragmaWeak();
809 void HandlePragmaWeakAlias();
813 void HandlePragmaRedefineExtname();
817 void HandlePragmaFPContract();
821 void HandlePragmaFEnvAccess();
825 void HandlePragmaFEnvRound();
829 void HandlePragmaCXLimitedRange();
833 void HandlePragmaFloatControl();
837 void HandlePragmaFP();
841 void HandlePragmaOpenCLExtension();
849 bool HandlePragmaLoopHint(LoopHint &Hint);
851 bool ParsePragmaAttributeSubjectMatchRuleSet(
853 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
855 void HandlePragmaAttribute();
864 const Token &GetLookAheadToken(
unsigned N) {
865 if (N == 0 || Tok.
is(tok::eof))
return Tok;
885 assert((
T.isInvalid() ||
T.get()) &&
886 "produced a valid-but-null type annotation?");
890 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
891 return static_cast<NamedDecl*
>(Tok.getAnnotationValue());
894 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
895 Tok.setAnnotationValue(ND);
898 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
899 return static_cast<IdentifierInfo*
>(Tok.getAnnotationValue());
902 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
903 Tok.setAnnotationValue(ND);
908 static ExprResult getExprAnnotation(
const Token &Tok) {
909 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
914 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
915 Tok.setAnnotationValue(ER.getAsOpaquePointer());
925 CXXScopeSpec &SS,
bool IsNewScope,
931 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
932 (Tok.is(tok::annot_template_id) &&
934 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
941 enum AnnotatedNameKind {
955 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
960 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
965 bool TryAltiVecToken(DeclSpec &DS, SourceLocation
Loc,
966 const char *&PrevSpec,
unsigned &DiagID,
971 if (Tok.getIdentifierInfo() != Ident_vector &&
972 Tok.getIdentifierInfo() != Ident_bool &&
973 Tok.getIdentifierInfo() != Ident_Bool &&
974 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
977 return TryAltiVecTokenOutOfLine(DS,
Loc, PrevSpec, DiagID,
isInvalid);
983 bool TryAltiVecVectorToken() {
985 Tok.getIdentifierInfo() != Ident_vector)
return false;
986 return TryAltiVecVectorTokenOutOfLine();
989 bool TryAltiVecVectorTokenOutOfLine();
990 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation
Loc,
991 const char *&PrevSpec,
unsigned &DiagID,
997 bool isObjCInstancetype() {
999 if (Tok.isAnnotation())
1001 if (!Ident_instancetype)
1003 return Tok.getIdentifierInfo() == Ident_instancetype;
1011 bool TryKeywordIdentFallback(
bool DisableKeyword);
1014 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
1029 class TentativeParsingAction {
1031 PreferredTypeBuilder PrevPreferredType;
1033 size_t PrevTentativelyDeclaredIdentifierCount;
1034 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
1038 explicit TentativeParsingAction(Parser &p,
bool Unannotated =
false)
1039 :
P(p), PrevPreferredType(
P.PreferredType) {
1041 PrevTentativelyDeclaredIdentifierCount =
1042 P.TentativelyDeclaredIdentifiers.size();
1043 PrevParenCount =
P.ParenCount;
1044 PrevBracketCount =
P.BracketCount;
1045 PrevBraceCount =
P.BraceCount;
1046 P.PP.EnableBacktrackAtThisPos(Unannotated);
1050 assert(isActive &&
"Parsing action was finished!");
1051 P.TentativelyDeclaredIdentifiers.resize(
1052 PrevTentativelyDeclaredIdentifierCount);
1053 P.PP.CommitBacktrackedTokens();
1057 assert(isActive &&
"Parsing action was finished!");
1059 P.PreferredType = PrevPreferredType;
1061 P.TentativelyDeclaredIdentifiers.resize(
1062 PrevTentativelyDeclaredIdentifierCount);
1063 P.ParenCount = PrevParenCount;
1064 P.BracketCount = PrevBracketCount;
1065 P.BraceCount = PrevBraceCount;
1068 ~TentativeParsingAction() {
1069 assert(!isActive &&
"Forgot to call Commit or Revert!");
1074 class RevertingTentativeParsingAction
1075 :
private Parser::TentativeParsingAction {
1077 using TentativeParsingAction::TentativeParsingAction;
1079 ~RevertingTentativeParsingAction() { Revert(); }
1087 ObjCContainerDecl *DC;
1088 SaveAndRestore<bool> WithinObjCContainer;
1090 explicit ObjCDeclContextSwitch(Parser &p)
1092 WithinObjCContainer(
P.ParsingInObjCContainer, DC != nullptr) {
1094 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
1096 ~ObjCDeclContextSwitch() {
1098 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
1111 unsigned Diag = diag::err_expected,
1112 StringRef DiagMsg =
"");
1119 bool ExpectAndConsumeSemi(
unsigned DiagID , StringRef TokenUsed =
"");
1122 enum ExtraSemiKind {
1123 OutsideFunction = 0,
1125 InstanceVariableList = 2,
1126 AfterMemberFunctionDefinition = 3
1138 bool expectIdentifier();
1141 enum class CompoundToken {
1156 void checkCompoundToken(SourceLocation FirstTokLoc,
1159 void diagnoseUseOfC11Keyword(
const Token &Tok);
1181 bool BeforeCompoundStmt =
false)
1183 if (EnteredScope && !BeforeCompoundStmt)
1184 Self->EnterScope(ScopeFlags);
1186 if (BeforeCompoundStmt)
1187 Self->incrementMSManglingNumber();
1189 this->Self =
nullptr;
1211 unsigned NumScopes = 0;
1218 Self.EnterScope(ScopeFlags);
1243 class ParseScopeFlags {
1245 unsigned OldFlags = 0;
1246 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1247 void operator=(
const ParseScopeFlags &) =
delete;
1250 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1258 DiagnosticBuilder
Diag(SourceLocation
Loc,
unsigned DiagID);
1259 DiagnosticBuilder
Diag(
const Token &Tok,
unsigned DiagID);
1261 return Diag(Tok, DiagID);
1282 static_cast<unsigned>(R));
1324 struct ParsingClass;
1334 class LateParsedDeclaration {
1336 virtual ~LateParsedDeclaration();
1338 virtual void ParseLexedMethodDeclarations();
1339 virtual void ParseLexedMemberInitializers();
1340 virtual void ParseLexedMethodDefs();
1341 virtual void ParseLexedAttributes();
1342 virtual void ParseLexedPragmas();
1347 class LateParsedClass :
public LateParsedDeclaration {
1349 LateParsedClass(
Parser *
P, ParsingClass *
C);
1350 ~LateParsedClass()
override;
1352 void ParseLexedMethodDeclarations()
override;
1353 void ParseLexedMemberInitializers()
override;
1354 void ParseLexedMethodDefs()
override;
1355 void ParseLexedAttributes()
override;
1356 void ParseLexedPragmas()
override;
1359 LateParsedClass(
const LateParsedClass &) =
delete;
1360 LateParsedClass &operator=(
const LateParsedClass &) =
delete;
1364 ParsingClass *
Class;
1373 struct LateParsedAttribute :
public LateParsedDeclaration {
1376 IdentifierInfo &AttrName;
1377 IdentifierInfo *MacroII =
nullptr;
1378 SourceLocation AttrNameLoc;
1379 SmallVector<Decl*, 2> Decls;
1381 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1383 : Self(
P), AttrName(Name), AttrNameLoc(
Loc) {}
1385 void ParseLexedAttributes()
override;
1387 void addDecl(Decl *
D) { Decls.push_back(
D); }
1394 class LateParsedPragma :
public LateParsedDeclaration {
1395 Parser *Self =
nullptr;
1401 : Self(
P), AS(AS) {}
1403 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1407 void ParseLexedPragmas()
override;
1411 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1413 LateParsedAttrList(
bool PSoon =
false,
1414 bool LateAttrParseExperimentalExtOnly =
false)
1416 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1418 bool parseSoon() {
return ParseSoon; }
1421 bool lateAttrParseExperimentalExtOnly() {
1422 return LateAttrParseExperimentalExtOnly;
1427 bool LateAttrParseExperimentalExtOnly;
1433 struct LexedMethod :
public LateParsedDeclaration {
1438 explicit LexedMethod(Parser *
P, Decl *MD) : Self(
P),
D(MD) {}
1440 void ParseLexedMethodDefs()
override;
1447 struct LateParsedDefaultArgument {
1448 explicit LateParsedDefaultArgument(Decl *
P,
1449 std::unique_ptr<CachedTokens> Toks =
nullptr)
1450 : Param(
P), Toks(
std::move(Toks)) { }
1459 std::unique_ptr<CachedTokens> Toks;
1466 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1467 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1468 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1470 void ParseLexedMethodDeclarations()
override;
1482 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1492 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1493 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1496 void ParseLexedMemberInitializers()
override;
1514 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1519 struct ParsingClass {
1520 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1521 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1522 TagOrTemplate(TagOrTemplate) {}
1526 bool TopLevelClass : 1;
1529 bool IsInterface : 1;
1532 Decl *TagOrTemplate;
1537 LateParsedDeclarationsContainer LateParsedDeclarations;
1543 std::stack<ParsingClass *> ClassStack;
1545 ParsingClass &getCurrentClass() {
1546 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1547 return *ClassStack.top();
1551 class ParsingClassDefinition {
1557 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1560 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1565 assert(!Popped &&
"Nested class has already been popped");
1567 P.PopParsingClass(State);
1570 ~ParsingClassDefinition() {
1572 P.PopParsingClass(State);
1579 struct ParsedTemplateInfo {
1580 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1583 bool isSpecialization,
1584 bool lastParameterListWasEmpty =
false)
1585 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1586 TemplateParams(TemplateParams),
1587 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1589 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1590 SourceLocation TemplateLoc)
1591 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1592 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1593 LastParameterListWasEmpty(
false){ }
1602 ExplicitSpecialization,
1604 ExplicitInstantiation
1613 SourceLocation ExternLoc;
1617 SourceLocation TemplateLoc;
1620 bool LastParameterListWasEmpty;
1626 struct ReenterTemplateScopeRAII;
1627 struct ReenterClassScopeRAII;
1629 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1630 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1632 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1634 Sema::ParsingClassState
1635 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1636 void DeallocateParsedClasses(ParsingClass *
Class);
1637 void PopParsingClass(Sema::ParsingClassState);
1639 enum CachedInitKind {
1640 CIK_DefaultArgument,
1641 CIK_DefaultInitializer
1645 const ParsedAttributesView &AccessAttrs,
1646 ParsingDeclarator &
D,
1647 const ParsedTemplateInfo &TemplateInfo,
1648 const VirtSpecifiers &VS,
1649 SourceLocation PureSpecLoc);
1650 StringLiteral *ParseCXXDeletedFunctionMessage();
1651 void SkipDeletedFunctionBody();
1652 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1653 void ParseLexedAttributes(ParsingClass &
Class);
1654 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *
D,
1656 void ParseLexedCAttributeList(LateParsedAttrList &LA,
bool EnterScope,
1657 ParsedAttributes *OutAttrs =
nullptr);
1658 void ParseLexedAttribute(LateParsedAttribute &LA,
1660 void ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
1661 ParsedAttributes *OutAttrs =
nullptr);
1662 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1663 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1664 void ParseLexedMethodDefs(ParsingClass &
Class);
1665 void ParseLexedMethodDef(LexedMethod &LM);
1666 void ParseLexedMemberInitializers(ParsingClass &
Class);
1667 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1668 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1669 void ParseLexedPragmas(ParsingClass &
Class);
1670 void ParseLexedPragma(LateParsedPragma &LP);
1671 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1672 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1677 bool ConsumeFinalToken =
true) {
1678 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1683 bool ConsumeFinalToken =
true);
1687 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1688 ParsedAttributes &DeclSpecAttrs,
1689 ParsingDeclSpec *DS =
nullptr);
1690 bool isDeclarationAfterDeclarator();
1691 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1693 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1695 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1696 ParsedAttributes &DeclSpecAttrs,
1697 ParsingDeclSpec &DS,
1700 void SkipFunctionBody();
1701 Decl *ParseFunctionDefinition(ParsingDeclarator &
D,
1702 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1703 LateParsedAttrList *LateParsedAttrs =
nullptr);
1704 void ParseKNRParamDeclarations(Declarator &
D);
1706 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1707 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1711 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1712 ParsedAttributes &DeclSpecAttrs);
1713 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1714 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1715 ParsedAttributes &prefixAttrs);
1716 class ObjCTypeParamListScope;
1717 ObjCTypeParamList *parseObjCTypeParamList();
1718 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1719 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1720 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1721 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1723 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1724 SourceLocation atLoc,
1726 SmallVectorImpl<Decl *> &AllIvarDecls,
1727 bool RBraceMissing);
1728 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1730 SourceLocation atLoc);
1731 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1732 SmallVectorImpl<SourceLocation> &PLocs,
1733 bool WarnOnDeclarations,
1734 bool ForObjCContainer,
1735 SourceLocation &LAngleLoc,
1736 SourceLocation &EndProtoLoc,
1737 bool consumeLastToken);
1742 void parseObjCTypeArgsOrProtocolQualifiers(
1744 SourceLocation &typeArgsLAngleLoc,
1745 SmallVectorImpl<ParsedType> &typeArgs,
1746 SourceLocation &typeArgsRAngleLoc,
1747 SourceLocation &protocolLAngleLoc,
1748 SmallVectorImpl<Decl *> &protocols,
1749 SmallVectorImpl<SourceLocation> &protocolLocs,
1750 SourceLocation &protocolRAngleLoc,
1751 bool consumeLastToken,
1752 bool warnOnIncompleteProtocols);
1756 void parseObjCTypeArgsAndProtocolQualifiers(
1758 SourceLocation &typeArgsLAngleLoc,
1759 SmallVectorImpl<ParsedType> &typeArgs,
1760 SourceLocation &typeArgsRAngleLoc,
1761 SourceLocation &protocolLAngleLoc,
1762 SmallVectorImpl<Decl *> &protocols,
1763 SmallVectorImpl<SourceLocation> &protocolLocs,
1764 SourceLocation &protocolRAngleLoc,
1765 bool consumeLastToken);
1769 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1773 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1775 bool consumeLastToken,
1776 SourceLocation &endLoc);
1780 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1781 ParsedAttributes &prefixAttrs);
1783 struct ObjCImplParsingDataRAII {
1787 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1788 LateParsedObjCMethodContainer LateParsedObjCMethods;
1790 ObjCImplParsingDataRAII(Parser &parser, Decl *
D)
1791 :
P(parser), Dcl(
D), HasCFunction(
false) {
1792 P.CurParsedObjCImpl =
this;
1795 ~ObjCImplParsingDataRAII();
1797 void finish(SourceRange AtEnd);
1798 bool isFinished()
const {
return Finished; }
1803 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1804 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1806 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1807 ParsedAttributes &Attrs);
1809 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1810 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1811 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1813 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1816 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1817 objc_nonnull, objc_nullable, objc_null_unspecified,
1820 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1822 bool isTokIdentifier_in()
const;
1825 ParsedAttributes *ParamAttrs);
1826 Decl *ParseObjCMethodPrototype(
1828 bool MethodDefinition =
true);
1831 bool MethodDefinition=
true);
1832 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1834 Decl *ParseObjCMethodDefinition();
1862 unsigned &NumLineToksConsumed,
1863 bool IsUnevaluated);
1879 enum CastParseKind {
1888 ExprResult ParseCastExpression(CastParseKind ParseKind,
1889 bool isAddressOfOperand,
1892 bool isVectorLiteral =
false,
1893 bool *NotPrimaryExpression =
nullptr);
1894 ExprResult ParseCastExpression(CastParseKind ParseKind,
1895 bool isAddressOfOperand =
false,
1897 bool isVectorLiteral =
false,
1898 bool *NotPrimaryExpression =
nullptr);
1901 bool isNotExpressionStart();
1905 bool isPostfixExpressionSuffixStart() {
1907 return (K == tok::l_square || K == tok::l_paren ||
1908 K == tok::period || K == tok::arrow ||
1909 K == tok::plusplus || K == tok::minusminus);
1912 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1913 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1914 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1915 const Token &OpToken);
1916 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1917 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1918 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1923 ExprResult ParseUnaryExprOrTypeTraitExpression();
1925 ExprResult ParseSYCLUniqueStableNameExpression();
1927 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1930 SourceRange &CastRange);
1933 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1934 llvm::function_ref<
void()> ExpressionStarts =
1935 llvm::function_ref<
void()>(),
1936 bool FailImmediatelyOnInvalidExpr =
false,
1937 bool EarlyTypoCorrection =
false,
1938 bool *HasTrailingComma =
nullptr);
1942 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1945 enum ParenParseOption {
1952 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1953 bool stopIfCastExpr,
1956 SourceLocation &RParenLoc);
1959 ParenParseOption &ExprType,
ParsedType &CastTy,
1962 SourceLocation LParenLoc,
1963 SourceLocation RParenLoc);
1965 ExprResult ParseGenericSelectionExpression();
1973 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1974 Token &Replacement);
1979 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1981 bool areTokensAdjacent(
const Token &A,
const Token &B);
1983 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1984 bool EnteringContext, IdentifierInfo &II,
1987 bool ParseOptionalCXXScopeSpecifier(
1988 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
1989 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
1990 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
1991 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
1992 bool Disambiguation =
false);
1998 enum class LambdaIntroducerTentativeParse {
2015 ParseLambdaIntroducer(LambdaIntroducer &Intro,
2016 LambdaIntroducerTentativeParse *Tentative =
nullptr);
2017 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
2036 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
2051 SourceRange &SpecificationRange,
2052 SmallVectorImpl<ParsedType> &DynamicExceptions,
2053 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2059 SourceRange &SpecificationRange,
2060 SmallVectorImpl<ParsedType> &Exceptions,
2061 SmallVectorImpl<SourceRange> &Ranges);
2066 bool MayBeFollowedByDirectInit);
2074 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2079 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2081 bool ParseCXXTypeSpecifierSeq(
2086 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2088 void ParseDirectNewDeclarator(Declarator &
D);
2089 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2090 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2091 SourceLocation Start);
2095 struct ForRangeInfo;
2096 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2100 ForRangeInfo *FRI =
nullptr,
2101 bool EnterForConditionScope =
false);
2103 ParsedAttributes &Attrs);
2114 void ParseTrailingRequiresClause(Declarator &
D);
2124 if (Tok.isNot(tok::l_brace))
2126 return ParseBraceInitializer();
2128 bool MayBeDesignationStart();
2130 struct DesignatorCompletionInfo {
2131 SmallVectorImpl<Expr *> &InitExprs;
2132 QualType PreferredBaseType;
2134 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2136 void injectEmbedTokens();
2145 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2146 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2147 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2148 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2149 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2150 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2151 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2152 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2153 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2154 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2155 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2156 bool isSimpleObjCMessageExpression();
2158 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2159 SourceLocation SuperLoc,
2161 Expr *ReceiverExpr);
2162 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2163 SourceLocation LBracloc, SourceLocation SuperLoc,
2164 ParsedType ReceiverType, Expr *ReceiverExpr);
2165 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2171 typedef SmallVector<Expr*, 12> ExprVector;
2174 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2175 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2177 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2178 SourceLocation *TrailingElseLoc =
nullptr);
2179 StmtResult ParseStatementOrDeclarationAfterAttributes(
2180 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2181 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2182 ParsedAttributes &DeclSpecAttrs);
2183 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2184 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2185 ParsedStmtContext StmtCtx);
2186 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2187 bool MissingCase =
false,
2189 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2190 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2191 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2192 unsigned ScopeFlags);
2193 void ParseCompoundStatementLeadingPragmas();
2194 void DiagnoseLabelAtEndOfCompoundStatement();
2196 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2197 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2198 Sema::ConditionResult &CondResult,
2200 SourceLocation &LParenLoc,
2201 SourceLocation &RParenLoc);
2202 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2203 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2204 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2206 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2212 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2214 SourceLocation *TrailingElseLoc,
2215 ParsedAttributes &Attrs);
2219 enum IfExistsBehavior {
2231 struct IfExistsCondition {
2233 SourceLocation KeywordLoc;
2246 IfExistsBehavior Behavior;
2249 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2250 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2251 void ParseMicrosoftIfExistsExternalDeclaration();
2252 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2253 ParsedAttributes &AccessAttrs,
2255 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2257 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2258 SmallVectorImpl<Expr *> &Constraints,
2259 SmallVectorImpl<Expr *> &Exprs);
2265 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2266 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2279 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2280 ParsedStmtContext StmtCtx);
2281 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2282 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2283 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2284 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2293 enum class DeclSpecContext {
2298 DSC_alias_declaration,
2303 DSC_template_type_arg,
2304 DSC_objc_method_result,
2313 static bool isTypeSpecifier(DeclSpecContext DSC) {
2315 case DeclSpecContext::DSC_normal:
2316 case DeclSpecContext::DSC_template_param:
2317 case DeclSpecContext::DSC_template_arg:
2318 case DeclSpecContext::DSC_class:
2319 case DeclSpecContext::DSC_top_level:
2320 case DeclSpecContext::DSC_objc_method_result:
2321 case DeclSpecContext::DSC_condition:
2324 case DeclSpecContext::DSC_template_type_arg:
2325 case DeclSpecContext::DSC_type_specifier:
2326 case DeclSpecContext::DSC_conv_operator:
2327 case DeclSpecContext::DSC_trailing:
2328 case DeclSpecContext::DSC_alias_declaration:
2329 case DeclSpecContext::DSC_association:
2330 case DeclSpecContext::DSC_new:
2333 llvm_unreachable(
"Missing DeclSpecContext case");
2337 enum class AllowDefiningTypeSpec {
2354 static AllowDefiningTypeSpec
2355 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2357 case DeclSpecContext::DSC_normal:
2358 case DeclSpecContext::DSC_class:
2359 case DeclSpecContext::DSC_top_level:
2360 case DeclSpecContext::DSC_alias_declaration:
2361 case DeclSpecContext::DSC_objc_method_result:
2362 return AllowDefiningTypeSpec::Yes;
2364 case DeclSpecContext::DSC_condition:
2365 case DeclSpecContext::DSC_template_param:
2366 return AllowDefiningTypeSpec::YesButInvalid;
2368 case DeclSpecContext::DSC_template_type_arg:
2369 case DeclSpecContext::DSC_type_specifier:
2370 return AllowDefiningTypeSpec::NoButErrorRecovery;
2372 case DeclSpecContext::DSC_association:
2373 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2374 : AllowDefiningTypeSpec::Yes;
2376 case DeclSpecContext::DSC_trailing:
2377 case DeclSpecContext::DSC_conv_operator:
2378 case DeclSpecContext::DSC_template_arg:
2379 case DeclSpecContext::DSC_new:
2380 return AllowDefiningTypeSpec::No;
2382 llvm_unreachable(
"Missing DeclSpecContext case");
2386 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2388 case DeclSpecContext::DSC_normal:
2389 case DeclSpecContext::DSC_class:
2390 case DeclSpecContext::DSC_top_level:
2393 case DeclSpecContext::DSC_alias_declaration:
2394 case DeclSpecContext::DSC_objc_method_result:
2395 case DeclSpecContext::DSC_condition:
2396 case DeclSpecContext::DSC_template_param:
2397 case DeclSpecContext::DSC_template_type_arg:
2398 case DeclSpecContext::DSC_type_specifier:
2399 case DeclSpecContext::DSC_trailing:
2400 case DeclSpecContext::DSC_association:
2401 case DeclSpecContext::DSC_conv_operator:
2402 case DeclSpecContext::DSC_template_arg:
2403 case DeclSpecContext::DSC_new:
2407 llvm_unreachable(
"Missing DeclSpecContext case");
2412 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2414 case DeclSpecContext::DSC_normal:
2415 case DeclSpecContext::DSC_template_param:
2416 case DeclSpecContext::DSC_template_arg:
2417 case DeclSpecContext::DSC_class:
2418 case DeclSpecContext::DSC_top_level:
2419 case DeclSpecContext::DSC_condition:
2420 case DeclSpecContext::DSC_type_specifier:
2421 case DeclSpecContext::DSC_association:
2422 case DeclSpecContext::DSC_conv_operator:
2423 case DeclSpecContext::DSC_new:
2426 case DeclSpecContext::DSC_objc_method_result:
2427 case DeclSpecContext::DSC_template_type_arg:
2428 case DeclSpecContext::DSC_trailing:
2429 case DeclSpecContext::DSC_alias_declaration:
2432 llvm_unreachable(
"Missing DeclSpecContext case");
2437 getImplicitTypenameContext(DeclSpecContext DSC) {
2439 case DeclSpecContext::DSC_class:
2440 case DeclSpecContext::DSC_top_level:
2441 case DeclSpecContext::DSC_type_specifier:
2442 case DeclSpecContext::DSC_template_type_arg:
2443 case DeclSpecContext::DSC_trailing:
2444 case DeclSpecContext::DSC_alias_declaration:
2445 case DeclSpecContext::DSC_template_param:
2446 case DeclSpecContext::DSC_new:
2449 case DeclSpecContext::DSC_normal:
2450 case DeclSpecContext::DSC_objc_method_result:
2451 case DeclSpecContext::DSC_condition:
2452 case DeclSpecContext::DSC_template_arg:
2453 case DeclSpecContext::DSC_conv_operator:
2454 case DeclSpecContext::DSC_association:
2457 llvm_unreachable(
"Missing DeclSpecContext case");
2462 struct ForRangeInit {
2463 SourceLocation ColonLoc;
2465 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2466 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2468 struct ForRangeInfo : ForRangeInit {
2473 SourceLocation &DeclEnd,
2474 ParsedAttributes &DeclAttrs,
2475 ParsedAttributes &DeclSpecAttrs,
2476 SourceLocation *DeclSpecStart =
nullptr);
2479 ParsedAttributes &DeclAttrs,
2480 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2481 ForRangeInit *FRI =
nullptr,
2482 SourceLocation *DeclSpecStart =
nullptr);
2485 ParsedAttributes &Attrs,
2486 ParsedTemplateInfo &TemplateInfo,
2487 SourceLocation *DeclEnd =
nullptr,
2488 ForRangeInit *FRI =
nullptr);
2489 Decl *ParseDeclarationAfterDeclarator(Declarator &
D,
2490 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2491 bool ParseAsmAttributesAfterDeclarator(Declarator &
D);
2492 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2494 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2495 ForRangeInit *FRI =
nullptr);
2496 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2497 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2503 bool trySkippingFunctionBody();
2505 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2507 DeclSpecContext DSC, ParsedAttributes &Attrs);
2511 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2513 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2514 LateParsedAttrList *LateAttrs =
nullptr) {
2515 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2516 getImplicitTypenameContext(DSC));
2519 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2521 LateParsedAttrList *LateAttrs,
2524 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2525 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2526 SourceLocation StartLoc,
2527 SourceLocation EndLoc);
2529 bool DiagnoseMissingSemiAfterTagDefinition(
2531 LateParsedAttrList *LateAttrs =
nullptr);
2533 void ParseSpecifierQualifierList(
2535 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2536 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2539 void ParseSpecifierQualifierList(
2542 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2544 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2547 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2548 const ParsedTemplateInfo &TemplateInfo,
2550 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2551 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2552 RecordDecl *TagDecl);
2554 void ParseStructDeclaration(
2555 ParsingDeclSpec &DS,
2556 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2557 LateParsedAttrList *LateFieldAttrs =
nullptr);
2562 bool DisambiguatingWithExpression =
false);
2563 bool isTypeSpecifierQualifier();
2568 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2573 bool isKnownToBeDeclarationSpecifier() {
2586 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2588 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2596 bool isForInitDeclaration() {
2600 return Tok.is(tok::kw_using) ||
2601 isCXXSimpleDeclaration(
true);
2606 bool isForRangeIdentifier();
2610 bool isStartOfObjCClassMessageMissingOpenBracket();
2615 bool isConstructorDeclarator(
2618 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2622 enum TentativeCXXTypeIdContext {
2625 TypeIdAsTemplateArgument,
2626 TypeIdInTrailingReturnType,
2627 TypeIdAsGenericSelectionArgument,
2633 bool isTypeIdInParens(
bool &isAmbiguous) {
2635 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2636 isAmbiguous =
false;
2637 return isTypeSpecifierQualifier();
2639 bool isTypeIdInParens() {
2641 return isTypeIdInParens(isAmbiguous);
2651 bool isTypeIdForGenericSelection() {
2654 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2656 return isTypeSpecifierQualifier();
2662 bool isTypeIdUnambiguously() {
2665 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2667 return isTypeSpecifierQualifier();
2673 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2680 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2689 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2693 struct ConditionDeclarationOrInitStatementState;
2694 enum class ConditionOrInitStatement {
2704 ConditionOrInitStatement
2705 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2706 bool CanBeForRangeDecl);
2708 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2709 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2711 return isCXXTypeId(Context, isAmbiguous);
2716 enum class TPResult {
2727 bool isEnumBase(
bool AllowSemi);
2738 TPResult BracedCastResult = TPResult::False,
2739 bool *InvalidAsDeclSpec =
nullptr);
2744 bool isCXXDeclarationSpecifierAType();
2749 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2754 TPResult isExplicitBool();
2759 bool isTentativelyDeclared(IdentifierInfo *II);
2768 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2769 TPResult TryParseTypeofSpecifier();
2770 TPResult TryParseProtocolQualifiers();
2771 TPResult TryParsePtrOperatorSeq();
2772 TPResult TryParseOperatorId();
2773 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2774 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2775 bool mayHaveDirectInit =
false,
2776 bool mayHaveTrailingReturnType =
false);
2777 TPResult TryParseParameterDeclarationClause(
2778 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2781 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2782 bool NameAfterArrowIsNonType();
2783 TPResult TryParseBracketDeclarator();
2784 TPResult TryConsumeDeclarationSpecifier();
2788 bool TrySkipAttributes();
2792 void DiagnoseBitIntUse(
const Token &Tok);
2799 ParsedAttributes *Attrs =
nullptr);
2802 void ParseBlockId(SourceLocation CaretLoc);
2809 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2810 bool OuterMightBeMessageSend =
false) {
2811 return (Tok.isRegularKeywordAttribute() ||
2812 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2817 bool CheckProhibitedCXX11Attribute() {
2818 assert(Tok.is(tok::l_square));
2821 return DiagnoseProhibitedCXX11Attribute();
2824 bool DiagnoseProhibitedCXX11Attribute();
2825 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2826 SourceLocation CorrectLocation) {
2827 if (!Tok.isRegularKeywordAttribute() &&
2828 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2829 Tok.isNot(tok::kw_alignas))
2831 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2833 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2834 SourceLocation CorrectLocation);
2836 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2840 void ProhibitAttributes(ParsedAttributes &Attrs,
2841 SourceLocation FixItLoc = SourceLocation()) {
2842 if (Attrs.Range.isInvalid())
2844 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2848 void ProhibitAttributes(ParsedAttributesView &Attrs,
2849 SourceLocation FixItLoc = SourceLocation()) {
2850 if (Attrs.Range.isInvalid())
2852 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2853 Attrs.clearListOnly();
2855 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2856 SourceLocation FixItLoc);
2864 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2865 unsigned KeywordDiagId,
2866 bool DiagnoseEmptyAttrs =
false,
2867 bool WarnOnUnknownAttrs =
false);
2872 SourceLocation SkipCXX11Attributes();
2876 void DiagnoseAndSkipCXX11Attributes();
2880 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2882 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2886 SmallVectorImpl<Expr *> &Exprs,
2887 ParsedAttributeArgumentsProperties ArgsProperties);
2894 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2895 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2896 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2897 ParsedAttr::Form Form);
2899 enum ParseAttrKindMask {
2901 PAKM_Declspec = 1 << 1,
2902 PAKM_CXX11 = 1 << 2,
2919 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2920 LateParsedAttrList *LateAttrs =
nullptr);
2923 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2924 LateParsedAttrList *LateAttrs =
nullptr) {
2925 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2926 isAllowedCXX11AttributeSpecifier()) {
2927 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2933 void MaybeParseGNUAttributes(Declarator &
D,
2934 LateParsedAttrList *LateAttrs =
nullptr) {
2935 if (Tok.is(tok::kw___attribute)) {
2936 ParsedAttributes Attrs(AttrFactory);
2937 ParseGNUAttributes(Attrs, LateAttrs, &
D);
2938 D.takeAttributes(Attrs);
2942 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2943 LateParsedAttrList *LateAttrs =
nullptr) {
2944 if (Tok.is(tok::kw___attribute)) {
2945 ParseGNUAttributes(Attrs, LateAttrs);
2951 bool ParseSingleGNUAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc,
2952 LateParsedAttrList *LateAttrs =
nullptr,
2953 Declarator *
D =
nullptr);
2954 void ParseGNUAttributes(ParsedAttributes &Attrs,
2955 LateParsedAttrList *LateAttrs =
nullptr,
2956 Declarator *
D =
nullptr);
2957 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2958 SourceLocation AttrNameLoc,
2959 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2960 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2961 ParsedAttr::Form Form, Declarator *
D);
2962 IdentifierLoc *ParseIdentifierLoc();
2965 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2966 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2967 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2968 ParsedAttr::Form Form);
2970 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2973 if (!OpenMPTokens.empty()) {
2975 PP.EnterTokenStream(OpenMPTokens,
true,
2980 void MaybeParseCXX11Attributes(Declarator &
D) {
2981 if (isAllowedCXX11AttributeSpecifier()) {
2982 ParsedAttributes Attrs(AttrFactory);
2983 ParseCXX11Attributes(Attrs);
2984 D.takeAttributes(Attrs);
2988 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2989 bool OuterMightBeMessageSend =
false) {
2990 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2991 ParseCXX11Attributes(Attrs);
2997 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
3000 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
3002 SourceLocation *EndLoc =
nullptr);
3003 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
3004 SourceLocation *EndLoc =
nullptr) {
3006 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
3007 ReplayOpenMPAttributeTokens(OpenMPTokens);
3009 void ParseCXX11Attributes(ParsedAttributes &attrs);
3012 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3013 SourceLocation AttrNameLoc,
3014 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3015 IdentifierInfo *ScopeName,
3016 SourceLocation ScopeLoc,
3020 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
3021 IdentifierInfo *AttrName,
3022 SourceLocation AttrNameLoc,
3023 SourceLocation *EndLoc,
3024 ParsedAttr::Form Form);
3026 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3027 SourceLocation &
Loc,
3030 const IdentifierInfo *EnclosingScope =
nullptr);
3032 bool MaybeParseHLSLAnnotations(Declarator &
D,
3033 SourceLocation *EndLoc =
nullptr,
3034 bool CouldBeBitField =
false) {
3035 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3036 if (Tok.is(tok::colon)) {
3037 ParsedAttributes Attrs(AttrFactory);
3038 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
3039 D.takeAttributes(Attrs);
3045 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
3046 SourceLocation *EndLoc =
nullptr) {
3047 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3048 if (Tok.is(tok::colon))
3049 ParseHLSLAnnotations(Attrs, EndLoc);
3052 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
3053 SourceLocation *EndLoc =
nullptr,
3054 bool CouldBeBitField =
false);
3055 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
3057 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3059 Tok.is(tok::l_square)) {
3060 ParsedAttributes AttrsWithRange(AttrFactory);
3061 ParseMicrosoftAttributes(AttrsWithRange);
3062 Attrs.takeAllFrom(AttrsWithRange);
3065 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3066 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3067 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3068 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3069 ParseMicrosoftDeclSpecs(Attrs);
3074 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3075 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3076 SourceLocation AttrNameLoc,
3077 ParsedAttributes &Attrs);
3078 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3079 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3080 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3081 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3082 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3083 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3084 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3085 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3086 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3087 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3088 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3089 bool isHLSLQualifier(
const Token &Tok)
const;
3090 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3092 VersionTuple ParseVersionTuple(SourceRange &
Range);
3093 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3094 SourceLocation AvailabilityLoc,
3095 ParsedAttributes &attrs,
3096 SourceLocation *endLoc,
3097 IdentifierInfo *ScopeName,
3098 SourceLocation ScopeLoc,
3099 ParsedAttr::Form Form);
3101 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3102 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3104 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3106 ParsedAttributes &Attrs,
3107 SourceLocation *EndLoc,
3108 IdentifierInfo *ScopeName,
3109 SourceLocation ScopeLoc,
3110 ParsedAttr::Form Form);
3112 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3113 SourceLocation ObjCBridgeRelatedLoc,
3114 ParsedAttributes &Attrs,
3115 SourceLocation *EndLoc,
3116 IdentifierInfo *ScopeName,
3117 SourceLocation ScopeLoc,
3118 ParsedAttr::Form Form);
3120 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3121 SourceLocation AttrNameLoc,
3122 ParsedAttributes &Attrs,
3123 SourceLocation *EndLoc,
3124 IdentifierInfo *ScopeName,
3125 SourceLocation ScopeLoc,
3126 ParsedAttr::Form Form);
3128 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3129 SourceLocation AttrNameLoc,
3130 ParsedAttributes &Attrs,
3131 SourceLocation *EndLoc,
3132 IdentifierInfo *ScopeName,
3133 SourceLocation ScopeLoc,
3134 ParsedAttr::Form Form);
3136 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3137 SourceLocation AttrNameLoc,
3138 ParsedAttributes &Attrs,
3139 IdentifierInfo *ScopeName,
3140 SourceLocation ScopeLoc,
3141 ParsedAttr::Form Form);
3143 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
3145 void ParseBoundsAttribute(IdentifierInfo &AttrName,
3146 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
3147 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3148 ParsedAttr::Form Form);
3150 void ParseTypeofSpecifier(DeclSpec &DS);
3151 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3152 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3153 SourceLocation StartLoc,
3154 SourceLocation EndLoc);
3155 void ParseAtomicSpecifier(DeclSpec &DS);
3157 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3158 SourceLocation &EllipsisLoc,
bool &IsType,
3160 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3161 SourceLocation *endLoc =
nullptr);
3166 return isCXX11VirtSpecifier(Tok);
3168 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3169 SourceLocation FriendLoc);
3171 bool isCXX11FinalKeyword()
const;
3172 bool isClassCompatibleKeyword()
const;
3177 class DeclaratorScopeObj {
3183 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3184 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3186 void EnterDeclaratorScope() {
3187 assert(!EnteredScope &&
"Already entered the scope!");
3188 assert(SS.isSet() &&
"C++ scope was not set!");
3190 CreatedScope =
true;
3193 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3194 EnteredScope =
true;
3197 ~DeclaratorScopeObj() {
3199 assert(SS.isSet() &&
"C++ scope was cleared ?");
3200 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3208 void ParseDeclarator(Declarator &
D);
3210 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3211 void ParseDeclaratorInternal(Declarator &
D,
3212 DirectDeclParseFunction DirectDeclParser);
3214 enum AttrRequirements {
3215 AR_NoAttributesParsed = 0,
3216 AR_GNUAttributesParsedAndRejected = 1 << 0,
3217 AR_GNUAttributesParsed = 1 << 1,
3218 AR_CXX11AttributesParsed = 1 << 2,
3219 AR_DeclspecAttributesParsed = 1 << 3,
3220 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3221 AR_CXX11AttributesParsed |
3222 AR_DeclspecAttributesParsed,
3223 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3224 AR_DeclspecAttributesParsed
3227 void ParseTypeQualifierListOpt(
3228 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3229 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3230 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3232 void ParseDirectDeclarator(Declarator &
D);
3233 void ParseDecompositionDeclarator(Declarator &
D);
3234 void ParseParenDeclarator(Declarator &
D);
3235 void ParseFunctionDeclarator(Declarator &
D, ParsedAttributes &FirstArgAttrs,
3237 bool IsAmbiguous,
bool RequiresArg =
false);
3238 void InitCXXThisScopeForDeclaratorIfRelevant(
3239 const Declarator &
D,
const DeclSpec &DS,
3240 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3241 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3242 SourceLocation &RefQualifierLoc);
3243 bool isFunctionDeclaratorIdentifierList();
3244 void ParseFunctionDeclaratorIdentifierList(
3246 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3247 void ParseParameterDeclarationClause(
3248 Declarator &
D, ParsedAttributes &attrs,
3249 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3250 SourceLocation &EllipsisLoc) {
3251 return ParseParameterDeclarationClause(
3252 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3253 D.getCXXScopeSpec().isSet() &&
3254 D.isFunctionDeclaratorAFunctionDeclaration());
3256 void ParseParameterDeclarationClause(
3258 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3259 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3261 void ParseBracketDeclarator(Declarator &
D);
3262 void ParseMisplacedBracketDeclarator(Declarator &
D);
3263 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3270 enum CXX11AttributeKind {
3272 CAK_NotAttributeSpecifier,
3274 CAK_AttributeSpecifier,
3277 CAK_InvalidAttributeSpecifier
3280 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3281 bool OuterMightBeMessageSend =
false);
3283 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3286 SourceLocation &DeclEnd,
3287 SourceLocation InlineLoc = SourceLocation());
3289 struct InnerNamespaceInfo {
3290 SourceLocation NamespaceLoc;
3291 SourceLocation InlineLoc;
3292 SourceLocation IdentLoc;
3293 IdentifierInfo *Ident;
3297 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3298 unsigned int index, SourceLocation &InlineLoc,
3299 ParsedAttributes &attrs,
3302 Decl *ParseExportDeclaration();
3305 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3307 SourceLocation UsingLoc,
3308 SourceLocation &DeclEnd,
3309 ParsedAttributes &attrs);
3311 struct UsingDeclarator {
3312 SourceLocation TypenameLoc;
3315 SourceLocation EllipsisLoc;
3318 TypenameLoc = EllipsisLoc = SourceLocation();
3326 const ParsedTemplateInfo &TemplateInfo,
3327 SourceLocation UsingLoc,
3328 SourceLocation &DeclEnd,
3329 ParsedAttributes &Attrs,
3331 Decl *ParseAliasDeclarationAfterDeclarator(
3332 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3334 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3336 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3337 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3338 SourceLocation AliasLoc, IdentifierInfo *Alias,
3339 SourceLocation &DeclEnd);
3343 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3344 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3345 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3347 DeclSpecContext DSC, ParsedAttributes &Attributes);
3348 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3349 SourceLocation AttrFixitLoc,
3352 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3353 SourceLocation AttrFixitLoc,
3354 ParsedAttributes &Attrs,
unsigned TagType,
3356 ExprResult ParseCXXMemberInitializer(Decl *
D,
bool IsFunction,
3357 SourceLocation &EqualLoc);
3359 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3362 LateParsedAttrList &LateAttrs);
3363 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &
D,
3364 VirtSpecifiers &VS);
3367 ParsedTemplateInfo &TemplateInfo,
3368 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3371 ParsedAttributes &AccessAttrs,
3373 void ParseConstructorInitializer(Decl *ConstructorDecl);
3375 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3380 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3381 SourceLocation &EndLocation);
3382 void ParseBaseClause(Decl *ClassDecl);
3383 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3386 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3388 bool ObjectHadErrors,
3389 SourceLocation TemplateKWLoc,
3390 IdentifierInfo *Name,
3391 SourceLocation NameLoc,
3392 bool EnteringContext,
3394 bool AssumeTemplateId);
3395 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3404 SourceLocation
Loc);
3408 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3409 llvm::omp::TraitSet
Set,
3410 llvm::omp::TraitSelector Selector,
3411 llvm::StringMap<SourceLocation> &Seen);
3414 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3415 llvm::omp::TraitSet
Set,
3416 llvm::StringMap<SourceLocation> &Seen);
3419 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3420 llvm::StringMap<SourceLocation> &Seen);
3423 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3424 llvm::omp::TraitSet
Set,
3425 llvm::StringMap<SourceLocation> &Seen);
3428 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3429 llvm::omp::TraitSet
Set,
3430 llvm::StringMap<SourceLocation> &SeenSelectors);
3433 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3434 llvm::StringMap<SourceLocation> &SeenSets);
3437 bool parseOMPContextSelectors(SourceLocation
Loc, OMPTraitInfo &TI);
3440 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3444 bool parseOMPDeclareVariantMatchClause(SourceLocation
Loc, OMPTraitInfo &TI,
3445 OMPTraitInfo *ParentTI);
3449 SourceLocation
Loc);
3453 SourceLocation
Loc);
3456 void ParseOpenMPEndAssumesDirective(SourceLocation
Loc);
3464 SmallVectorImpl<clang::OMPClause *> &Clauses,
3465 SourceLocation
Loc);
3468 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
3473 SourceLocation
Loc);
3486 SourceLocation MatchingLoc,
3487 SourceLocation FoundLoc,
3488 bool SkipUntilOpenMPEnd);
3494 Decl *TagDecl =
nullptr);
3499 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3505 DeclarationName &Name,
3510 bool tryParseOpenMPArrayShapingCastPart();
3519 bool ParseOpenMPSimpleVarList(
3521 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3523 bool AllowScopeSpecifier);
3529 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3530 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3540 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
3542 bool ReadDirectiveWithinMetadirective);
3551 StmtResult ParseOpenMPInformationalDirective(
3553 bool ReadDirectiveWithinMetadirective);
3582 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
3597 OMPClause *ParseOpenMPSizesClause();
3600 OMPClause *ParseOpenMPPermutationClause();
3608 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3629 SourceLocation &ClauseNameLoc,
3630 SourceLocation &OpenLoc,
3631 SourceLocation &CloseLoc,
3632 SmallVectorImpl<Expr *> &Exprs,
3633 bool ReqIntConst =
false);
3646 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3654 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3661 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3668 bool IsAddressOfOperand =
false);
3672 SemaOpenMP::OpenMPVarListDataTy &
Data,
3673 const LangOptions &LangOpts);
3676 SmallVectorImpl<Expr *> &Vars,
3677 SemaOpenMP::OpenMPVarListDataTy &
Data);
3679 bool ObjectHadErrors,
bool EnteringContext,
3680 bool AllowDestructorName,
bool AllowConstructorName,
3681 bool AllowDeductionGuide,
3682 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3705 struct OpenACCDirectiveParseInfo {
3707 SourceLocation StartLoc;
3708 SourceLocation DirLoc;
3709 SourceLocation LParenLoc;
3710 SourceLocation RParenLoc;
3711 SourceLocation EndLoc;
3712 SourceLocation MiscLoc;
3713 SmallVector<Expr *> Exprs;
3714 SmallVector<OpenACCClause *> Clauses;
3719 struct OpenACCWaitParseInfo {
3720 bool Failed =
false;
3721 Expr *DevNumExpr =
nullptr;
3722 SourceLocation QueuesLoc;
3723 SmallVector<Expr *> QueueIdExprs;
3725 SmallVector<Expr *> getAllExprs() {
3726 SmallVector<Expr *> Out;
3727 Out.push_back(DevNumExpr);
3728 Out.insert(Out.end(), QueueIdExprs.begin(), QueueIdExprs.end());
3735 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
3741 using OpenACCClauseParseResult =
3742 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
3744 OpenACCClauseParseResult OpenACCCanContinue();
3745 OpenACCClauseParseResult OpenACCCannotContinue();
3746 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
3750 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3754 void ParseOpenACCCacheVarList();
3756 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
3763 OpenACCClauseParseResult
3764 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
3766 SourceLocation ClauseLoc);
3769 OpenACCClauseParseResult
3770 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
3773 SmallVector<OpenACCClause *>
3775 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation
Loc,
3784 using OpenACCIntExprParseResult =
3785 std::pair<ExprResult, OpenACCParseCanContinue>;
3790 SourceLocation
Loc);
3797 bool ParseOpenACCDeviceTypeList(
3803 SourceLocation
Loc);
3812 bool ParseOpenACCGangArgList(SourceLocation GangLoc,
3816 using OpenACCGangArgRes = std::pair<OpenACCGangKind, ExprResult>;
3820 OpenACCGangArgRes ParseOpenACCGangArg(SourceLocation GangLoc);
3831 SourceLocation &DeclEnd,
3832 ParsedAttributes &AccessAttrs);
3838 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3840 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3841 SmallVectorImpl<NamedDecl *> &TemplateParams,
3842 SourceLocation &LAngleLoc,
3843 SourceLocation &RAngleLoc);
3844 bool ParseTemplateParameterList(
unsigned Depth,
3845 SmallVectorImpl<NamedDecl*> &TemplateParams);
3846 TPResult isStartOfTemplateTypeParameter();
3847 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3848 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3849 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3850 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3851 bool isTypeConstraintAnnotation();
3852 bool TryAnnotateTypeConstraint();
3853 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3854 SourceLocation CorrectLoc,
3855 bool AlreadyHasEllipsis,
3856 bool IdentifierHasName);
3857 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3860 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3862 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3863 SourceLocation &RAngleLoc,
3864 bool ConsumeLastToken,
3865 bool ObjCGenericList);
3866 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3867 SourceLocation &LAngleLoc,
3868 TemplateArgList &TemplateArgs,
3869 SourceLocation &RAngleLoc,
3874 SourceLocation TemplateKWLoc,
3875 UnqualifiedId &TemplateName,
3876 bool AllowTypeAnnotation =
true,
3877 bool TypeConstraint =
false);
3879 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3881 bool IsClassName =
false);
3882 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3883 TemplateTy Template, SourceLocation OpenLoc);
3884 ParsedTemplateArgument ParseTemplateTemplateArgument();
3885 ParsedTemplateArgument ParseTemplateArgument();
3887 SourceLocation ExternLoc,
3888 SourceLocation TemplateLoc,
3889 SourceLocation &DeclEnd,
3890 ParsedAttributes &AccessAttrs,
3894 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3895 SourceLocation &DeclEnd);
3906 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3907 SourceLocation IncludeLoc);
3912 Decl *ParseModuleImport(SourceLocation AtLoc,
3914 bool parseMisplacedModuleImport();
3915 bool tryParseMisplacedModuleImport() {
3917 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3918 Kind == tok::annot_module_include)
3919 return parseMisplacedModuleImport();
3923 bool ParseModuleName(
3924 SourceLocation UseLoc,
3925 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &
Path,
3937 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
3941 void CodeCompleteDirective(
bool InConditional)
override;
3942 void CodeCompleteInConditionalExclusion()
override;
3943 void CodeCompleteMacroName(
bool IsDefinition)
override;
3944 void CodeCompletePreprocessorExpression()
override;
3945 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3946 unsigned ArgumentIndex)
override;
3947 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3948 void CodeCompleteNaturalLanguage()
override;
3950 class GNUAsmQualifiers {
3951 unsigned Qualifiers = AQ_unspecified;
3960 static const char *getQualifierName(AQ Qualifier);
3961 bool setAsmQualifier(AQ Qualifier);
3962 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3963 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3964 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3966 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3967 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3968 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3969 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
enum clang::sema::@1712::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)
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 { ....
Callback handler that receives notifications when performing code completion within the preprocessor.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
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.
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,...
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 type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope, ImplicitTypenameContext AllowImplicitTypename)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
Preprocessor & getPreprocessor() const
bool parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data)
Parses map-type-modifiers in map clause.
Sema::FullExprArg FullExprArg
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
AttributeFactory & getAttrFactory()
void incrementMSManglingNumber() const
Sema & getActions() const
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.
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
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.
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
SourceLocation getEndOfPreviousToken()
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 ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
SourceLocation MisleadingIndentationElseLoc
The location of the first statement inside an else that might have a missleading indentation.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result, Sema::ModuleImportState &ImportState)
Parse the first top-level declaration in a translation unit.
DiagnosticBuilder Diag(unsigned DiagID)
SmallVector< Stmt *, 32 > StmtVector
A SmallVector of statements.
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()
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ParseUnevaluatedStringLiteralExpression()
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
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.
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 the template scopes for a declaration that might be a template.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
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
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
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.
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(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setAnnotationValue(void *val)
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
bool Pop(InterpState &S, CodePtr OpPC)
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.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
NullabilityKind
Describes the nullability of a particular type.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
ActionResult< CXXCtorInitializer * > MemInitResult
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
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
@ 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.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< CXXBaseSpecifier * > BaseResult
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
unsigned short BracketCount
unsigned short BraceCount
AngleBracketTracker::Priority Priority
bool isActive(Parser &P) const
unsigned short ParenCount
bool isActiveOrNested(Parser &P) const