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;
1360 ParsingClass *
Class;
1369 struct LateParsedAttribute :
public LateParsedDeclaration {
1372 IdentifierInfo &AttrName;
1373 IdentifierInfo *MacroII =
nullptr;
1374 SourceLocation AttrNameLoc;
1375 SmallVector<Decl*, 2> Decls;
1377 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1379 : Self(
P), AttrName(Name), AttrNameLoc(
Loc) {}
1381 void ParseLexedAttributes()
override;
1383 void addDecl(Decl *
D) { Decls.push_back(
D); }
1390 class LateParsedPragma :
public LateParsedDeclaration {
1391 Parser *Self =
nullptr;
1397 : Self(
P), AS(AS) {}
1399 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1403 void ParseLexedPragmas()
override;
1407 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1409 LateParsedAttrList(
bool PSoon =
false,
1410 bool LateAttrParseExperimentalExtOnly =
false)
1412 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1414 bool parseSoon() {
return ParseSoon; }
1417 bool lateAttrParseExperimentalExtOnly() {
1418 return LateAttrParseExperimentalExtOnly;
1423 bool LateAttrParseExperimentalExtOnly;
1429 struct LexedMethod :
public LateParsedDeclaration {
1434 explicit LexedMethod(Parser *
P, Decl *MD) : Self(
P),
D(MD) {}
1436 void ParseLexedMethodDefs()
override;
1443 struct LateParsedDefaultArgument {
1444 explicit LateParsedDefaultArgument(Decl *
P,
1445 std::unique_ptr<CachedTokens> Toks =
nullptr)
1446 : Param(
P), Toks(
std::move(Toks)) { }
1455 std::unique_ptr<CachedTokens> Toks;
1462 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1463 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1464 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1466 void ParseLexedMethodDeclarations()
override;
1478 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1488 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1489 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1492 void ParseLexedMemberInitializers()
override;
1510 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1515 struct ParsingClass {
1516 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1517 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1518 TagOrTemplate(TagOrTemplate) {}
1522 bool TopLevelClass : 1;
1525 bool IsInterface : 1;
1528 Decl *TagOrTemplate;
1533 LateParsedDeclarationsContainer LateParsedDeclarations;
1539 std::stack<ParsingClass *> ClassStack;
1541 ParsingClass &getCurrentClass() {
1542 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1543 return *ClassStack.top();
1547 class ParsingClassDefinition {
1553 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1556 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1561 assert(!Popped &&
"Nested class has already been popped");
1563 P.PopParsingClass(State);
1566 ~ParsingClassDefinition() {
1568 P.PopParsingClass(State);
1575 struct ParsedTemplateInfo {
1576 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1579 bool isSpecialization,
1580 bool lastParameterListWasEmpty =
false)
1581 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1582 TemplateParams(TemplateParams),
1583 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1585 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1586 SourceLocation TemplateLoc)
1587 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1588 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1589 LastParameterListWasEmpty(
false){ }
1598 ExplicitSpecialization,
1600 ExplicitInstantiation
1609 SourceLocation ExternLoc;
1613 SourceLocation TemplateLoc;
1616 bool LastParameterListWasEmpty;
1622 struct ReenterTemplateScopeRAII;
1623 struct ReenterClassScopeRAII;
1625 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1626 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1628 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1630 Sema::ParsingClassState
1631 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1632 void DeallocateParsedClasses(ParsingClass *
Class);
1633 void PopParsingClass(Sema::ParsingClassState);
1635 enum CachedInitKind {
1636 CIK_DefaultArgument,
1637 CIK_DefaultInitializer
1641 const ParsedAttributesView &AccessAttrs,
1642 ParsingDeclarator &
D,
1643 const ParsedTemplateInfo &TemplateInfo,
1644 const VirtSpecifiers &VS,
1645 SourceLocation PureSpecLoc);
1646 StringLiteral *ParseCXXDeletedFunctionMessage();
1647 void SkipDeletedFunctionBody();
1648 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1649 void ParseLexedAttributes(ParsingClass &
Class);
1650 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *
D,
1652 void ParseLexedCAttributeList(LateParsedAttrList &LA,
bool EnterScope,
1653 ParsedAttributes *OutAttrs =
nullptr);
1654 void ParseLexedAttribute(LateParsedAttribute &LA,
1656 void ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
1657 ParsedAttributes *OutAttrs =
nullptr);
1658 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1659 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1660 void ParseLexedMethodDefs(ParsingClass &
Class);
1661 void ParseLexedMethodDef(LexedMethod &LM);
1662 void ParseLexedMemberInitializers(ParsingClass &
Class);
1663 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1664 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1665 void ParseLexedPragmas(ParsingClass &
Class);
1666 void ParseLexedPragma(LateParsedPragma &LP);
1667 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1668 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1673 bool ConsumeFinalToken =
true) {
1674 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1679 bool ConsumeFinalToken =
true);
1683 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1684 ParsedAttributes &DeclSpecAttrs,
1685 ParsingDeclSpec *DS =
nullptr);
1686 bool isDeclarationAfterDeclarator();
1687 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1689 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1691 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1692 ParsedAttributes &DeclSpecAttrs,
1693 ParsingDeclSpec &DS,
1696 void SkipFunctionBody();
1697 Decl *ParseFunctionDefinition(ParsingDeclarator &
D,
1698 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1699 LateParsedAttrList *LateParsedAttrs =
nullptr);
1700 void ParseKNRParamDeclarations(Declarator &
D);
1702 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1703 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1707 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1708 ParsedAttributes &DeclSpecAttrs);
1709 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1710 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1711 ParsedAttributes &prefixAttrs);
1712 class ObjCTypeParamListScope;
1713 ObjCTypeParamList *parseObjCTypeParamList();
1714 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1715 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1716 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1717 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1719 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1720 SourceLocation atLoc,
1722 SmallVectorImpl<Decl *> &AllIvarDecls,
1723 bool RBraceMissing);
1724 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1726 SourceLocation atLoc);
1727 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1728 SmallVectorImpl<SourceLocation> &PLocs,
1729 bool WarnOnDeclarations,
1730 bool ForObjCContainer,
1731 SourceLocation &LAngleLoc,
1732 SourceLocation &EndProtoLoc,
1733 bool consumeLastToken);
1738 void parseObjCTypeArgsOrProtocolQualifiers(
1740 SourceLocation &typeArgsLAngleLoc,
1741 SmallVectorImpl<ParsedType> &typeArgs,
1742 SourceLocation &typeArgsRAngleLoc,
1743 SourceLocation &protocolLAngleLoc,
1744 SmallVectorImpl<Decl *> &protocols,
1745 SmallVectorImpl<SourceLocation> &protocolLocs,
1746 SourceLocation &protocolRAngleLoc,
1747 bool consumeLastToken,
1748 bool warnOnIncompleteProtocols);
1752 void parseObjCTypeArgsAndProtocolQualifiers(
1754 SourceLocation &typeArgsLAngleLoc,
1755 SmallVectorImpl<ParsedType> &typeArgs,
1756 SourceLocation &typeArgsRAngleLoc,
1757 SourceLocation &protocolLAngleLoc,
1758 SmallVectorImpl<Decl *> &protocols,
1759 SmallVectorImpl<SourceLocation> &protocolLocs,
1760 SourceLocation &protocolRAngleLoc,
1761 bool consumeLastToken);
1765 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1769 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1771 bool consumeLastToken,
1772 SourceLocation &endLoc);
1776 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1777 ParsedAttributes &prefixAttrs);
1779 struct ObjCImplParsingDataRAII {
1783 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1784 LateParsedObjCMethodContainer LateParsedObjCMethods;
1786 ObjCImplParsingDataRAII(Parser &parser, Decl *
D)
1787 :
P(parser), Dcl(
D), HasCFunction(
false) {
1788 P.CurParsedObjCImpl =
this;
1791 ~ObjCImplParsingDataRAII();
1793 void finish(SourceRange AtEnd);
1794 bool isFinished()
const {
return Finished; }
1799 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1800 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1802 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1803 ParsedAttributes &Attrs);
1805 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1806 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1807 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1809 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1812 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1813 objc_nonnull, objc_nullable, objc_null_unspecified,
1816 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1818 bool isTokIdentifier_in()
const;
1821 ParsedAttributes *ParamAttrs);
1822 Decl *ParseObjCMethodPrototype(
1824 bool MethodDefinition =
true);
1827 bool MethodDefinition=
true);
1828 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1830 Decl *ParseObjCMethodDefinition();
1858 unsigned &NumLineToksConsumed,
1859 bool IsUnevaluated);
1875 enum CastParseKind {
1884 ExprResult ParseCastExpression(CastParseKind ParseKind,
1885 bool isAddressOfOperand,
1888 bool isVectorLiteral =
false,
1889 bool *NotPrimaryExpression =
nullptr);
1890 ExprResult ParseCastExpression(CastParseKind ParseKind,
1891 bool isAddressOfOperand =
false,
1893 bool isVectorLiteral =
false,
1894 bool *NotPrimaryExpression =
nullptr);
1897 bool isNotExpressionStart();
1901 bool isPostfixExpressionSuffixStart() {
1903 return (K == tok::l_square || K == tok::l_paren ||
1904 K == tok::period || K == tok::arrow ||
1905 K == tok::plusplus || K == tok::minusminus);
1908 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1909 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1910 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1911 const Token &OpToken);
1912 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1913 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1914 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1919 ExprResult ParseUnaryExprOrTypeTraitExpression();
1921 ExprResult ParseSYCLUniqueStableNameExpression();
1923 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1926 SourceRange &CastRange);
1929 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1930 llvm::function_ref<
void()> ExpressionStarts =
1931 llvm::function_ref<
void()>(),
1932 bool FailImmediatelyOnInvalidExpr =
false,
1933 bool EarlyTypoCorrection =
false);
1937 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1940 enum ParenParseOption {
1947 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1948 bool stopIfCastExpr,
1951 SourceLocation &RParenLoc);
1954 ParenParseOption &ExprType,
ParsedType &CastTy,
1957 SourceLocation LParenLoc,
1958 SourceLocation RParenLoc);
1960 ExprResult ParseGenericSelectionExpression();
1968 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1969 Token &Replacement);
1974 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1976 bool areTokensAdjacent(
const Token &A,
const Token &B);
1978 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1979 bool EnteringContext, IdentifierInfo &II,
1982 bool ParseOptionalCXXScopeSpecifier(
1983 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
1984 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
1985 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
1986 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false,
1987 bool Disambiguation =
false);
1993 enum class LambdaIntroducerTentativeParse {
2010 ParseLambdaIntroducer(LambdaIntroducer &Intro,
2011 LambdaIntroducerTentativeParse *Tentative =
nullptr);
2012 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
2031 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
2046 SourceRange &SpecificationRange,
2047 SmallVectorImpl<ParsedType> &DynamicExceptions,
2048 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2054 SourceRange &SpecificationRange,
2055 SmallVectorImpl<ParsedType> &Exceptions,
2056 SmallVectorImpl<SourceRange> &Ranges);
2061 bool MayBeFollowedByDirectInit);
2069 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2074 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2076 bool ParseCXXTypeSpecifierSeq(
2081 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2083 void ParseDirectNewDeclarator(Declarator &
D);
2084 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2085 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2086 SourceLocation Start);
2090 struct ForRangeInfo;
2091 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2095 ForRangeInfo *FRI =
nullptr,
2096 bool EnterForConditionScope =
false);
2098 ParsedAttributes &Attrs);
2109 void ParseTrailingRequiresClause(Declarator &
D);
2119 if (Tok.isNot(tok::l_brace))
2121 return ParseBraceInitializer();
2123 bool MayBeDesignationStart();
2125 struct DesignatorCompletionInfo {
2126 SmallVectorImpl<Expr *> &InitExprs;
2127 QualType PreferredBaseType;
2129 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2131 void injectEmbedTokens();
2140 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2141 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2142 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2143 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2144 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2145 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2146 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2147 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2148 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2149 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2150 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2151 bool isSimpleObjCMessageExpression();
2153 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2154 SourceLocation SuperLoc,
2156 Expr *ReceiverExpr);
2157 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2158 SourceLocation LBracloc, SourceLocation SuperLoc,
2159 ParsedType ReceiverType, Expr *ReceiverExpr);
2160 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2166 typedef SmallVector<Expr*, 12> ExprVector;
2169 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2170 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2172 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2173 SourceLocation *TrailingElseLoc =
nullptr);
2174 StmtResult ParseStatementOrDeclarationAfterAttributes(
2175 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2176 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2177 ParsedAttributes &DeclSpecAttrs);
2178 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2179 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2180 ParsedStmtContext StmtCtx);
2181 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2182 bool MissingCase =
false,
2184 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2185 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2186 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2187 unsigned ScopeFlags);
2188 void ParseCompoundStatementLeadingPragmas();
2189 void DiagnoseLabelAtEndOfCompoundStatement();
2191 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2192 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2193 Sema::ConditionResult &CondResult,
2195 SourceLocation &LParenLoc,
2196 SourceLocation &RParenLoc);
2197 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2198 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2199 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2201 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2207 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2209 SourceLocation *TrailingElseLoc,
2210 ParsedAttributes &Attrs);
2214 enum IfExistsBehavior {
2226 struct IfExistsCondition {
2228 SourceLocation KeywordLoc;
2241 IfExistsBehavior Behavior;
2244 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2245 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2246 void ParseMicrosoftIfExistsExternalDeclaration();
2247 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2248 ParsedAttributes &AccessAttrs,
2250 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2252 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2253 SmallVectorImpl<Expr *> &Constraints,
2254 SmallVectorImpl<Expr *> &Exprs);
2260 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2261 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2274 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2275 ParsedStmtContext StmtCtx);
2276 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2277 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2278 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2279 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2288 enum class DeclSpecContext {
2293 DSC_alias_declaration,
2298 DSC_template_type_arg,
2299 DSC_objc_method_result,
2308 static bool isTypeSpecifier(DeclSpecContext DSC) {
2310 case DeclSpecContext::DSC_normal:
2311 case DeclSpecContext::DSC_template_param:
2312 case DeclSpecContext::DSC_template_arg:
2313 case DeclSpecContext::DSC_class:
2314 case DeclSpecContext::DSC_top_level:
2315 case DeclSpecContext::DSC_objc_method_result:
2316 case DeclSpecContext::DSC_condition:
2319 case DeclSpecContext::DSC_template_type_arg:
2320 case DeclSpecContext::DSC_type_specifier:
2321 case DeclSpecContext::DSC_conv_operator:
2322 case DeclSpecContext::DSC_trailing:
2323 case DeclSpecContext::DSC_alias_declaration:
2324 case DeclSpecContext::DSC_association:
2325 case DeclSpecContext::DSC_new:
2328 llvm_unreachable(
"Missing DeclSpecContext case");
2332 enum class AllowDefiningTypeSpec {
2349 static AllowDefiningTypeSpec
2350 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2352 case DeclSpecContext::DSC_normal:
2353 case DeclSpecContext::DSC_class:
2354 case DeclSpecContext::DSC_top_level:
2355 case DeclSpecContext::DSC_alias_declaration:
2356 case DeclSpecContext::DSC_objc_method_result:
2357 return AllowDefiningTypeSpec::Yes;
2359 case DeclSpecContext::DSC_condition:
2360 case DeclSpecContext::DSC_template_param:
2361 return AllowDefiningTypeSpec::YesButInvalid;
2363 case DeclSpecContext::DSC_template_type_arg:
2364 case DeclSpecContext::DSC_type_specifier:
2365 return AllowDefiningTypeSpec::NoButErrorRecovery;
2367 case DeclSpecContext::DSC_association:
2368 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2369 : AllowDefiningTypeSpec::Yes;
2371 case DeclSpecContext::DSC_trailing:
2372 case DeclSpecContext::DSC_conv_operator:
2373 case DeclSpecContext::DSC_template_arg:
2374 case DeclSpecContext::DSC_new:
2375 return AllowDefiningTypeSpec::No;
2377 llvm_unreachable(
"Missing DeclSpecContext case");
2381 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2383 case DeclSpecContext::DSC_normal:
2384 case DeclSpecContext::DSC_class:
2385 case DeclSpecContext::DSC_top_level:
2388 case DeclSpecContext::DSC_alias_declaration:
2389 case DeclSpecContext::DSC_objc_method_result:
2390 case DeclSpecContext::DSC_condition:
2391 case DeclSpecContext::DSC_template_param:
2392 case DeclSpecContext::DSC_template_type_arg:
2393 case DeclSpecContext::DSC_type_specifier:
2394 case DeclSpecContext::DSC_trailing:
2395 case DeclSpecContext::DSC_association:
2396 case DeclSpecContext::DSC_conv_operator:
2397 case DeclSpecContext::DSC_template_arg:
2398 case DeclSpecContext::DSC_new:
2402 llvm_unreachable(
"Missing DeclSpecContext case");
2407 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2409 case DeclSpecContext::DSC_normal:
2410 case DeclSpecContext::DSC_template_param:
2411 case DeclSpecContext::DSC_template_arg:
2412 case DeclSpecContext::DSC_class:
2413 case DeclSpecContext::DSC_top_level:
2414 case DeclSpecContext::DSC_condition:
2415 case DeclSpecContext::DSC_type_specifier:
2416 case DeclSpecContext::DSC_association:
2417 case DeclSpecContext::DSC_conv_operator:
2418 case DeclSpecContext::DSC_new:
2421 case DeclSpecContext::DSC_objc_method_result:
2422 case DeclSpecContext::DSC_template_type_arg:
2423 case DeclSpecContext::DSC_trailing:
2424 case DeclSpecContext::DSC_alias_declaration:
2427 llvm_unreachable(
"Missing DeclSpecContext case");
2432 getImplicitTypenameContext(DeclSpecContext DSC) {
2434 case DeclSpecContext::DSC_class:
2435 case DeclSpecContext::DSC_top_level:
2436 case DeclSpecContext::DSC_type_specifier:
2437 case DeclSpecContext::DSC_template_type_arg:
2438 case DeclSpecContext::DSC_trailing:
2439 case DeclSpecContext::DSC_alias_declaration:
2440 case DeclSpecContext::DSC_template_param:
2441 case DeclSpecContext::DSC_new:
2444 case DeclSpecContext::DSC_normal:
2445 case DeclSpecContext::DSC_objc_method_result:
2446 case DeclSpecContext::DSC_condition:
2447 case DeclSpecContext::DSC_template_arg:
2448 case DeclSpecContext::DSC_conv_operator:
2449 case DeclSpecContext::DSC_association:
2452 llvm_unreachable(
"Missing DeclSpecContext case");
2457 struct ForRangeInit {
2458 SourceLocation ColonLoc;
2460 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2461 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2463 struct ForRangeInfo : ForRangeInit {
2468 SourceLocation &DeclEnd,
2469 ParsedAttributes &DeclAttrs,
2470 ParsedAttributes &DeclSpecAttrs,
2471 SourceLocation *DeclSpecStart =
nullptr);
2474 ParsedAttributes &DeclAttrs,
2475 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2476 ForRangeInit *FRI =
nullptr,
2477 SourceLocation *DeclSpecStart =
nullptr);
2480 ParsedAttributes &Attrs,
2481 ParsedTemplateInfo &TemplateInfo,
2482 SourceLocation *DeclEnd =
nullptr,
2483 ForRangeInit *FRI =
nullptr);
2484 Decl *ParseDeclarationAfterDeclarator(Declarator &
D,
2485 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2486 bool ParseAsmAttributesAfterDeclarator(Declarator &
D);
2487 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2489 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2490 ForRangeInit *FRI =
nullptr);
2491 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2492 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2498 bool trySkippingFunctionBody();
2500 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2502 DeclSpecContext DSC, ParsedAttributes &Attrs);
2506 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2508 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2509 LateParsedAttrList *LateAttrs =
nullptr) {
2510 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2511 getImplicitTypenameContext(DSC));
2514 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2516 LateParsedAttrList *LateAttrs,
2519 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2520 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2521 SourceLocation StartLoc,
2522 SourceLocation EndLoc);
2524 bool DiagnoseMissingSemiAfterTagDefinition(
2526 LateParsedAttrList *LateAttrs =
nullptr);
2528 void ParseSpecifierQualifierList(
2530 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2531 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2534 void ParseSpecifierQualifierList(
2537 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2539 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2542 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2543 const ParsedTemplateInfo &TemplateInfo,
2545 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2546 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2547 RecordDecl *TagDecl);
2549 void ParseStructDeclaration(
2550 ParsingDeclSpec &DS,
2551 llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2552 LateParsedAttrList *LateFieldAttrs =
nullptr);
2557 bool DisambiguatingWithExpression =
false);
2558 bool isTypeSpecifierQualifier();
2563 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2568 bool isKnownToBeDeclarationSpecifier() {
2581 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2583 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2591 bool isForInitDeclaration() {
2595 return Tok.is(tok::kw_using) ||
2596 isCXXSimpleDeclaration(
true);
2601 bool isForRangeIdentifier();
2605 bool isStartOfObjCClassMessageMissingOpenBracket();
2610 bool isConstructorDeclarator(
2613 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2617 enum TentativeCXXTypeIdContext {
2620 TypeIdAsTemplateArgument,
2621 TypeIdInTrailingReturnType,
2622 TypeIdAsGenericSelectionArgument,
2628 bool isTypeIdInParens(
bool &isAmbiguous) {
2630 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2631 isAmbiguous =
false;
2632 return isTypeSpecifierQualifier();
2634 bool isTypeIdInParens() {
2636 return isTypeIdInParens(isAmbiguous);
2646 bool isTypeIdForGenericSelection() {
2649 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2651 return isTypeSpecifierQualifier();
2657 bool isTypeIdUnambiguously() {
2660 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2662 return isTypeSpecifierQualifier();
2668 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2675 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2684 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2688 struct ConditionDeclarationOrInitStatementState;
2689 enum class ConditionOrInitStatement {
2699 ConditionOrInitStatement
2700 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2701 bool CanBeForRangeDecl);
2703 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2704 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2706 return isCXXTypeId(Context, isAmbiguous);
2711 enum class TPResult {
2722 bool isEnumBase(
bool AllowSemi);
2733 TPResult BracedCastResult = TPResult::False,
2734 bool *InvalidAsDeclSpec =
nullptr);
2739 bool isCXXDeclarationSpecifierAType();
2744 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2749 TPResult isExplicitBool();
2754 bool isTentativelyDeclared(IdentifierInfo *II);
2763 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2764 TPResult TryParseTypeofSpecifier();
2765 TPResult TryParseProtocolQualifiers();
2766 TPResult TryParsePtrOperatorSeq();
2767 TPResult TryParseOperatorId();
2768 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2769 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2770 bool mayHaveDirectInit =
false,
2771 bool mayHaveTrailingReturnType =
false);
2772 TPResult TryParseParameterDeclarationClause(
2773 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2776 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2777 bool NameAfterArrowIsNonType();
2778 TPResult TryParseBracketDeclarator();
2779 TPResult TryConsumeDeclarationSpecifier();
2783 bool TrySkipAttributes();
2787 void DiagnoseBitIntUse(
const Token &Tok);
2794 ParsedAttributes *Attrs =
nullptr);
2797 void ParseBlockId(SourceLocation CaretLoc);
2804 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2805 bool OuterMightBeMessageSend =
false) {
2806 return (Tok.isRegularKeywordAttribute() ||
2807 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2812 bool CheckProhibitedCXX11Attribute() {
2813 assert(Tok.is(tok::l_square));
2816 return DiagnoseProhibitedCXX11Attribute();
2819 bool DiagnoseProhibitedCXX11Attribute();
2820 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2821 SourceLocation CorrectLocation) {
2822 if (!Tok.isRegularKeywordAttribute() &&
2823 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2824 Tok.isNot(tok::kw_alignas))
2826 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2828 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2829 SourceLocation CorrectLocation);
2831 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2835 void ProhibitAttributes(ParsedAttributes &Attrs,
2836 SourceLocation FixItLoc = SourceLocation()) {
2837 if (Attrs.Range.isInvalid())
2839 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2843 void ProhibitAttributes(ParsedAttributesView &Attrs,
2844 SourceLocation FixItLoc = SourceLocation()) {
2845 if (Attrs.Range.isInvalid())
2847 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2848 Attrs.clearListOnly();
2850 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2851 SourceLocation FixItLoc);
2859 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2860 unsigned KeywordDiagId,
2861 bool DiagnoseEmptyAttrs =
false,
2862 bool WarnOnUnknownAttrs =
false);
2867 SourceLocation SkipCXX11Attributes();
2871 void DiagnoseAndSkipCXX11Attributes();
2875 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2877 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2881 SmallVectorImpl<Expr *> &Exprs,
2882 ParsedAttributeArgumentsProperties ArgsProperties);
2889 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2890 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2891 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2892 ParsedAttr::Form Form);
2894 enum ParseAttrKindMask {
2896 PAKM_Declspec = 1 << 1,
2897 PAKM_CXX11 = 1 << 2,
2914 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2915 LateParsedAttrList *LateAttrs =
nullptr);
2918 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2919 LateParsedAttrList *LateAttrs =
nullptr) {
2920 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2921 isAllowedCXX11AttributeSpecifier()) {
2922 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2928 void MaybeParseGNUAttributes(Declarator &
D,
2929 LateParsedAttrList *LateAttrs =
nullptr) {
2930 if (Tok.is(tok::kw___attribute)) {
2931 ParsedAttributes Attrs(AttrFactory);
2932 ParseGNUAttributes(Attrs, LateAttrs, &
D);
2933 D.takeAttributes(Attrs);
2937 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2938 LateParsedAttrList *LateAttrs =
nullptr) {
2939 if (Tok.is(tok::kw___attribute)) {
2940 ParseGNUAttributes(Attrs, LateAttrs);
2946 void ParseGNUAttributes(ParsedAttributes &Attrs,
2947 LateParsedAttrList *LateAttrs =
nullptr,
2948 Declarator *
D =
nullptr);
2949 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2950 SourceLocation AttrNameLoc,
2951 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2952 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2953 ParsedAttr::Form Form, Declarator *
D);
2954 IdentifierLoc *ParseIdentifierLoc();
2957 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2958 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2959 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2960 ParsedAttr::Form Form);
2962 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2965 if (!OpenMPTokens.empty()) {
2967 PP.EnterTokenStream(OpenMPTokens,
true,
2972 void MaybeParseCXX11Attributes(Declarator &
D) {
2973 if (isAllowedCXX11AttributeSpecifier()) {
2974 ParsedAttributes Attrs(AttrFactory);
2975 ParseCXX11Attributes(Attrs);
2976 D.takeAttributes(Attrs);
2980 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2981 bool OuterMightBeMessageSend =
false) {
2982 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2983 ParseCXX11Attributes(Attrs);
2989 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
2992 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2994 SourceLocation *EndLoc =
nullptr);
2995 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2996 SourceLocation *EndLoc =
nullptr) {
2998 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2999 ReplayOpenMPAttributeTokens(OpenMPTokens);
3001 void ParseCXX11Attributes(ParsedAttributes &attrs);
3004 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
3005 SourceLocation AttrNameLoc,
3006 ParsedAttributes &Attrs, SourceLocation *EndLoc,
3007 IdentifierInfo *ScopeName,
3008 SourceLocation ScopeLoc,
3012 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
3013 IdentifierInfo *AttrName,
3014 SourceLocation AttrNameLoc,
3015 SourceLocation *EndLoc,
3016 ParsedAttr::Form Form);
3018 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3019 SourceLocation &
Loc,
3022 const IdentifierInfo *EnclosingScope =
nullptr);
3024 void MaybeParseHLSLAnnotations(Declarator &
D,
3025 SourceLocation *EndLoc =
nullptr,
3026 bool CouldBeBitField =
false) {
3027 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3028 if (Tok.is(tok::colon)) {
3029 ParsedAttributes Attrs(AttrFactory);
3030 ParseHLSLAnnotations(Attrs, EndLoc, CouldBeBitField);
3031 D.takeAttributes(Attrs);
3035 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
3036 SourceLocation *EndLoc =
nullptr) {
3037 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3038 if (Tok.is(tok::colon))
3039 ParseHLSLAnnotations(Attrs, EndLoc);
3042 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
3043 SourceLocation *EndLoc =
nullptr,
3044 bool CouldBeBitField =
false);
3045 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
3047 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3049 Tok.is(tok::l_square)) {
3050 ParsedAttributes AttrsWithRange(AttrFactory);
3051 ParseMicrosoftAttributes(AttrsWithRange);
3052 Attrs.takeAllFrom(AttrsWithRange);
3055 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3056 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3057 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3058 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3059 ParseMicrosoftDeclSpecs(Attrs);
3064 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3065 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3066 SourceLocation AttrNameLoc,
3067 ParsedAttributes &Attrs);
3068 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3069 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3070 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3071 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3072 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3073 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3074 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3075 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3076 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3077 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3078 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3079 bool isHLSLQualifier(
const Token &Tok)
const;
3080 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3082 VersionTuple ParseVersionTuple(SourceRange &
Range);
3083 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3084 SourceLocation AvailabilityLoc,
3085 ParsedAttributes &attrs,
3086 SourceLocation *endLoc,
3087 IdentifierInfo *ScopeName,
3088 SourceLocation ScopeLoc,
3089 ParsedAttr::Form Form);
3091 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3092 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3094 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3096 ParsedAttributes &Attrs,
3097 SourceLocation *EndLoc,
3098 IdentifierInfo *ScopeName,
3099 SourceLocation ScopeLoc,
3100 ParsedAttr::Form Form);
3102 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3103 SourceLocation ObjCBridgeRelatedLoc,
3104 ParsedAttributes &Attrs,
3105 SourceLocation *EndLoc,
3106 IdentifierInfo *ScopeName,
3107 SourceLocation ScopeLoc,
3108 ParsedAttr::Form Form);
3110 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3111 SourceLocation AttrNameLoc,
3112 ParsedAttributes &Attrs,
3113 SourceLocation *EndLoc,
3114 IdentifierInfo *ScopeName,
3115 SourceLocation ScopeLoc,
3116 ParsedAttr::Form Form);
3118 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3119 SourceLocation AttrNameLoc,
3120 ParsedAttributes &Attrs,
3121 SourceLocation *EndLoc,
3122 IdentifierInfo *ScopeName,
3123 SourceLocation ScopeLoc,
3124 ParsedAttr::Form Form);
3126 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3127 SourceLocation AttrNameLoc,
3128 ParsedAttributes &Attrs,
3129 IdentifierInfo *ScopeName,
3130 SourceLocation ScopeLoc,
3131 ParsedAttr::Form Form);
3133 void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
3135 void ParseBoundsAttribute(IdentifierInfo &AttrName,
3136 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
3137 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3138 ParsedAttr::Form Form);
3140 void ParseTypeofSpecifier(DeclSpec &DS);
3141 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3142 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3143 SourceLocation StartLoc,
3144 SourceLocation EndLoc);
3145 void ParseAtomicSpecifier(DeclSpec &DS);
3147 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3148 SourceLocation &EllipsisLoc,
bool &IsType,
3150 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3151 SourceLocation *endLoc =
nullptr);
3156 return isCXX11VirtSpecifier(Tok);
3158 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3159 SourceLocation FriendLoc);
3161 bool isCXX11FinalKeyword()
const;
3162 bool isClassCompatibleKeyword()
const;
3167 class DeclaratorScopeObj {
3173 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3174 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3176 void EnterDeclaratorScope() {
3177 assert(!EnteredScope &&
"Already entered the scope!");
3178 assert(SS.isSet() &&
"C++ scope was not set!");
3180 CreatedScope =
true;
3183 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3184 EnteredScope =
true;
3187 ~DeclaratorScopeObj() {
3189 assert(SS.isSet() &&
"C++ scope was cleared ?");
3190 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3198 void ParseDeclarator(Declarator &
D);
3200 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3201 void ParseDeclaratorInternal(Declarator &
D,
3202 DirectDeclParseFunction DirectDeclParser);
3204 enum AttrRequirements {
3205 AR_NoAttributesParsed = 0,
3206 AR_GNUAttributesParsedAndRejected = 1 << 0,
3207 AR_GNUAttributesParsed = 1 << 1,
3208 AR_CXX11AttributesParsed = 1 << 2,
3209 AR_DeclspecAttributesParsed = 1 << 3,
3210 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3211 AR_CXX11AttributesParsed |
3212 AR_DeclspecAttributesParsed,
3213 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3214 AR_DeclspecAttributesParsed
3217 void ParseTypeQualifierListOpt(
3218 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3219 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3220 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3222 void ParseDirectDeclarator(Declarator &
D);
3223 void ParseDecompositionDeclarator(Declarator &
D);
3224 void ParseParenDeclarator(Declarator &
D);
3225 void ParseFunctionDeclarator(Declarator &
D, ParsedAttributes &FirstArgAttrs,
3227 bool IsAmbiguous,
bool RequiresArg =
false);
3228 void InitCXXThisScopeForDeclaratorIfRelevant(
3229 const Declarator &
D,
const DeclSpec &DS,
3230 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3231 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3232 SourceLocation &RefQualifierLoc);
3233 bool isFunctionDeclaratorIdentifierList();
3234 void ParseFunctionDeclaratorIdentifierList(
3236 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3237 void ParseParameterDeclarationClause(
3238 Declarator &
D, ParsedAttributes &attrs,
3239 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3240 SourceLocation &EllipsisLoc) {
3241 return ParseParameterDeclarationClause(
3242 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3243 D.getCXXScopeSpec().isSet() &&
3244 D.isFunctionDeclaratorAFunctionDeclaration());
3246 void ParseParameterDeclarationClause(
3248 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3249 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3251 void ParseBracketDeclarator(Declarator &
D);
3252 void ParseMisplacedBracketDeclarator(Declarator &
D);
3253 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3260 enum CXX11AttributeKind {
3262 CAK_NotAttributeSpecifier,
3264 CAK_AttributeSpecifier,
3267 CAK_InvalidAttributeSpecifier
3270 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3271 bool OuterMightBeMessageSend =
false);
3273 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3276 SourceLocation &DeclEnd,
3277 SourceLocation InlineLoc = SourceLocation());
3279 struct InnerNamespaceInfo {
3280 SourceLocation NamespaceLoc;
3281 SourceLocation InlineLoc;
3282 SourceLocation IdentLoc;
3283 IdentifierInfo *Ident;
3287 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3288 unsigned int index, SourceLocation &InlineLoc,
3289 ParsedAttributes &attrs,
3292 Decl *ParseExportDeclaration();
3295 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3297 SourceLocation UsingLoc,
3298 SourceLocation &DeclEnd,
3299 ParsedAttributes &attrs);
3301 struct UsingDeclarator {
3302 SourceLocation TypenameLoc;
3305 SourceLocation EllipsisLoc;
3308 TypenameLoc = EllipsisLoc = SourceLocation();
3316 const ParsedTemplateInfo &TemplateInfo,
3317 SourceLocation UsingLoc,
3318 SourceLocation &DeclEnd,
3319 ParsedAttributes &Attrs,
3321 Decl *ParseAliasDeclarationAfterDeclarator(
3322 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3324 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3326 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3327 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3328 SourceLocation AliasLoc, IdentifierInfo *Alias,
3329 SourceLocation &DeclEnd);
3333 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3334 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3335 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3337 DeclSpecContext DSC, ParsedAttributes &Attributes);
3338 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3339 SourceLocation AttrFixitLoc,
3342 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3343 SourceLocation AttrFixitLoc,
3344 ParsedAttributes &Attrs,
unsigned TagType,
3346 ExprResult ParseCXXMemberInitializer(Decl *
D,
bool IsFunction,
3347 SourceLocation &EqualLoc);
3349 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3352 LateParsedAttrList &LateAttrs);
3353 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &
D,
3354 VirtSpecifiers &VS);
3357 ParsedTemplateInfo &TemplateInfo,
3358 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3361 ParsedAttributes &AccessAttrs,
3363 void ParseConstructorInitializer(Decl *ConstructorDecl);
3365 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3370 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3371 SourceLocation &EndLocation);
3372 void ParseBaseClause(Decl *ClassDecl);
3373 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3376 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3378 bool ObjectHadErrors,
3379 SourceLocation TemplateKWLoc,
3380 IdentifierInfo *Name,
3381 SourceLocation NameLoc,
3382 bool EnteringContext,
3384 bool AssumeTemplateId);
3385 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3394 SourceLocation
Loc);
3398 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3399 llvm::omp::TraitSet
Set,
3400 llvm::omp::TraitSelector Selector,
3401 llvm::StringMap<SourceLocation> &Seen);
3404 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3405 llvm::omp::TraitSet
Set,
3406 llvm::StringMap<SourceLocation> &Seen);
3409 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3410 llvm::StringMap<SourceLocation> &Seen);
3413 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3414 llvm::omp::TraitSet
Set,
3415 llvm::StringMap<SourceLocation> &Seen);
3418 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3419 llvm::omp::TraitSet
Set,
3420 llvm::StringMap<SourceLocation> &SeenSelectors);
3423 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3424 llvm::StringMap<SourceLocation> &SeenSets);
3427 bool parseOMPContextSelectors(SourceLocation
Loc, OMPTraitInfo &TI);
3430 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3434 bool parseOMPDeclareVariantMatchClause(SourceLocation
Loc, OMPTraitInfo &TI,
3435 OMPTraitInfo *ParentTI);
3439 SourceLocation
Loc);
3443 SourceLocation
Loc);
3446 void ParseOpenMPEndAssumesDirective(SourceLocation
Loc);
3454 SmallVectorImpl<clang::OMPClause *> &Clauses,
3455 SourceLocation
Loc);
3458 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
3463 SourceLocation
Loc);
3476 SourceLocation MatchingLoc,
3477 SourceLocation FoundLoc,
3478 bool SkipUntilOpenMPEnd);
3484 Decl *TagDecl =
nullptr);
3489 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3495 DeclarationName &Name,
3500 bool tryParseOpenMPArrayShapingCastPart();
3509 bool ParseOpenMPSimpleVarList(
3511 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3513 bool AllowScopeSpecifier);
3519 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3520 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3530 ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx,
3532 bool ReadDirectiveWithinMetadirective);
3541 StmtResult ParseOpenMPInformationalDirective(
3543 bool ReadDirectiveWithinMetadirective);
3572 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
3587 OMPClause *ParseOpenMPSizesClause();
3595 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3616 SourceLocation &ClauseNameLoc,
3617 SourceLocation &OpenLoc,
3618 SourceLocation &CloseLoc,
3619 SmallVectorImpl<Expr *> &Exprs,
3620 bool ReqIntConst =
false);
3633 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3641 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3648 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3655 bool IsAddressOfOperand =
false);
3659 SemaOpenMP::OpenMPVarListDataTy &
Data,
3660 const LangOptions &LangOpts);
3663 SmallVectorImpl<Expr *> &Vars,
3664 SemaOpenMP::OpenMPVarListDataTy &
Data);
3666 bool ObjectHadErrors,
bool EnteringContext,
3667 bool AllowDestructorName,
bool AllowConstructorName,
3668 bool AllowDeductionGuide,
3669 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3692 struct OpenACCDirectiveParseInfo {
3694 SourceLocation StartLoc;
3695 SourceLocation DirLoc;
3696 SourceLocation EndLoc;
3697 SmallVector<OpenACCClause *> Clauses;
3702 struct OpenACCWaitParseInfo {
3703 bool Failed =
false;
3704 Expr *DevNumExpr =
nullptr;
3705 SourceLocation QueuesLoc;
3706 SmallVector<Expr *> QueueIdExprs;
3711 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
3717 using OpenACCClauseParseResult =
3718 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
3720 OpenACCClauseParseResult OpenACCCanContinue();
3721 OpenACCClauseParseResult OpenACCCannotContinue();
3722 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
3726 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3730 void ParseOpenACCCacheVarList();
3732 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
3739 OpenACCClauseParseResult
3740 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
3742 SourceLocation ClauseLoc);
3745 OpenACCClauseParseResult
3746 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
3749 SmallVector<OpenACCClause *>
3751 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation
Loc,
3760 using OpenACCIntExprParseResult =
3761 std::pair<ExprResult, OpenACCParseCanContinue>;
3766 SourceLocation
Loc);
3773 bool ParseOpenACCDeviceTypeList(
3779 SourceLocation
Loc);
3781 bool ParseOpenACCSizeExpr();
3783 bool ParseOpenACCSizeExprList();
3785 bool ParseOpenACCGangArgList(SourceLocation GangLoc);
3787 bool ParseOpenACCGangArg(SourceLocation GangLoc);
3798 SourceLocation &DeclEnd,
3799 ParsedAttributes &AccessAttrs);
3805 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3807 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3808 SmallVectorImpl<NamedDecl *> &TemplateParams,
3809 SourceLocation &LAngleLoc,
3810 SourceLocation &RAngleLoc);
3811 bool ParseTemplateParameterList(
unsigned Depth,
3812 SmallVectorImpl<NamedDecl*> &TemplateParams);
3813 TPResult isStartOfTemplateTypeParameter();
3814 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3815 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3816 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3817 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3818 bool isTypeConstraintAnnotation();
3819 bool TryAnnotateTypeConstraint();
3820 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3821 SourceLocation CorrectLoc,
3822 bool AlreadyHasEllipsis,
3823 bool IdentifierHasName);
3824 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3827 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3829 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3830 SourceLocation &RAngleLoc,
3831 bool ConsumeLastToken,
3832 bool ObjCGenericList);
3833 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3834 SourceLocation &LAngleLoc,
3835 TemplateArgList &TemplateArgs,
3836 SourceLocation &RAngleLoc,
3841 SourceLocation TemplateKWLoc,
3842 UnqualifiedId &TemplateName,
3843 bool AllowTypeAnnotation =
true,
3844 bool TypeConstraint =
false);
3846 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3848 bool IsClassName =
false);
3849 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3850 TemplateTy Template, SourceLocation OpenLoc);
3851 ParsedTemplateArgument ParseTemplateTemplateArgument();
3852 ParsedTemplateArgument ParseTemplateArgument();
3854 SourceLocation ExternLoc,
3855 SourceLocation TemplateLoc,
3856 SourceLocation &DeclEnd,
3857 ParsedAttributes &AccessAttrs,
3861 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3862 SourceLocation &DeclEnd);
3873 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3874 SourceLocation IncludeLoc);
3879 Decl *ParseModuleImport(SourceLocation AtLoc,
3881 bool parseMisplacedModuleImport();
3882 bool tryParseMisplacedModuleImport() {
3884 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3885 Kind == tok::annot_module_include)
3886 return parseMisplacedModuleImport();
3890 bool ParseModuleName(
3891 SourceLocation UseLoc,
3892 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &
Path,
3904 ExprResult ParseBuiltinPtrauthTypeDiscriminator();
3908 void CodeCompleteDirective(
bool InConditional)
override;
3909 void CodeCompleteInConditionalExclusion()
override;
3910 void CodeCompleteMacroName(
bool IsDefinition)
override;
3911 void CodeCompletePreprocessorExpression()
override;
3912 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3913 unsigned ArgumentIndex)
override;
3914 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3915 void CodeCompleteNaturalLanguage()
override;
3917 class GNUAsmQualifiers {
3918 unsigned Qualifiers = AQ_unspecified;
3927 static const char *getQualifierName(AQ Qualifier);
3928 bool setAsmQualifier(AQ Qualifier);
3929 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3930 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3931 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3933 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3934 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3935 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3936 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
enum clang::sema::@1658::IndirectLocalPathEntry::EntryKind Kind
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 ...
@ LLVM_MARK_AS_BITMASK_ENUM
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.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
NullabilityKind
Describes the nullability of a particular type.
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