13#ifndef LLVM_CLANG_PARSE_PARSER_H
14#define LLVM_CLANG_PARSE_PARSER_H
22#include "llvm/ADT/SmallVector.h"
23#include "llvm/Frontend/OpenMP/OMPContext.h"
24#include "llvm/Support/SaveAndRestore.h"
31 class BalancedDelimiterTracker;
32 class CorrectionCandidateCallback;
34 class DiagnosticBuilder;
37 class ParsingDeclRAIIObject;
38 class ParsingDeclSpec;
39 class ParsingDeclarator;
40 class ParsingFieldDeclarator;
41 class ColonProtectionRAIIObject;
42 class InMessageExpressionRAIIObject;
43 class PoisonSEHIdentifiersRAIIObject;
46 class ObjCTypeParamList;
47 struct OMPTraitProperty;
48 struct OMPTraitSelector;
83 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
84 unsigned short MisplacedModuleBeginCount = 0;
93 enum { ScopeCacheSize = 16 };
94 unsigned NumCachedScopes;
95 Scope *ScopeCache[ScopeCacheSize];
101 *Ident___exception_code,
102 *Ident_GetExceptionCode;
105 *Ident___exception_info,
106 *Ident_GetExceptionInfo;
109 *Ident___abnormal_termination,
110 *Ident_AbnormalTermination;
156 *Ident_generated_declaration, *Ident_USR;
169 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
171 std::unique_ptr<PragmaHandler> AlignHandler;
172 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
173 std::unique_ptr<PragmaHandler> OptionsHandler;
174 std::unique_ptr<PragmaHandler> PackHandler;
175 std::unique_ptr<PragmaHandler> MSStructHandler;
176 std::unique_ptr<PragmaHandler> UnusedHandler;
177 std::unique_ptr<PragmaHandler> WeakHandler;
178 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
179 std::unique_ptr<PragmaHandler> FPContractHandler;
180 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
181 std::unique_ptr<PragmaHandler> OpenMPHandler;
182 std::unique_ptr<PragmaHandler> OpenACCHandler;
183 std::unique_ptr<PragmaHandler> PCSectionHandler;
184 std::unique_ptr<PragmaHandler> MSCommentHandler;
185 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
186 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
187 std::unique_ptr<PragmaHandler> FloatControlHandler;
188 std::unique_ptr<PragmaHandler> MSPointersToMembers;
189 std::unique_ptr<PragmaHandler> MSVtorDisp;
190 std::unique_ptr<PragmaHandler> MSInitSeg;
191 std::unique_ptr<PragmaHandler> MSDataSeg;
192 std::unique_ptr<PragmaHandler> MSBSSSeg;
193 std::unique_ptr<PragmaHandler> MSConstSeg;
194 std::unique_ptr<PragmaHandler> MSCodeSeg;
195 std::unique_ptr<PragmaHandler> MSSection;
196 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
197 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
198 std::unique_ptr<PragmaHandler> MSIntrinsic;
199 std::unique_ptr<PragmaHandler> MSFunction;
200 std::unique_ptr<PragmaHandler> MSOptimize;
201 std::unique_ptr<PragmaHandler> MSFenvAccess;
202 std::unique_ptr<PragmaHandler> MSAllocText;
203 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
204 std::unique_ptr<PragmaHandler> OptimizeHandler;
205 std::unique_ptr<PragmaHandler> LoopHintHandler;
206 std::unique_ptr<PragmaHandler> UnrollHintHandler;
207 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
208 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
209 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
210 std::unique_ptr<PragmaHandler> FPHandler;
211 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
212 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
213 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
214 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
215 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
216 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
217 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
218 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
220 std::unique_ptr<CommentHandler> CommentSemaHandler;
226 bool GreaterThanIsOperator;
235 bool OpenMPDirectiveParsing =
false;
238 bool OpenACCDirectiveParsing =
false;
242 bool AllowOpenACCArraySections =
false;
246 class OpenACCArraySectionRAII {
250 OpenACCArraySectionRAII(
Parser &P) :
P(
P) {
251 assert(!
P.AllowOpenACCArraySections);
252 P.AllowOpenACCArraySections =
true;
254 ~OpenACCArraySectionRAII() {
255 assert(
P.AllowOpenACCArraySections);
256 P.AllowOpenACCArraySections =
false;
265 bool InMessageExpression;
270 bool CalledSignatureHelp =
false;
275 unsigned TemplateParameterDepth;
281 class TemplateParameterDepthRAII {
283 unsigned AddedLevels;
285 explicit TemplateParameterDepthRAII(
unsigned &Depth)
286 : Depth(Depth), AddedLevels(0) {}
288 ~TemplateParameterDepthRAII() {
289 Depth -= AddedLevels;
296 void addDepth(
unsigned D) {
300 void setAddedDepth(
unsigned D) {
301 Depth = Depth - AddedLevels + D;
305 unsigned getDepth()
const {
return Depth; }
306 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
310 AttributeFactory AttrFactory;
314 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
320 bool DelayTemplateIdDestruction =
false;
322 void MaybeDestroyTemplateIds() {
323 if (DelayTemplateIdDestruction)
325 if (!TemplateIds.empty() &&
327 DestroyTemplateIds();
329 void DestroyTemplateIds();
333 struct DestroyTemplateIdAnnotationsRAIIObj {
336 DestroyTemplateIdAnnotationsRAIIObj(Parser &Self) : Self(Self) {}
337 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
340 struct DelayTemplateIdDestructionRAII {
342 bool PrevDelayTemplateIdDestruction;
344 DelayTemplateIdDestructionRAII(Parser &Self,
345 bool DelayTemplateIdDestruction) noexcept
347 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
348 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
351 ~DelayTemplateIdDestructionRAII() noexcept {
352 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
357 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
369 struct AngleBracketTracker {
379 SpaceBeforeLess = 0x0,
381 NoSpaceBeforeLess = 0x1,
412 if (!Locs.empty() && Locs.back().isActive(
P)) {
413 if (Locs.back().Priority <= Prio) {
415 Locs.back().LessLoc = LessLoc;
416 Locs.back().Priority = Prio;
419 Locs.push_back({TemplateName, LessLoc, Prio,
420 P.ParenCount,
P.BracketCount,
P.BraceCount});
427 void clear(Parser &
P) {
428 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
434 Loc *getCurrent(Parser &
P) {
435 if (!Locs.empty() && Locs.back().isActive(
P))
441 AngleBracketTracker AngleBrackets;
443 IdentifierInfo *getSEHExceptKeyword();
450 bool ParsingInObjCContainer;
456 bool SkipFunctionBodies;
461 SourceLocation ExprStatementTokLoc;
464 enum class ParsedStmtContext {
466 AllowStandaloneOpenMPDirectives = 0x1,
473 Compound = AllowStandaloneOpenMPDirectives,
484 Parser(Preprocessor &PP, Sema &Actions,
bool SkipFunctionBodies);
541 assert(!isTokenSpecial() &&
542 "Should consume special tokens with Consume*Token");
545 return PrevTokLocation;
551 assert(!isTokenSpecial() &&
552 "Should consume special tokens with Consume*Token");
561 Loc = PrevTokLocation;
570 return ConsumeParen();
571 if (isTokenBracket())
572 return ConsumeBracket();
574 return ConsumeBrace();
575 if (isTokenStringLiteral())
576 return ConsumeStringToken();
577 if (Tok.
is(tok::code_completion))
578 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
579 : handleUnexpectedCodeCompletionToken();
581 return ConsumeAnnotationToken();
602 bool isTokenParen()
const {
603 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
606 bool isTokenBracket()
const {
607 return Tok.
isOneOf(tok::l_square, tok::r_square);
610 bool isTokenBrace()
const {
611 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
614 bool isTokenStringLiteral()
const {
618 bool isTokenSpecial()
const {
619 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
620 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
625 bool isTokenEqualOrEqualTypo();
629 void UnconsumeToken(Token &Consumed) {
636 SourceLocation ConsumeAnnotationToken() {
646 SourceLocation ConsumeParen() {
647 assert(isTokenParen() &&
"wrong consume method");
648 if (Tok.
getKind() == tok::l_paren)
650 else if (ParenCount) {
651 AngleBrackets.clear(*
this);
656 return PrevTokLocation;
661 SourceLocation ConsumeBracket() {
662 assert(isTokenBracket() &&
"wrong consume method");
663 if (Tok.
getKind() == tok::l_square)
665 else if (BracketCount) {
666 AngleBrackets.clear(*
this);
672 return PrevTokLocation;
677 SourceLocation ConsumeBrace() {
678 assert(isTokenBrace() &&
"wrong consume method");
679 if (Tok.
getKind() == tok::l_brace)
681 else if (BraceCount) {
682 AngleBrackets.clear(*
this);
688 return PrevTokLocation;
695 SourceLocation ConsumeStringToken() {
696 assert(isTokenStringLiteral() &&
697 "Should only consume string literals with this method");
700 return PrevTokLocation;
708 SourceLocation ConsumeCodeCompletionToken() {
709 assert(Tok.
is(tok::code_completion));
712 return PrevTokLocation;
720 SourceLocation handleUnexpectedCodeCompletionToken();
724 void cutOffParsing() {
735 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
736 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
737 Kind == tok::annot_repl_input_end;
747 void initializePragmaHandlers();
750 void resetPragmaHandlers();
753 void HandlePragmaUnused();
757 void HandlePragmaVisibility();
761 void HandlePragmaPack();
765 void HandlePragmaMSStruct();
767 void HandlePragmaMSPointersToMembers();
769 void HandlePragmaMSVtorDisp();
771 void HandlePragmaMSPragma();
772 bool HandlePragmaMSSection(StringRef PragmaName,
773 SourceLocation PragmaLocation);
774 bool HandlePragmaMSSegment(StringRef PragmaName,
775 SourceLocation PragmaLocation);
776 bool HandlePragmaMSInitSeg(StringRef PragmaName,
777 SourceLocation PragmaLocation);
778 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
779 SourceLocation PragmaLocation);
780 bool HandlePragmaMSFunction(StringRef PragmaName,
781 SourceLocation PragmaLocation);
782 bool HandlePragmaMSAllocText(StringRef PragmaName,
783 SourceLocation PragmaLocation);
784 bool HandlePragmaMSOptimize(StringRef PragmaName,
785 SourceLocation PragmaLocation);
789 void HandlePragmaAlign();
793 void HandlePragmaDump();
797 void HandlePragmaWeak();
801 void HandlePragmaWeakAlias();
805 void HandlePragmaRedefineExtname();
809 void HandlePragmaFPContract();
813 void HandlePragmaFEnvAccess();
817 void HandlePragmaFEnvRound();
821 void HandlePragmaCXLimitedRange();
825 void HandlePragmaFloatControl();
829 void HandlePragmaFP();
833 void HandlePragmaOpenCLExtension();
841 bool HandlePragmaLoopHint(LoopHint &Hint);
843 bool ParsePragmaAttributeSubjectMatchRuleSet(
845 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
847 void HandlePragmaAttribute();
856 const Token &GetLookAheadToken(
unsigned N) {
857 if (N == 0 || Tok.
is(tok::eof))
return Tok;
877 assert((
T.isInvalid() ||
T.get()) &&
878 "produced a valid-but-null type annotation?");
882 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
883 return static_cast<NamedDecl*
>(Tok.getAnnotationValue());
886 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
887 Tok.setAnnotationValue(ND);
890 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
891 return static_cast<IdentifierInfo*
>(Tok.getAnnotationValue());
894 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
895 Tok.setAnnotationValue(ND);
900 static ExprResult getExprAnnotation(
const Token &Tok) {
901 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
906 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
907 Tok.setAnnotationValue(ER.getAsOpaquePointer());
917 CXXScopeSpec &SS,
bool IsNewScope,
923 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
924 (Tok.is(tok::annot_template_id) &&
926 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
933 enum AnnotatedNameKind {
947 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
952 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
957 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
958 const char *&PrevSpec,
unsigned &DiagID,
963 if (Tok.getIdentifierInfo() != Ident_vector &&
964 Tok.getIdentifierInfo() != Ident_bool &&
965 Tok.getIdentifierInfo() != Ident_Bool &&
966 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
969 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
975 bool TryAltiVecVectorToken() {
977 Tok.getIdentifierInfo() != Ident_vector)
return false;
978 return TryAltiVecVectorTokenOutOfLine();
981 bool TryAltiVecVectorTokenOutOfLine();
982 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
983 const char *&PrevSpec,
unsigned &DiagID,
989 bool isObjCInstancetype() {
991 if (Tok.isAnnotation())
993 if (!Ident_instancetype)
995 return Tok.getIdentifierInfo() == Ident_instancetype;
1003 bool TryKeywordIdentFallback(
bool DisableKeyword);
1006 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
1019 class TentativeParsingAction {
1021 PreferredTypeBuilder PrevPreferredType;
1023 size_t PrevTentativelyDeclaredIdentifierCount;
1024 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
1028 explicit TentativeParsingAction(Parser &p)
1029 :
P(p), PrevPreferredType(
P.PreferredType) {
1031 PrevTentativelyDeclaredIdentifierCount =
1032 P.TentativelyDeclaredIdentifiers.size();
1033 PrevParenCount =
P.ParenCount;
1034 PrevBracketCount =
P.BracketCount;
1035 PrevBraceCount =
P.BraceCount;
1036 P.PP.EnableBacktrackAtThisPos();
1040 assert(isActive &&
"Parsing action was finished!");
1041 P.TentativelyDeclaredIdentifiers.resize(
1042 PrevTentativelyDeclaredIdentifierCount);
1043 P.PP.CommitBacktrackedTokens();
1047 assert(isActive &&
"Parsing action was finished!");
1049 P.PreferredType = PrevPreferredType;
1051 P.TentativelyDeclaredIdentifiers.resize(
1052 PrevTentativelyDeclaredIdentifierCount);
1053 P.ParenCount = PrevParenCount;
1054 P.BracketCount = PrevBracketCount;
1055 P.BraceCount = PrevBraceCount;
1058 ~TentativeParsingAction() {
1059 assert(!isActive &&
"Forgot to call Commit or Revert!");
1064 class RevertingTentativeParsingAction
1065 :
private Parser::TentativeParsingAction {
1067 RevertingTentativeParsingAction(Parser &P)
1068 : Parser::TentativeParsingAction(
P) {}
1069 ~RevertingTentativeParsingAction() { Revert(); }
1072 class UnannotatedTentativeParsingAction;
1079 ObjCContainerDecl *DC;
1080 SaveAndRestore<bool> WithinObjCContainer;
1082 explicit ObjCDeclContextSwitch(Parser &p)
1084 WithinObjCContainer(
P.ParsingInObjCContainer, DC != nullptr) {
1086 P.Actions.ActOnObjCTemporaryExitContainerContext(DC);
1088 ~ObjCDeclContextSwitch() {
1090 P.Actions.ActOnObjCReenterContainerContext(DC);
1103 unsigned Diag = diag::err_expected,
1104 StringRef DiagMsg =
"");
1111 bool ExpectAndConsumeSemi(
unsigned DiagID , StringRef TokenUsed =
"");
1114 enum ExtraSemiKind {
1115 OutsideFunction = 0,
1117 InstanceVariableList = 2,
1118 AfterMemberFunctionDefinition = 3
1130 bool expectIdentifier();
1133 enum class CompoundToken {
1148 void checkCompoundToken(SourceLocation FirstTokLoc,
1151 void diagnoseUseOfC11Keyword(
const Token &Tok);
1173 bool BeforeCompoundStmt =
false)
1175 if (EnteredScope && !BeforeCompoundStmt)
1176 Self->EnterScope(ScopeFlags);
1178 if (BeforeCompoundStmt)
1179 Self->incrementMSManglingNumber();
1181 this->Self =
nullptr;
1203 unsigned NumScopes = 0;
1210 Self.EnterScope(ScopeFlags);
1235 class ParseScopeFlags {
1237 unsigned OldFlags = 0;
1238 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1239 void operator=(
const ParseScopeFlags &) =
delete;
1242 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1250 DiagnosticBuilder
Diag(SourceLocation Loc,
unsigned DiagID);
1251 DiagnosticBuilder
Diag(
const Token &Tok,
unsigned DiagID);
1253 return Diag(Tok, DiagID);
1274 static_cast<unsigned>(R));
1316 struct ParsingClass;
1326 class LateParsedDeclaration {
1328 virtual ~LateParsedDeclaration();
1330 virtual void ParseLexedMethodDeclarations();
1331 virtual void ParseLexedMemberInitializers();
1332 virtual void ParseLexedMethodDefs();
1333 virtual void ParseLexedAttributes();
1334 virtual void ParseLexedPragmas();
1339 class LateParsedClass :
public LateParsedDeclaration {
1341 LateParsedClass(
Parser *
P, ParsingClass *
C);
1342 ~LateParsedClass()
override;
1344 void ParseLexedMethodDeclarations()
override;
1345 void ParseLexedMemberInitializers()
override;
1346 void ParseLexedMethodDefs()
override;
1347 void ParseLexedAttributes()
override;
1348 void ParseLexedPragmas()
override;
1352 ParsingClass *
Class;
1361 struct LateParsedAttribute :
public LateParsedDeclaration {
1364 IdentifierInfo &AttrName;
1365 IdentifierInfo *MacroII =
nullptr;
1366 SourceLocation AttrNameLoc;
1367 SmallVector<Decl*, 2> Decls;
1369 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1371 : Self(
P), AttrName(Name), AttrNameLoc(Loc) {}
1373 void ParseLexedAttributes()
override;
1375 void addDecl(Decl *D) { Decls.push_back(D); }
1382 class LateParsedPragma :
public LateParsedDeclaration {
1383 Parser *Self =
nullptr;
1389 : Self(
P), AS(AS) {}
1391 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1395 void ParseLexedPragmas()
override;
1399 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1401 LateParsedAttrList(
bool PSoon =
false,
1402 bool LateAttrParseExperimentalExtOnly =
false)
1404 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1406 bool parseSoon() {
return ParseSoon; }
1409 bool lateAttrParseExperimentalExtOnly() {
1410 return LateAttrParseExperimentalExtOnly;
1415 bool LateAttrParseExperimentalExtOnly;
1421 struct LexedMethod :
public LateParsedDeclaration {
1426 explicit LexedMethod(Parser *
P, Decl *MD) : Self(
P), D(MD) {}
1428 void ParseLexedMethodDefs()
override;
1435 struct LateParsedDefaultArgument {
1436 explicit LateParsedDefaultArgument(Decl *
P,
1437 std::unique_ptr<CachedTokens> Toks =
nullptr)
1438 : Param(
P), Toks(
std::move(Toks)) { }
1447 std::unique_ptr<CachedTokens> Toks;
1454 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1455 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1456 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1458 void ParseLexedMethodDeclarations()
override;
1470 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1480 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1481 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1484 void ParseLexedMemberInitializers()
override;
1502 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1507 struct ParsingClass {
1508 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1509 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1510 TagOrTemplate(TagOrTemplate) {}
1514 bool TopLevelClass : 1;
1517 bool IsInterface : 1;
1520 Decl *TagOrTemplate;
1525 LateParsedDeclarationsContainer LateParsedDeclarations;
1531 std::stack<ParsingClass *> ClassStack;
1533 ParsingClass &getCurrentClass() {
1534 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1535 return *ClassStack.top();
1539 class ParsingClassDefinition {
1545 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1548 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1553 assert(!Popped &&
"Nested class has already been popped");
1555 P.PopParsingClass(State);
1558 ~ParsingClassDefinition() {
1560 P.PopParsingClass(State);
1567 struct ParsedTemplateInfo {
1568 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1571 bool isSpecialization,
1572 bool lastParameterListWasEmpty =
false)
1573 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1574 TemplateParams(TemplateParams),
1575 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1577 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1578 SourceLocation TemplateLoc)
1579 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1580 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1581 LastParameterListWasEmpty(
false){ }
1590 ExplicitSpecialization,
1592 ExplicitInstantiation
1601 SourceLocation ExternLoc;
1605 SourceLocation TemplateLoc;
1608 bool LastParameterListWasEmpty;
1614 struct ReenterTemplateScopeRAII;
1615 struct ReenterClassScopeRAII;
1617 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1618 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1620 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1622 Sema::ParsingClassState
1623 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1624 void DeallocateParsedClasses(ParsingClass *
Class);
1625 void PopParsingClass(Sema::ParsingClassState);
1627 enum CachedInitKind {
1628 CIK_DefaultArgument,
1629 CIK_DefaultInitializer
1633 const ParsedAttributesView &AccessAttrs,
1634 ParsingDeclarator &D,
1635 const ParsedTemplateInfo &TemplateInfo,
1636 const VirtSpecifiers &VS,
1637 SourceLocation PureSpecLoc);
1638 StringLiteral *ParseCXXDeletedFunctionMessage();
1639 void SkipDeletedFunctionBody();
1640 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1641 void ParseLexedAttributes(ParsingClass &
Class);
1642 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1644 void ParseLexedAttribute(LateParsedAttribute &LA,
1646 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1647 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1648 void ParseLexedMethodDefs(ParsingClass &
Class);
1649 void ParseLexedMethodDef(LexedMethod &LM);
1650 void ParseLexedMemberInitializers(ParsingClass &
Class);
1651 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1652 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1653 void ParseLexedPragmas(ParsingClass &
Class);
1654 void ParseLexedPragma(LateParsedPragma &LP);
1655 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1656 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1661 bool ConsumeFinalToken =
true) {
1662 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1667 bool ConsumeFinalToken =
true);
1671 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1672 ParsedAttributes &DeclSpecAttrs,
1673 ParsingDeclSpec *DS =
nullptr);
1674 bool isDeclarationAfterDeclarator();
1675 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1677 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1679 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1680 ParsedAttributes &DeclSpecAttrs,
1681 ParsingDeclSpec &DS,
1684 void SkipFunctionBody();
1685 Decl *ParseFunctionDefinition(ParsingDeclarator &D,
1686 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1687 LateParsedAttrList *LateParsedAttrs =
nullptr);
1688 void ParseKNRParamDeclarations(Declarator &D);
1690 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1691 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1695 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1696 ParsedAttributes &DeclSpecAttrs);
1697 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1698 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1699 ParsedAttributes &prefixAttrs);
1700 class ObjCTypeParamListScope;
1701 ObjCTypeParamList *parseObjCTypeParamList();
1702 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1703 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1704 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1705 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1707 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1708 SourceLocation atLoc,
1710 SmallVectorImpl<Decl *> &AllIvarDecls,
1711 bool RBraceMissing);
1712 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1714 SourceLocation atLoc);
1715 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1716 SmallVectorImpl<SourceLocation> &PLocs,
1717 bool WarnOnDeclarations,
1718 bool ForObjCContainer,
1719 SourceLocation &LAngleLoc,
1720 SourceLocation &EndProtoLoc,
1721 bool consumeLastToken);
1726 void parseObjCTypeArgsOrProtocolQualifiers(
1728 SourceLocation &typeArgsLAngleLoc,
1729 SmallVectorImpl<ParsedType> &typeArgs,
1730 SourceLocation &typeArgsRAngleLoc,
1731 SourceLocation &protocolLAngleLoc,
1732 SmallVectorImpl<Decl *> &protocols,
1733 SmallVectorImpl<SourceLocation> &protocolLocs,
1734 SourceLocation &protocolRAngleLoc,
1735 bool consumeLastToken,
1736 bool warnOnIncompleteProtocols);
1740 void parseObjCTypeArgsAndProtocolQualifiers(
1742 SourceLocation &typeArgsLAngleLoc,
1743 SmallVectorImpl<ParsedType> &typeArgs,
1744 SourceLocation &typeArgsRAngleLoc,
1745 SourceLocation &protocolLAngleLoc,
1746 SmallVectorImpl<Decl *> &protocols,
1747 SmallVectorImpl<SourceLocation> &protocolLocs,
1748 SourceLocation &protocolRAngleLoc,
1749 bool consumeLastToken);
1753 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1757 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1759 bool consumeLastToken,
1760 SourceLocation &endLoc);
1764 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1765 ParsedAttributes &prefixAttrs);
1767 struct ObjCImplParsingDataRAII {
1771 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1772 LateParsedObjCMethodContainer LateParsedObjCMethods;
1774 ObjCImplParsingDataRAII(Parser &parser, Decl *D)
1775 :
P(parser), Dcl(D), HasCFunction(
false) {
1776 P.CurParsedObjCImpl =
this;
1779 ~ObjCImplParsingDataRAII();
1781 void finish(SourceRange AtEnd);
1782 bool isFinished()
const {
return Finished; }
1787 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1788 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1790 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1791 ParsedAttributes &Attrs);
1793 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1794 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1795 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1797 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1800 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1801 objc_nonnull, objc_nullable, objc_null_unspecified,
1804 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1806 bool isTokIdentifier_in()
const;
1809 ParsedAttributes *ParamAttrs);
1810 Decl *ParseObjCMethodPrototype(
1812 bool MethodDefinition =
true);
1815 bool MethodDefinition=
true);
1816 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1818 Decl *ParseObjCMethodDefinition();
1846 unsigned &NumLineToksConsumed,
1847 bool IsUnevaluated);
1863 enum CastParseKind {
1868 ExprResult ParseCastExpression(CastParseKind ParseKind,
1869 bool isAddressOfOperand,
1872 bool isVectorLiteral =
false,
1873 bool *NotPrimaryExpression =
nullptr);
1874 ExprResult ParseCastExpression(CastParseKind ParseKind,
1875 bool isAddressOfOperand =
false,
1877 bool isVectorLiteral =
false,
1878 bool *NotPrimaryExpression =
nullptr);
1881 bool isNotExpressionStart();
1885 bool isPostfixExpressionSuffixStart() {
1887 return (K == tok::l_square || K == tok::l_paren ||
1888 K == tok::period || K == tok::arrow ||
1889 K == tok::plusplus || K == tok::minusminus);
1892 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1893 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1894 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1895 const Token &OpToken);
1896 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1897 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1898 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1903 ExprResult ParseUnaryExprOrTypeTraitExpression();
1905 ExprResult ParseSYCLUniqueStableNameExpression();
1907 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1910 SourceRange &CastRange);
1913 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1914 llvm::function_ref<
void()> ExpressionStarts =
1915 llvm::function_ref<
void()>(),
1916 bool FailImmediatelyOnInvalidExpr =
false,
1917 bool EarlyTypoCorrection =
false);
1921 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1924 enum ParenParseOption {
1931 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1932 bool stopIfCastExpr,
1935 SourceLocation &RParenLoc);
1938 ParenParseOption &ExprType,
ParsedType &CastTy,
1941 SourceLocation LParenLoc,
1942 SourceLocation RParenLoc);
1944 ExprResult ParseGenericSelectionExpression();
1952 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1953 Token &Replacement);
1958 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1960 bool areTokensAdjacent(
const Token &A,
const Token &B);
1962 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1963 bool EnteringContext, IdentifierInfo &II,
1966 bool ParseOptionalCXXScopeSpecifier(
1967 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
1968 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
1969 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
1970 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false);
1976 enum class LambdaIntroducerTentativeParse {
1993 ParseLambdaIntroducer(LambdaIntroducer &Intro,
1994 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1995 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
2014 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
2029 SourceRange &SpecificationRange,
2030 SmallVectorImpl<ParsedType> &DynamicExceptions,
2031 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2037 SourceRange &SpecificationRange,
2038 SmallVectorImpl<ParsedType> &Exceptions,
2039 SmallVectorImpl<SourceRange> &Ranges);
2043 TypeResult ParseTrailingReturnType(SourceRange &Range,
2044 bool MayBeFollowedByDirectInit);
2052 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2057 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2059 bool ParseCXXTypeSpecifierSeq(
2064 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2066 void ParseDirectNewDeclarator(Declarator &D);
2067 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2068 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2069 SourceLocation Start);
2073 struct ForRangeInfo;
2074 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2078 ForRangeInfo *FRI =
nullptr,
2079 bool EnterForConditionScope =
false);
2081 ParsedAttributes &Attrs);
2092 void ParseTrailingRequiresClause(Declarator &D);
2102 if (Tok.isNot(tok::l_brace))
2104 return ParseBraceInitializer();
2106 bool MayBeDesignationStart();
2108 struct DesignatorCompletionInfo {
2109 SmallVectorImpl<Expr *> &InitExprs;
2110 QualType PreferredBaseType;
2112 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2121 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2122 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2123 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2124 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2125 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2126 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2127 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2128 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2129 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2130 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2131 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2132 bool isSimpleObjCMessageExpression();
2134 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2135 SourceLocation SuperLoc,
2137 Expr *ReceiverExpr);
2138 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2139 SourceLocation LBracloc, SourceLocation SuperLoc,
2140 ParsedType ReceiverType, Expr *ReceiverExpr);
2141 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2147 typedef SmallVector<Expr*, 12> ExprVector;
2150 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2151 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2153 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2154 SourceLocation *TrailingElseLoc =
nullptr);
2155 StmtResult ParseStatementOrDeclarationAfterAttributes(
2156 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2157 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2158 ParsedAttributes &DeclSpecAttrs);
2159 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2160 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2161 ParsedStmtContext StmtCtx);
2162 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2163 bool MissingCase =
false,
2165 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2166 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2167 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2168 unsigned ScopeFlags);
2169 void ParseCompoundStatementLeadingPragmas();
2170 void DiagnoseLabelAtEndOfCompoundStatement();
2172 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2173 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2174 Sema::ConditionResult &CondResult,
2176 SourceLocation &LParenLoc,
2177 SourceLocation &RParenLoc);
2178 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2179 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2180 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2182 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2188 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2190 SourceLocation *TrailingElseLoc,
2191 ParsedAttributes &Attrs);
2195 enum IfExistsBehavior {
2207 struct IfExistsCondition {
2209 SourceLocation KeywordLoc;
2222 IfExistsBehavior Behavior;
2225 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2226 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2227 void ParseMicrosoftIfExistsExternalDeclaration();
2228 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2229 ParsedAttributes &AccessAttrs,
2231 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2233 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2234 SmallVectorImpl<Expr *> &Constraints,
2235 SmallVectorImpl<Expr *> &Exprs);
2241 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2242 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2248 StmtResult ParseSEHExceptBlock(SourceLocation Loc);
2249 StmtResult ParseSEHFinallyBlock(SourceLocation Loc);
2255 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2256 ParsedStmtContext StmtCtx);
2257 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2258 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2259 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2260 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2269 enum class DeclSpecContext {
2274 DSC_alias_declaration,
2279 DSC_template_type_arg,
2280 DSC_objc_method_result,
2289 static bool isTypeSpecifier(DeclSpecContext DSC) {
2291 case DeclSpecContext::DSC_normal:
2292 case DeclSpecContext::DSC_template_param:
2293 case DeclSpecContext::DSC_template_arg:
2294 case DeclSpecContext::DSC_class:
2295 case DeclSpecContext::DSC_top_level:
2296 case DeclSpecContext::DSC_objc_method_result:
2297 case DeclSpecContext::DSC_condition:
2300 case DeclSpecContext::DSC_template_type_arg:
2301 case DeclSpecContext::DSC_type_specifier:
2302 case DeclSpecContext::DSC_conv_operator:
2303 case DeclSpecContext::DSC_trailing:
2304 case DeclSpecContext::DSC_alias_declaration:
2305 case DeclSpecContext::DSC_association:
2306 case DeclSpecContext::DSC_new:
2309 llvm_unreachable(
"Missing DeclSpecContext case");
2313 enum class AllowDefiningTypeSpec {
2330 static AllowDefiningTypeSpec
2331 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2333 case DeclSpecContext::DSC_normal:
2334 case DeclSpecContext::DSC_class:
2335 case DeclSpecContext::DSC_top_level:
2336 case DeclSpecContext::DSC_alias_declaration:
2337 case DeclSpecContext::DSC_objc_method_result:
2338 return AllowDefiningTypeSpec::Yes;
2340 case DeclSpecContext::DSC_condition:
2341 case DeclSpecContext::DSC_template_param:
2342 return AllowDefiningTypeSpec::YesButInvalid;
2344 case DeclSpecContext::DSC_template_type_arg:
2345 case DeclSpecContext::DSC_type_specifier:
2346 return AllowDefiningTypeSpec::NoButErrorRecovery;
2348 case DeclSpecContext::DSC_association:
2349 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2350 : AllowDefiningTypeSpec::Yes;
2352 case DeclSpecContext::DSC_trailing:
2353 case DeclSpecContext::DSC_conv_operator:
2354 case DeclSpecContext::DSC_template_arg:
2355 case DeclSpecContext::DSC_new:
2356 return AllowDefiningTypeSpec::No;
2358 llvm_unreachable(
"Missing DeclSpecContext case");
2362 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2364 case DeclSpecContext::DSC_normal:
2365 case DeclSpecContext::DSC_class:
2366 case DeclSpecContext::DSC_top_level:
2369 case DeclSpecContext::DSC_alias_declaration:
2370 case DeclSpecContext::DSC_objc_method_result:
2371 case DeclSpecContext::DSC_condition:
2372 case DeclSpecContext::DSC_template_param:
2373 case DeclSpecContext::DSC_template_type_arg:
2374 case DeclSpecContext::DSC_type_specifier:
2375 case DeclSpecContext::DSC_trailing:
2376 case DeclSpecContext::DSC_association:
2377 case DeclSpecContext::DSC_conv_operator:
2378 case DeclSpecContext::DSC_template_arg:
2379 case DeclSpecContext::DSC_new:
2383 llvm_unreachable(
"Missing DeclSpecContext case");
2388 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2390 case DeclSpecContext::DSC_normal:
2391 case DeclSpecContext::DSC_template_param:
2392 case DeclSpecContext::DSC_template_arg:
2393 case DeclSpecContext::DSC_class:
2394 case DeclSpecContext::DSC_top_level:
2395 case DeclSpecContext::DSC_condition:
2396 case DeclSpecContext::DSC_type_specifier:
2397 case DeclSpecContext::DSC_association:
2398 case DeclSpecContext::DSC_conv_operator:
2399 case DeclSpecContext::DSC_new:
2402 case DeclSpecContext::DSC_objc_method_result:
2403 case DeclSpecContext::DSC_template_type_arg:
2404 case DeclSpecContext::DSC_trailing:
2405 case DeclSpecContext::DSC_alias_declaration:
2408 llvm_unreachable(
"Missing DeclSpecContext case");
2413 getImplicitTypenameContext(DeclSpecContext DSC) {
2415 case DeclSpecContext::DSC_class:
2416 case DeclSpecContext::DSC_top_level:
2417 case DeclSpecContext::DSC_type_specifier:
2418 case DeclSpecContext::DSC_template_type_arg:
2419 case DeclSpecContext::DSC_trailing:
2420 case DeclSpecContext::DSC_alias_declaration:
2421 case DeclSpecContext::DSC_template_param:
2422 case DeclSpecContext::DSC_new:
2425 case DeclSpecContext::DSC_normal:
2426 case DeclSpecContext::DSC_objc_method_result:
2427 case DeclSpecContext::DSC_condition:
2428 case DeclSpecContext::DSC_template_arg:
2429 case DeclSpecContext::DSC_conv_operator:
2430 case DeclSpecContext::DSC_association:
2433 llvm_unreachable(
"Missing DeclSpecContext case");
2438 struct ForRangeInit {
2439 SourceLocation ColonLoc;
2441 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2442 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2444 struct ForRangeInfo : ForRangeInit {
2449 SourceLocation &DeclEnd,
2450 ParsedAttributes &DeclAttrs,
2451 ParsedAttributes &DeclSpecAttrs,
2452 SourceLocation *DeclSpecStart =
nullptr);
2455 ParsedAttributes &DeclAttrs,
2456 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2457 ForRangeInit *FRI =
nullptr,
2458 SourceLocation *DeclSpecStart =
nullptr);
2461 ParsedAttributes &Attrs,
2462 ParsedTemplateInfo &TemplateInfo,
2463 SourceLocation *DeclEnd =
nullptr,
2464 ForRangeInit *FRI =
nullptr);
2465 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2466 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2467 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2468 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2470 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2471 ForRangeInit *FRI =
nullptr);
2472 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2473 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2479 bool trySkippingFunctionBody();
2481 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2482 const ParsedTemplateInfo &TemplateInfo,
2484 ParsedAttributes &Attrs);
2487 void ParseDeclarationSpecifiers(
2489 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2491 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2492 LateParsedAttrList *LateAttrs =
nullptr) {
2493 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2494 getImplicitTypenameContext(DSC));
2496 void ParseDeclarationSpecifiers(
2497 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS,
2498 DeclSpecContext DSC, LateParsedAttrList *LateAttrs,
2501 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2502 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2503 SourceLocation StartLoc,
2504 SourceLocation EndLoc);
2506 bool DiagnoseMissingSemiAfterTagDefinition(
2508 LateParsedAttrList *LateAttrs =
nullptr);
2510 void ParseSpecifierQualifierList(
2512 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2513 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2516 void ParseSpecifierQualifierList(
2519 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2521 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2524 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2525 const ParsedTemplateInfo &TemplateInfo,
2527 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2528 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2529 RecordDecl *TagDecl);
2531 void ParseStructDeclaration(
2532 ParsingDeclSpec &DS,
2533 llvm::function_ref<
void(ParsingFieldDeclarator &)> FieldsCallback);
2538 bool DisambiguatingWithExpression =
false);
2539 bool isTypeSpecifierQualifier();
2544 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2549 bool isKnownToBeDeclarationSpecifier() {
2562 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2564 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2572 bool isForInitDeclaration() {
2576 return Tok.is(tok::kw_using) ||
2577 isCXXSimpleDeclaration(
true);
2582 bool isForRangeIdentifier();
2586 bool isStartOfObjCClassMessageMissingOpenBracket();
2591 bool isConstructorDeclarator(
2594 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2598 enum TentativeCXXTypeIdContext {
2601 TypeIdAsTemplateArgument,
2602 TypeIdInTrailingReturnType,
2603 TypeIdAsGenericSelectionArgument,
2609 bool isTypeIdInParens(
bool &isAmbiguous) {
2611 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2612 isAmbiguous =
false;
2613 return isTypeSpecifierQualifier();
2615 bool isTypeIdInParens() {
2617 return isTypeIdInParens(isAmbiguous);
2627 bool isTypeIdForGenericSelection() {
2630 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2632 return isTypeSpecifierQualifier();
2638 bool isTypeIdUnambiguously() {
2641 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2643 return isTypeSpecifierQualifier();
2649 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2656 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2665 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2669 struct ConditionDeclarationOrInitStatementState;
2670 enum class ConditionOrInitStatement {
2680 ConditionOrInitStatement
2681 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2682 bool CanBeForRangeDecl);
2684 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2685 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2687 return isCXXTypeId(Context, isAmbiguous);
2692 enum class TPResult {
2693 True, False, Ambiguous,
Error
2703 bool isEnumBase(
bool AllowSemi);
2714 TPResult BracedCastResult = TPResult::False,
2715 bool *InvalidAsDeclSpec =
nullptr);
2720 bool isCXXDeclarationSpecifierAType();
2725 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2730 TPResult isExplicitBool();
2735 bool isTentativelyDeclared(IdentifierInfo *II);
2744 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2745 TPResult TryParseTypeofSpecifier();
2746 TPResult TryParseProtocolQualifiers();
2747 TPResult TryParsePtrOperatorSeq();
2748 TPResult TryParseOperatorId();
2749 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2750 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2751 bool mayHaveDirectInit =
false,
2752 bool mayHaveTrailingReturnType =
false);
2753 TPResult TryParseParameterDeclarationClause(
2754 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2757 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2758 bool NameAfterArrowIsNonType();
2759 TPResult TryParseBracketDeclarator();
2760 TPResult TryConsumeDeclarationSpecifier();
2764 bool TrySkipAttributes();
2768 void DiagnoseBitIntUse(
const Token &Tok);
2775 ParsedAttributes *Attrs =
nullptr);
2778 void ParseBlockId(SourceLocation CaretLoc);
2785 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2786 bool OuterMightBeMessageSend =
false) {
2787 return (Tok.isRegularKeywordAttribute() ||
2788 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2793 bool CheckProhibitedCXX11Attribute() {
2794 assert(Tok.is(tok::l_square));
2797 return DiagnoseProhibitedCXX11Attribute();
2800 bool DiagnoseProhibitedCXX11Attribute();
2801 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2802 SourceLocation CorrectLocation) {
2803 if (!Tok.isRegularKeywordAttribute() &&
2804 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2805 Tok.isNot(tok::kw_alignas))
2807 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2809 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2810 SourceLocation CorrectLocation);
2812 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2816 void ProhibitAttributes(ParsedAttributes &Attrs,
2817 SourceLocation FixItLoc = SourceLocation()) {
2818 if (Attrs.Range.isInvalid())
2820 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2824 void ProhibitAttributes(ParsedAttributesView &Attrs,
2825 SourceLocation FixItLoc = SourceLocation()) {
2826 if (Attrs.Range.isInvalid())
2828 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2829 Attrs.clearListOnly();
2831 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2832 SourceLocation FixItLoc);
2840 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2841 unsigned KeywordDiagId,
2842 bool DiagnoseEmptyAttrs =
false,
2843 bool WarnOnUnknownAttrs =
false);
2848 SourceLocation SkipCXX11Attributes();
2852 void DiagnoseAndSkipCXX11Attributes();
2856 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2858 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2862 SmallVectorImpl<Expr *> &Exprs,
2863 ParsedAttributeArgumentsProperties ArgsProperties);
2870 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2871 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2872 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2873 ParsedAttr::Form Form);
2875 enum ParseAttrKindMask {
2877 PAKM_Declspec = 1 << 1,
2878 PAKM_CXX11 = 1 << 2,
2895 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2896 LateParsedAttrList *LateAttrs =
nullptr);
2899 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2900 LateParsedAttrList *LateAttrs =
nullptr) {
2901 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2902 isAllowedCXX11AttributeSpecifier()) {
2903 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2909 void MaybeParseGNUAttributes(Declarator &D,
2910 LateParsedAttrList *LateAttrs =
nullptr) {
2911 if (Tok.is(tok::kw___attribute)) {
2912 ParsedAttributes Attrs(AttrFactory);
2913 ParseGNUAttributes(Attrs, LateAttrs, &D);
2914 D.takeAttributes(Attrs);
2918 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2919 LateParsedAttrList *LateAttrs =
nullptr) {
2920 if (Tok.is(tok::kw___attribute)) {
2921 ParseGNUAttributes(Attrs, LateAttrs);
2927 void ParseGNUAttributes(ParsedAttributes &Attrs,
2928 LateParsedAttrList *LateAttrs =
nullptr,
2929 Declarator *D =
nullptr);
2930 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2931 SourceLocation AttrNameLoc,
2932 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2933 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2934 ParsedAttr::Form Form, Declarator *D);
2935 IdentifierLoc *ParseIdentifierLoc();
2938 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2939 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2940 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2941 ParsedAttr::Form Form);
2943 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2946 if (!OpenMPTokens.empty()) {
2948 PP.EnterTokenStream(OpenMPTokens,
true,
2953 void MaybeParseCXX11Attributes(Declarator &D) {
2954 if (isAllowedCXX11AttributeSpecifier()) {
2955 ParsedAttributes Attrs(AttrFactory);
2956 ParseCXX11Attributes(Attrs);
2957 D.takeAttributes(Attrs);
2961 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2962 bool OuterMightBeMessageSend =
false) {
2963 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2964 ParseCXX11Attributes(Attrs);
2970 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
2973 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2975 SourceLocation *EndLoc =
nullptr);
2976 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2977 SourceLocation *EndLoc =
nullptr) {
2979 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2980 ReplayOpenMPAttributeTokens(OpenMPTokens);
2982 void ParseCXX11Attributes(ParsedAttributes &attrs);
2985 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
2986 SourceLocation AttrNameLoc,
2987 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2988 IdentifierInfo *ScopeName,
2989 SourceLocation ScopeLoc,
2993 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
2994 IdentifierInfo *AttrName,
2995 SourceLocation AttrNameLoc,
2996 SourceLocation *EndLoc);
2998 IdentifierInfo *TryParseCXX11AttributeIdentifier(
2999 SourceLocation &Loc,
3001 const IdentifierInfo *EnclosingScope =
nullptr);
3003 void MaybeParseHLSLAnnotations(Declarator &D,
3004 SourceLocation *EndLoc =
nullptr) {
3005 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3006 if (Tok.is(tok::colon)) {
3007 ParsedAttributes Attrs(AttrFactory);
3008 ParseHLSLAnnotations(Attrs, EndLoc);
3009 D.takeAttributes(Attrs);
3013 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
3014 SourceLocation *EndLoc =
nullptr) {
3015 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3017 ParseHLSLAnnotations(Attrs, EndLoc);
3020 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
3021 SourceLocation *EndLoc =
nullptr);
3022 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
3024 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3026 Tok.is(tok::l_square)) {
3027 ParsedAttributes AttrsWithRange(AttrFactory);
3028 ParseMicrosoftAttributes(AttrsWithRange);
3029 Attrs.takeAllFrom(AttrsWithRange);
3032 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3033 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3034 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3035 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3036 ParseMicrosoftDeclSpecs(Attrs);
3041 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3042 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3043 SourceLocation AttrNameLoc,
3044 ParsedAttributes &Attrs);
3045 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3046 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3047 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3048 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3049 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3050 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3051 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3052 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3053 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3054 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3055 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3056 bool isHLSLQualifier(
const Token &Tok)
const;
3057 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3059 VersionTuple ParseVersionTuple(SourceRange &Range);
3060 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3061 SourceLocation AvailabilityLoc,
3062 ParsedAttributes &attrs,
3063 SourceLocation *endLoc,
3064 IdentifierInfo *ScopeName,
3065 SourceLocation ScopeLoc,
3066 ParsedAttr::Form Form);
3068 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3069 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3071 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3073 ParsedAttributes &Attrs,
3074 SourceLocation *EndLoc,
3075 IdentifierInfo *ScopeName,
3076 SourceLocation ScopeLoc,
3077 ParsedAttr::Form Form);
3079 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3080 SourceLocation ObjCBridgeRelatedLoc,
3081 ParsedAttributes &Attrs,
3082 SourceLocation *EndLoc,
3083 IdentifierInfo *ScopeName,
3084 SourceLocation ScopeLoc,
3085 ParsedAttr::Form Form);
3087 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3088 SourceLocation AttrNameLoc,
3089 ParsedAttributes &Attrs,
3090 SourceLocation *EndLoc,
3091 IdentifierInfo *ScopeName,
3092 SourceLocation ScopeLoc,
3093 ParsedAttr::Form Form);
3095 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3096 SourceLocation AttrNameLoc,
3097 ParsedAttributes &Attrs,
3098 SourceLocation *EndLoc,
3099 IdentifierInfo *ScopeName,
3100 SourceLocation ScopeLoc,
3101 ParsedAttr::Form Form);
3103 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3104 SourceLocation AttrNameLoc,
3105 ParsedAttributes &Attrs,
3106 IdentifierInfo *ScopeName,
3107 SourceLocation ScopeLoc,
3108 ParsedAttr::Form Form);
3110 void ParseBoundsAttribute(IdentifierInfo &AttrName,
3111 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
3112 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3113 ParsedAttr::Form Form);
3115 void ParseTypeofSpecifier(DeclSpec &DS);
3116 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3117 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3118 SourceLocation StartLoc,
3119 SourceLocation EndLoc);
3120 void ParseAtomicSpecifier(DeclSpec &DS);
3122 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3123 SourceLocation &EllipsisLoc,
bool &IsType,
3125 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3126 SourceLocation *endLoc =
nullptr);
3131 return isCXX11VirtSpecifier(Tok);
3133 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3134 SourceLocation FriendLoc);
3136 bool isCXX11FinalKeyword()
const;
3137 bool isClassCompatibleKeyword()
const;
3142 class DeclaratorScopeObj {
3148 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3149 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3151 void EnterDeclaratorScope() {
3152 assert(!EnteredScope &&
"Already entered the scope!");
3153 assert(SS.isSet() &&
"C++ scope was not set!");
3155 CreatedScope =
true;
3158 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3159 EnteredScope =
true;
3162 ~DeclaratorScopeObj() {
3164 assert(SS.isSet() &&
"C++ scope was cleared ?");
3165 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3173 void ParseDeclarator(Declarator &D);
3175 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3176 void ParseDeclaratorInternal(Declarator &D,
3177 DirectDeclParseFunction DirectDeclParser);
3179 enum AttrRequirements {
3180 AR_NoAttributesParsed = 0,
3181 AR_GNUAttributesParsedAndRejected = 1 << 0,
3182 AR_GNUAttributesParsed = 1 << 1,
3183 AR_CXX11AttributesParsed = 1 << 2,
3184 AR_DeclspecAttributesParsed = 1 << 3,
3185 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3186 AR_CXX11AttributesParsed |
3187 AR_DeclspecAttributesParsed,
3188 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3189 AR_DeclspecAttributesParsed
3192 void ParseTypeQualifierListOpt(
3193 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3194 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3195 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3197 void ParseDirectDeclarator(Declarator &D);
3198 void ParseDecompositionDeclarator(Declarator &D);
3199 void ParseParenDeclarator(Declarator &D);
3200 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
3202 bool IsAmbiguous,
bool RequiresArg =
false);
3203 void InitCXXThisScopeForDeclaratorIfRelevant(
3204 const Declarator &D,
const DeclSpec &DS,
3205 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3206 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3207 SourceLocation &RefQualifierLoc);
3208 bool isFunctionDeclaratorIdentifierList();
3209 void ParseFunctionDeclaratorIdentifierList(
3211 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3212 void ParseParameterDeclarationClause(
3213 Declarator &D, ParsedAttributes &attrs,
3214 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3215 SourceLocation &EllipsisLoc) {
3216 return ParseParameterDeclarationClause(
3217 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3218 D.getCXXScopeSpec().isSet() &&
3219 D.isFunctionDeclaratorAFunctionDeclaration());
3221 void ParseParameterDeclarationClause(
3223 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3224 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3226 void ParseBracketDeclarator(Declarator &D);
3227 void ParseMisplacedBracketDeclarator(Declarator &D);
3228 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3235 enum CXX11AttributeKind {
3237 CAK_NotAttributeSpecifier,
3239 CAK_AttributeSpecifier,
3242 CAK_InvalidAttributeSpecifier
3245 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3246 bool OuterMightBeMessageSend =
false);
3248 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3251 SourceLocation &DeclEnd,
3252 SourceLocation InlineLoc = SourceLocation());
3254 struct InnerNamespaceInfo {
3255 SourceLocation NamespaceLoc;
3256 SourceLocation InlineLoc;
3257 SourceLocation IdentLoc;
3258 IdentifierInfo *Ident;
3262 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3263 unsigned int index, SourceLocation &InlineLoc,
3264 ParsedAttributes &attrs,
3267 Decl *ParseExportDeclaration();
3270 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3272 SourceLocation UsingLoc,
3273 SourceLocation &DeclEnd,
3274 ParsedAttributes &attrs);
3276 struct UsingDeclarator {
3277 SourceLocation TypenameLoc;
3280 SourceLocation EllipsisLoc;
3283 TypenameLoc = EllipsisLoc = SourceLocation();
3291 const ParsedTemplateInfo &TemplateInfo,
3292 SourceLocation UsingLoc,
3293 SourceLocation &DeclEnd,
3294 ParsedAttributes &Attrs,
3296 Decl *ParseAliasDeclarationAfterDeclarator(
3297 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3299 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3301 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3302 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3303 SourceLocation AliasLoc, IdentifierInfo *Alias,
3304 SourceLocation &DeclEnd);
3308 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3309 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3310 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
3312 DeclSpecContext DSC, ParsedAttributes &Attributes);
3313 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3314 SourceLocation AttrFixitLoc,
3317 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3318 SourceLocation AttrFixitLoc,
3319 ParsedAttributes &Attrs,
unsigned TagType,
3321 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3322 SourceLocation &EqualLoc);
3324 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3327 LateParsedAttrList &LateAttrs);
3328 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3329 VirtSpecifiers &VS);
3332 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
3333 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3336 ParsedAttributes &AccessAttrs,
3338 void ParseConstructorInitializer(Decl *ConstructorDecl);
3340 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3345 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3346 SourceLocation &EndLocation);
3347 void ParseBaseClause(Decl *ClassDecl);
3348 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3351 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3353 bool ObjectHadErrors,
3354 SourceLocation TemplateKWLoc,
3355 IdentifierInfo *Name,
3356 SourceLocation NameLoc,
3357 bool EnteringContext,
3359 bool AssumeTemplateId);
3360 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3369 SourceLocation Loc);
3373 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3374 llvm::omp::TraitSet
Set,
3375 llvm::omp::TraitSelector Selector,
3376 llvm::StringMap<SourceLocation> &Seen);
3379 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3380 llvm::omp::TraitSet
Set,
3381 llvm::StringMap<SourceLocation> &Seen);
3384 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3385 llvm::StringMap<SourceLocation> &Seen);
3388 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3389 llvm::omp::TraitSet
Set,
3390 llvm::StringMap<SourceLocation> &Seen);
3393 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3394 llvm::omp::TraitSet
Set,
3395 llvm::StringMap<SourceLocation> &SeenSelectors);
3398 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3399 llvm::StringMap<SourceLocation> &SeenSets);
3402 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
3405 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3409 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
3410 OMPTraitInfo *ParentTI);
3414 SourceLocation Loc);
3418 SourceLocation Loc);
3421 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
3429 SmallVectorImpl<clang::OMPClause *> &Clauses,
3430 SourceLocation Loc);
3433 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
3438 SourceLocation Loc);
3451 SourceLocation MatchingLoc,
3452 SourceLocation FoundLoc,
3453 bool SkipUntilOpenMPEnd);
3459 Decl *TagDecl =
nullptr);
3464 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3469 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
3470 DeclarationName &Name,
3475 bool tryParseOpenMPArrayShapingCastPart();
3484 bool ParseOpenMPSimpleVarList(
3486 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3488 bool AllowScopeSpecifier);
3494 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3495 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3523 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
3538 OMPClause *ParseOpenMPSizesClause();
3546 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3567 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3575 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3582 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3589 bool IsAddressOfOperand =
false);
3593 SemaOpenMP::OpenMPVarListDataTy &
Data,
3594 const LangOptions &LangOpts);
3597 SmallVectorImpl<Expr *> &Vars,
3598 SemaOpenMP::OpenMPVarListDataTy &
Data);
3600 bool ObjectHadErrors,
bool EnteringContext,
3601 bool AllowDestructorName,
bool AllowConstructorName,
3602 bool AllowDeductionGuide,
3603 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3626 struct OpenACCDirectiveParseInfo {
3628 SourceLocation StartLoc;
3629 SourceLocation EndLoc;
3630 SmallVector<OpenACCClause *> Clauses;
3637 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
3643 using OpenACCClauseParseResult =
3644 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
3646 OpenACCClauseParseResult OpenACCCanContinue();
3647 OpenACCClauseParseResult OpenACCCannotContinue();
3648 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
3652 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3656 void ParseOpenACCCacheVarList();
3658 bool ParseOpenACCVar();
3664 OpenACCClauseParseResult
3665 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
3667 SourceLocation ClauseLoc);
3670 OpenACCClauseParseResult
3671 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
3674 SmallVector<OpenACCClause *>
3676 bool ParseOpenACCWaitArgument(SourceLocation Loc,
bool IsDirective);
3684 using OpenACCIntExprParseResult =
3685 std::pair<ExprResult, OpenACCParseCanContinue>;
3690 SourceLocation Loc);
3697 bool ParseOpenACCDeviceTypeList();
3702 bool ParseOpenACCSizeExpr();
3704 bool ParseOpenACCSizeExprList();
3706 bool ParseOpenACCGangArgList(SourceLocation GangLoc);
3708 bool ParseOpenACCGangArg(SourceLocation GangLoc);
3719 SourceLocation &DeclEnd,
3720 ParsedAttributes &AccessAttrs);
3726 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3728 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3729 SmallVectorImpl<NamedDecl *> &TemplateParams,
3730 SourceLocation &LAngleLoc,
3731 SourceLocation &RAngleLoc);
3732 bool ParseTemplateParameterList(
unsigned Depth,
3733 SmallVectorImpl<NamedDecl*> &TemplateParams);
3734 TPResult isStartOfTemplateTypeParameter();
3735 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3736 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3737 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3738 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3739 bool isTypeConstraintAnnotation();
3740 bool TryAnnotateTypeConstraint();
3741 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3742 SourceLocation CorrectLoc,
3743 bool AlreadyHasEllipsis,
3744 bool IdentifierHasName);
3745 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3748 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3750 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3751 SourceLocation &RAngleLoc,
3752 bool ConsumeLastToken,
3753 bool ObjCGenericList);
3754 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3755 SourceLocation &LAngleLoc,
3756 TemplateArgList &TemplateArgs,
3757 SourceLocation &RAngleLoc,
3762 SourceLocation TemplateKWLoc,
3763 UnqualifiedId &TemplateName,
3764 bool AllowTypeAnnotation =
true,
3765 bool TypeConstraint =
false);
3767 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3769 bool IsClassName =
false);
3770 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3771 TemplateTy Template, SourceLocation OpenLoc);
3772 ParsedTemplateArgument ParseTemplateTemplateArgument();
3773 ParsedTemplateArgument ParseTemplateArgument();
3775 SourceLocation ExternLoc,
3776 SourceLocation TemplateLoc,
3777 SourceLocation &DeclEnd,
3778 ParsedAttributes &AccessAttrs,
3782 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3783 SourceLocation &DeclEnd);
3794 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3795 SourceLocation IncludeLoc);
3800 Decl *ParseModuleImport(SourceLocation AtLoc,
3802 bool parseMisplacedModuleImport();
3803 bool tryParseMisplacedModuleImport() {
3805 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3806 Kind == tok::annot_module_include)
3807 return parseMisplacedModuleImport();
3811 bool ParseModuleName(
3812 SourceLocation UseLoc,
3813 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
3827 void CodeCompleteDirective(
bool InConditional)
override;
3828 void CodeCompleteInConditionalExclusion()
override;
3829 void CodeCompleteMacroName(
bool IsDefinition)
override;
3830 void CodeCompletePreprocessorExpression()
override;
3831 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3832 unsigned ArgumentIndex)
override;
3833 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3834 void CodeCompleteNaturalLanguage()
override;
3836 class GNUAsmQualifiers {
3837 unsigned Qualifiers = AQ_unspecified;
3846 static const char *getQualifierName(AQ Qualifier);
3847 bool setAsmQualifier(AQ Qualifier);
3848 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3849 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3850 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3852 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3853 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3854 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3855 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);
Defines some OpenACC-specific enums and functions.
Defines and computes precedence levels for binary/ternary operators.
Defines the clang::Preprocessor interface.
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.
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.
ObjCContainerDecl * getObjCDeclContext() const
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