13#ifndef LLVM_CLANG_PARSE_PARSER_H
14#define LLVM_CLANG_PARSE_PARSER_H
21#include "llvm/ADT/SmallVector.h"
22#include "llvm/Frontend/OpenMP/OMPContext.h"
23#include "llvm/Support/SaveAndRestore.h"
30 class BalancedDelimiterTracker;
31 class CorrectionCandidateCallback;
33 class DiagnosticBuilder;
36 class ParsingDeclRAIIObject;
37 class ParsingDeclSpec;
38 class ParsingDeclarator;
39 class ParsingFieldDeclarator;
40 class ColonProtectionRAIIObject;
41 class InMessageExpressionRAIIObject;
42 class PoisonSEHIdentifiersRAIIObject;
44 class ObjCTypeParamList;
45 struct OMPTraitProperty;
46 struct OMPTraitSelector;
81 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
82 unsigned short MisplacedModuleBeginCount = 0;
91 enum { ScopeCacheSize = 16 };
92 unsigned NumCachedScopes;
93 Scope *ScopeCache[ScopeCacheSize];
99 *Ident___exception_code,
100 *Ident_GetExceptionCode;
103 *Ident___exception_info,
104 *Ident_GetExceptionInfo;
107 *Ident___abnormal_termination,
108 *Ident_AbnormalTermination;
154 *Ident_generated_declaration, *Ident_USR;
167 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
169 std::unique_ptr<PragmaHandler> AlignHandler;
170 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
171 std::unique_ptr<PragmaHandler> OptionsHandler;
172 std::unique_ptr<PragmaHandler> PackHandler;
173 std::unique_ptr<PragmaHandler> MSStructHandler;
174 std::unique_ptr<PragmaHandler> UnusedHandler;
175 std::unique_ptr<PragmaHandler> WeakHandler;
176 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
177 std::unique_ptr<PragmaHandler> FPContractHandler;
178 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
179 std::unique_ptr<PragmaHandler> OpenMPHandler;
180 std::unique_ptr<PragmaHandler> OpenACCHandler;
181 std::unique_ptr<PragmaHandler> PCSectionHandler;
182 std::unique_ptr<PragmaHandler> MSCommentHandler;
183 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
184 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
185 std::unique_ptr<PragmaHandler> FloatControlHandler;
186 std::unique_ptr<PragmaHandler> MSPointersToMembers;
187 std::unique_ptr<PragmaHandler> MSVtorDisp;
188 std::unique_ptr<PragmaHandler> MSInitSeg;
189 std::unique_ptr<PragmaHandler> MSDataSeg;
190 std::unique_ptr<PragmaHandler> MSBSSSeg;
191 std::unique_ptr<PragmaHandler> MSConstSeg;
192 std::unique_ptr<PragmaHandler> MSCodeSeg;
193 std::unique_ptr<PragmaHandler> MSSection;
194 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
195 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
196 std::unique_ptr<PragmaHandler> MSIntrinsic;
197 std::unique_ptr<PragmaHandler> MSFunction;
198 std::unique_ptr<PragmaHandler> MSOptimize;
199 std::unique_ptr<PragmaHandler> MSFenvAccess;
200 std::unique_ptr<PragmaHandler> MSAllocText;
201 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
202 std::unique_ptr<PragmaHandler> OptimizeHandler;
203 std::unique_ptr<PragmaHandler> LoopHintHandler;
204 std::unique_ptr<PragmaHandler> UnrollHintHandler;
205 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
206 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
207 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
208 std::unique_ptr<PragmaHandler> FPHandler;
209 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
210 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
211 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
212 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
213 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
214 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
215 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
216 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
218 std::unique_ptr<CommentHandler> CommentSemaHandler;
224 bool GreaterThanIsOperator;
233 bool OpenMPDirectiveParsing =
false;
236 bool OpenACCDirectiveParsing =
false;
240 bool AllowOpenACCArraySections =
false;
244 class OpenACCArraySectionRAII {
248 OpenACCArraySectionRAII(
Parser &P) :
P(
P) {
249 assert(!
P.AllowOpenACCArraySections);
250 P.AllowOpenACCArraySections =
true;
252 ~OpenACCArraySectionRAII() {
253 assert(
P.AllowOpenACCArraySections);
254 P.AllowOpenACCArraySections =
false;
263 bool InMessageExpression;
268 bool CalledSignatureHelp =
false;
273 unsigned TemplateParameterDepth;
279 class TemplateParameterDepthRAII {
281 unsigned AddedLevels;
283 explicit TemplateParameterDepthRAII(
unsigned &Depth)
284 : Depth(Depth), AddedLevels(0) {}
286 ~TemplateParameterDepthRAII() {
287 Depth -= AddedLevels;
294 void addDepth(
unsigned D) {
298 void setAddedDepth(
unsigned D) {
299 Depth = Depth - AddedLevels + D;
303 unsigned getDepth()
const {
return Depth; }
304 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
308 AttributeFactory AttrFactory;
312 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
314 void MaybeDestroyTemplateIds() {
315 if (!TemplateIds.empty() &&
317 DestroyTemplateIds();
319 void DestroyTemplateIds();
323 struct DestroyTemplateIdAnnotationsRAIIObj {
326 DestroyTemplateIdAnnotationsRAIIObj(Parser &Self) :
Self(
Self) {}
327 ~DestroyTemplateIdAnnotationsRAIIObj() {
Self.MaybeDestroyTemplateIds(); }
331 SmallVector<IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
343 struct AngleBracketTracker {
353 SpaceBeforeLess = 0x0,
355 NoSpaceBeforeLess = 0x1,
386 if (!Locs.empty() && Locs.back().isActive(
P)) {
387 if (Locs.back().Priority <= Prio) {
389 Locs.back().LessLoc = LessLoc;
390 Locs.back().Priority = Prio;
393 Locs.push_back({TemplateName, LessLoc, Prio,
394 P.ParenCount,
P.BracketCount,
P.BraceCount});
401 void clear(Parser &
P) {
402 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
408 Loc *getCurrent(Parser &
P) {
409 if (!Locs.empty() && Locs.back().isActive(
P))
415 AngleBracketTracker AngleBrackets;
417 IdentifierInfo *getSEHExceptKeyword();
424 bool ParsingInObjCContainer;
430 bool SkipFunctionBodies;
435 SourceLocation ExprStatementTokLoc;
438 enum class ParsedStmtContext {
440 AllowStandaloneOpenMPDirectives = 0x1,
447 Compound = AllowStandaloneOpenMPDirectives,
458 Parser(Preprocessor &PP, Sema &Actions,
bool SkipFunctionBodies);
515 assert(!isTokenSpecial() &&
516 "Should consume special tokens with Consume*Token");
519 return PrevTokLocation;
525 assert(!isTokenSpecial() &&
526 "Should consume special tokens with Consume*Token");
535 Loc = PrevTokLocation;
544 return ConsumeParen();
545 if (isTokenBracket())
546 return ConsumeBracket();
548 return ConsumeBrace();
549 if (isTokenStringLiteral())
550 return ConsumeStringToken();
551 if (Tok.
is(tok::code_completion))
552 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
553 : handleUnexpectedCodeCompletionToken();
555 return ConsumeAnnotationToken();
576 bool isTokenParen()
const {
577 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
580 bool isTokenBracket()
const {
581 return Tok.
isOneOf(tok::l_square, tok::r_square);
584 bool isTokenBrace()
const {
585 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
588 bool isTokenStringLiteral()
const {
592 bool isTokenSpecial()
const {
593 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
594 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
599 bool isTokenEqualOrEqualTypo();
603 void UnconsumeToken(Token &Consumed) {
610 SourceLocation ConsumeAnnotationToken() {
620 SourceLocation ConsumeParen() {
621 assert(isTokenParen() &&
"wrong consume method");
622 if (Tok.
getKind() == tok::l_paren)
624 else if (ParenCount) {
625 AngleBrackets.clear(*
this);
630 return PrevTokLocation;
635 SourceLocation ConsumeBracket() {
636 assert(isTokenBracket() &&
"wrong consume method");
637 if (Tok.
getKind() == tok::l_square)
639 else if (BracketCount) {
640 AngleBrackets.clear(*
this);
646 return PrevTokLocation;
651 SourceLocation ConsumeBrace() {
652 assert(isTokenBrace() &&
"wrong consume method");
653 if (Tok.
getKind() == tok::l_brace)
655 else if (BraceCount) {
656 AngleBrackets.clear(*
this);
662 return PrevTokLocation;
669 SourceLocation ConsumeStringToken() {
670 assert(isTokenStringLiteral() &&
671 "Should only consume string literals with this method");
674 return PrevTokLocation;
682 SourceLocation ConsumeCodeCompletionToken() {
683 assert(Tok.
is(tok::code_completion));
686 return PrevTokLocation;
694 SourceLocation handleUnexpectedCodeCompletionToken();
698 void cutOffParsing() {
709 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
710 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
711 Kind == tok::annot_repl_input_end;
721 void initializePragmaHandlers();
724 void resetPragmaHandlers();
727 void HandlePragmaUnused();
731 void HandlePragmaVisibility();
735 void HandlePragmaPack();
739 void HandlePragmaMSStruct();
741 void HandlePragmaMSPointersToMembers();
743 void HandlePragmaMSVtorDisp();
745 void HandlePragmaMSPragma();
746 bool HandlePragmaMSSection(StringRef PragmaName,
747 SourceLocation PragmaLocation);
748 bool HandlePragmaMSSegment(StringRef PragmaName,
749 SourceLocation PragmaLocation);
750 bool HandlePragmaMSInitSeg(StringRef PragmaName,
751 SourceLocation PragmaLocation);
752 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
753 SourceLocation PragmaLocation);
754 bool HandlePragmaMSFunction(StringRef PragmaName,
755 SourceLocation PragmaLocation);
756 bool HandlePragmaMSAllocText(StringRef PragmaName,
757 SourceLocation PragmaLocation);
758 bool HandlePragmaMSOptimize(StringRef PragmaName,
759 SourceLocation PragmaLocation);
763 void HandlePragmaAlign();
767 void HandlePragmaDump();
771 void HandlePragmaWeak();
775 void HandlePragmaWeakAlias();
779 void HandlePragmaRedefineExtname();
783 void HandlePragmaFPContract();
787 void HandlePragmaFEnvAccess();
791 void HandlePragmaFEnvRound();
795 void HandlePragmaCXLimitedRange();
799 void HandlePragmaFloatControl();
803 void HandlePragmaFP();
807 void HandlePragmaOpenCLExtension();
815 bool HandlePragmaLoopHint(LoopHint &Hint);
817 bool ParsePragmaAttributeSubjectMatchRuleSet(
819 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
821 void HandlePragmaAttribute();
830 const Token &GetLookAheadToken(
unsigned N) {
831 if (N == 0 || Tok.
is(tok::eof))
return Tok;
852 "produced a valid-but-null type annotation?");
856 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
857 return static_cast<NamedDecl*
>(Tok.getAnnotationValue());
860 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
861 Tok.setAnnotationValue(ND);
864 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
865 return static_cast<IdentifierInfo*
>(Tok.getAnnotationValue());
868 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
869 Tok.setAnnotationValue(ND);
874 static ExprResult getExprAnnotation(
const Token &Tok) {
875 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
880 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
881 Tok.setAnnotationValue(ER.getAsOpaquePointer());
891 CXXScopeSpec &SS,
bool IsNewScope,
897 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
898 (Tok.is(tok::annot_template_id) &&
900 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
907 enum AnnotatedNameKind {
921 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
926 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
931 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
932 const char *&PrevSpec,
unsigned &DiagID,
937 if (Tok.getIdentifierInfo() != Ident_vector &&
938 Tok.getIdentifierInfo() != Ident_bool &&
939 Tok.getIdentifierInfo() != Ident_Bool &&
940 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
943 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
949 bool TryAltiVecVectorToken() {
951 Tok.getIdentifierInfo() != Ident_vector)
return false;
952 return TryAltiVecVectorTokenOutOfLine();
955 bool TryAltiVecVectorTokenOutOfLine();
956 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
957 const char *&PrevSpec,
unsigned &DiagID,
963 bool isObjCInstancetype() {
965 if (Tok.isAnnotation())
967 if (!Ident_instancetype)
969 return Tok.getIdentifierInfo() == Ident_instancetype;
977 bool TryKeywordIdentFallback(
bool DisableKeyword);
980 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
993 class TentativeParsingAction {
995 PreferredTypeBuilder PrevPreferredType;
997 size_t PrevTentativelyDeclaredIdentifierCount;
998 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
1002 explicit TentativeParsingAction(Parser &p)
1003 :
P(p), PrevPreferredType(
P.PreferredType) {
1005 PrevTentativelyDeclaredIdentifierCount =
1006 P.TentativelyDeclaredIdentifiers.size();
1007 PrevParenCount =
P.ParenCount;
1008 PrevBracketCount =
P.BracketCount;
1009 PrevBraceCount =
P.BraceCount;
1010 P.PP.EnableBacktrackAtThisPos();
1014 assert(isActive &&
"Parsing action was finished!");
1015 P.TentativelyDeclaredIdentifiers.resize(
1016 PrevTentativelyDeclaredIdentifierCount);
1017 P.PP.CommitBacktrackedTokens();
1021 assert(isActive &&
"Parsing action was finished!");
1023 P.PreferredType = PrevPreferredType;
1025 P.TentativelyDeclaredIdentifiers.resize(
1026 PrevTentativelyDeclaredIdentifierCount);
1027 P.ParenCount = PrevParenCount;
1028 P.BracketCount = PrevBracketCount;
1029 P.BraceCount = PrevBraceCount;
1032 ~TentativeParsingAction() {
1033 assert(!isActive &&
"Forgot to call Commit or Revert!");
1038 class RevertingTentativeParsingAction
1039 :
private Parser::TentativeParsingAction {
1041 RevertingTentativeParsingAction(Parser &P)
1042 : Parser::TentativeParsingAction(
P) {}
1043 ~RevertingTentativeParsingAction() { Revert(); }
1046 class UnannotatedTentativeParsingAction;
1053 ObjCContainerDecl *DC;
1054 SaveAndRestore<bool> WithinObjCContainer;
1056 explicit ObjCDeclContextSwitch(Parser &p)
1058 WithinObjCContainer(
P.ParsingInObjCContainer, DC != nullptr) {
1060 P.Actions.ActOnObjCTemporaryExitContainerContext(DC);
1062 ~ObjCDeclContextSwitch() {
1064 P.Actions.ActOnObjCReenterContainerContext(DC);
1077 unsigned Diag = diag::err_expected,
1078 StringRef DiagMsg =
"");
1085 bool ExpectAndConsumeSemi(
unsigned DiagID , StringRef TokenUsed =
"");
1088 enum ExtraSemiKind {
1089 OutsideFunction = 0,
1091 InstanceVariableList = 2,
1092 AfterMemberFunctionDefinition = 3
1104 bool expectIdentifier();
1107 enum class CompoundToken {
1122 void checkCompoundToken(SourceLocation FirstTokLoc,
1125 void diagnoseUseOfC11Keyword(
const Token &Tok);
1147 bool BeforeCompoundStmt =
false)
1149 if (EnteredScope && !BeforeCompoundStmt)
1150 Self->EnterScope(ScopeFlags);
1152 if (BeforeCompoundStmt)
1153 Self->incrementMSManglingNumber();
1155 this->Self =
nullptr;
1177 unsigned NumScopes = 0;
1184 Self.EnterScope(ScopeFlags);
1209 class ParseScopeFlags {
1211 unsigned OldFlags = 0;
1212 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1213 void operator=(
const ParseScopeFlags &) =
delete;
1216 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1224 DiagnosticBuilder
Diag(SourceLocation Loc,
unsigned DiagID);
1225 DiagnosticBuilder
Diag(
const Token &Tok,
unsigned DiagID);
1227 return Diag(Tok, DiagID);
1248 static_cast<unsigned>(R));
1290 struct ParsingClass;
1300 class LateParsedDeclaration {
1302 virtual ~LateParsedDeclaration();
1304 virtual void ParseLexedMethodDeclarations();
1305 virtual void ParseLexedMemberInitializers();
1306 virtual void ParseLexedMethodDefs();
1307 virtual void ParseLexedAttributes();
1308 virtual void ParseLexedPragmas();
1313 class LateParsedClass :
public LateParsedDeclaration {
1315 LateParsedClass(
Parser *
P, ParsingClass *
C);
1316 ~LateParsedClass()
override;
1318 void ParseLexedMethodDeclarations()
override;
1319 void ParseLexedMemberInitializers()
override;
1320 void ParseLexedMethodDefs()
override;
1321 void ParseLexedAttributes()
override;
1322 void ParseLexedPragmas()
override;
1326 ParsingClass *
Class;
1335 struct LateParsedAttribute :
public LateParsedDeclaration {
1338 IdentifierInfo &AttrName;
1339 IdentifierInfo *MacroII =
nullptr;
1340 SourceLocation AttrNameLoc;
1341 SmallVector<Decl*, 2> Decls;
1343 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1345 : Self(
P), AttrName(Name), AttrNameLoc(Loc) {}
1347 void ParseLexedAttributes()
override;
1349 void addDecl(Decl *D) { Decls.push_back(D); }
1356 class LateParsedPragma :
public LateParsedDeclaration {
1357 Parser *
Self =
nullptr;
1363 :
Self(
P), AS(AS) {}
1365 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1369 void ParseLexedPragmas()
override;
1373 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1375 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1377 bool parseSoon() {
return ParseSoon; }
1386 struct LexedMethod :
public LateParsedDeclaration {
1391 explicit LexedMethod(Parser *
P, Decl *MD) :
Self(
P), D(MD) {}
1393 void ParseLexedMethodDefs()
override;
1400 struct LateParsedDefaultArgument {
1401 explicit LateParsedDefaultArgument(Decl *
P,
1402 std::unique_ptr<CachedTokens> Toks =
nullptr)
1403 : Param(
P), Toks(
std::move(Toks)) { }
1412 std::unique_ptr<CachedTokens> Toks;
1419 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1420 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1421 :
Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1423 void ParseLexedMethodDeclarations()
override;
1435 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1445 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1446 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1449 void ParseLexedMemberInitializers()
override;
1467 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1472 struct ParsingClass {
1473 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1474 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1475 TagOrTemplate(TagOrTemplate) {}
1479 bool TopLevelClass : 1;
1482 bool IsInterface : 1;
1485 Decl *TagOrTemplate;
1490 LateParsedDeclarationsContainer LateParsedDeclarations;
1496 std::stack<ParsingClass *> ClassStack;
1498 ParsingClass &getCurrentClass() {
1499 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1500 return *ClassStack.top();
1504 class ParsingClassDefinition {
1510 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1513 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1518 assert(!Popped &&
"Nested class has already been popped");
1520 P.PopParsingClass(State);
1523 ~ParsingClassDefinition() {
1525 P.PopParsingClass(State);
1532 struct ParsedTemplateInfo {
1533 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1536 bool isSpecialization,
1537 bool lastParameterListWasEmpty =
false)
1538 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1539 TemplateParams(TemplateParams),
1540 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1542 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1543 SourceLocation TemplateLoc)
1544 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1545 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1546 LastParameterListWasEmpty(
false){ }
1555 ExplicitSpecialization,
1557 ExplicitInstantiation
1566 SourceLocation ExternLoc;
1570 SourceLocation TemplateLoc;
1573 bool LastParameterListWasEmpty;
1579 struct ReenterTemplateScopeRAII;
1580 struct ReenterClassScopeRAII;
1582 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1583 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1585 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1587 Sema::ParsingClassState
1588 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1589 void DeallocateParsedClasses(ParsingClass *
Class);
1590 void PopParsingClass(Sema::ParsingClassState);
1592 enum CachedInitKind {
1593 CIK_DefaultArgument,
1594 CIK_DefaultInitializer
1598 const ParsedAttributesView &AccessAttrs,
1599 ParsingDeclarator &D,
1600 const ParsedTemplateInfo &TemplateInfo,
1601 const VirtSpecifiers &VS,
1602 SourceLocation PureSpecLoc);
1603 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1604 void ParseLexedAttributes(ParsingClass &
Class);
1605 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1607 void ParseLexedAttribute(LateParsedAttribute &LA,
1609 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1610 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1611 void ParseLexedMethodDefs(ParsingClass &
Class);
1612 void ParseLexedMethodDef(LexedMethod &LM);
1613 void ParseLexedMemberInitializers(ParsingClass &
Class);
1614 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1615 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1616 void ParseLexedPragmas(ParsingClass &
Class);
1617 void ParseLexedPragma(LateParsedPragma &LP);
1618 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1619 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1624 bool ConsumeFinalToken =
true) {
1625 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1630 bool ConsumeFinalToken =
true);
1634 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1635 ParsedAttributes &DeclSpecAttrs,
1636 ParsingDeclSpec *DS =
nullptr);
1637 bool isDeclarationAfterDeclarator();
1638 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1640 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1642 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1643 ParsedAttributes &DeclSpecAttrs,
1644 ParsingDeclSpec &DS,
1647 void SkipFunctionBody();
1648 Decl *ParseFunctionDefinition(ParsingDeclarator &D,
1649 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1650 LateParsedAttrList *LateParsedAttrs =
nullptr);
1651 void ParseKNRParamDeclarations(Declarator &D);
1653 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1654 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1658 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1659 ParsedAttributes &DeclSpecAttrs);
1660 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1661 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1662 ParsedAttributes &prefixAttrs);
1663 class ObjCTypeParamListScope;
1664 ObjCTypeParamList *parseObjCTypeParamList();
1665 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1666 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1667 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1668 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1670 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1671 SourceLocation atLoc,
1673 SmallVectorImpl<Decl *> &AllIvarDecls,
1674 bool RBraceMissing);
1675 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1677 SourceLocation atLoc);
1678 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1679 SmallVectorImpl<SourceLocation> &PLocs,
1680 bool WarnOnDeclarations,
1681 bool ForObjCContainer,
1682 SourceLocation &LAngleLoc,
1683 SourceLocation &EndProtoLoc,
1684 bool consumeLastToken);
1689 void parseObjCTypeArgsOrProtocolQualifiers(
1691 SourceLocation &typeArgsLAngleLoc,
1692 SmallVectorImpl<ParsedType> &typeArgs,
1693 SourceLocation &typeArgsRAngleLoc,
1694 SourceLocation &protocolLAngleLoc,
1695 SmallVectorImpl<Decl *> &protocols,
1696 SmallVectorImpl<SourceLocation> &protocolLocs,
1697 SourceLocation &protocolRAngleLoc,
1698 bool consumeLastToken,
1699 bool warnOnIncompleteProtocols);
1703 void parseObjCTypeArgsAndProtocolQualifiers(
1705 SourceLocation &typeArgsLAngleLoc,
1706 SmallVectorImpl<ParsedType> &typeArgs,
1707 SourceLocation &typeArgsRAngleLoc,
1708 SourceLocation &protocolLAngleLoc,
1709 SmallVectorImpl<Decl *> &protocols,
1710 SmallVectorImpl<SourceLocation> &protocolLocs,
1711 SourceLocation &protocolRAngleLoc,
1712 bool consumeLastToken);
1716 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1720 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1722 bool consumeLastToken,
1723 SourceLocation &endLoc);
1727 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1728 ParsedAttributes &prefixAttrs);
1730 struct ObjCImplParsingDataRAII {
1734 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1735 LateParsedObjCMethodContainer LateParsedObjCMethods;
1737 ObjCImplParsingDataRAII(Parser &parser, Decl *D)
1738 :
P(parser), Dcl(D), HasCFunction(
false) {
1739 P.CurParsedObjCImpl =
this;
1742 ~ObjCImplParsingDataRAII();
1744 void finish(SourceRange AtEnd);
1745 bool isFinished()
const {
return Finished; }
1750 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1751 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1753 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1754 ParsedAttributes &Attrs);
1756 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1757 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1758 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1760 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1763 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1764 objc_nonnull, objc_nullable, objc_null_unspecified,
1767 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1769 bool isTokIdentifier_in()
const;
1772 ParsedAttributes *ParamAttrs);
1773 Decl *ParseObjCMethodPrototype(
1775 bool MethodDefinition =
true);
1778 bool MethodDefinition=
true);
1779 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1781 Decl *ParseObjCMethodDefinition();
1809 unsigned &NumLineToksConsumed,
1810 bool IsUnevaluated);
1826 enum CastParseKind {
1831 ExprResult ParseCastExpression(CastParseKind ParseKind,
1832 bool isAddressOfOperand,
1835 bool isVectorLiteral =
false,
1836 bool *NotPrimaryExpression =
nullptr);
1837 ExprResult ParseCastExpression(CastParseKind ParseKind,
1838 bool isAddressOfOperand =
false,
1840 bool isVectorLiteral =
false,
1841 bool *NotPrimaryExpression =
nullptr);
1844 bool isNotExpressionStart();
1848 bool isPostfixExpressionSuffixStart() {
1850 return (K == tok::l_square || K == tok::l_paren ||
1851 K == tok::period || K == tok::arrow ||
1852 K == tok::plusplus || K == tok::minusminus);
1855 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1856 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1857 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1858 const Token &OpToken);
1859 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1860 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1861 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1866 ExprResult ParseUnaryExprOrTypeTraitExpression();
1868 ExprResult ParseSYCLUniqueStableNameExpression();
1870 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1873 SourceRange &CastRange);
1876 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1877 llvm::function_ref<
void()> ExpressionStarts =
1878 llvm::function_ref<
void()>(),
1879 bool FailImmediatelyOnInvalidExpr =
false,
1880 bool EarlyTypoCorrection =
false);
1884 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1887 enum ParenParseOption {
1894 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1895 bool stopIfCastExpr,
1898 SourceLocation &RParenLoc);
1901 ParenParseOption &ExprType,
ParsedType &CastTy,
1904 SourceLocation LParenLoc,
1905 SourceLocation RParenLoc);
1907 ExprResult ParseGenericSelectionExpression();
1915 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1916 Token &Replacement);
1921 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1923 bool areTokensAdjacent(
const Token &A,
const Token &B);
1925 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1926 bool EnteringContext, IdentifierInfo &II,
1929 bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
1931 bool ObjectHasErrors,
1932 bool EnteringContext,
1933 bool *MayBePseudoDestructor =
nullptr,
1934 bool IsTypename =
false,
1935 IdentifierInfo **LastII =
nullptr,
1936 bool OnlyNamespace =
false,
1937 bool InUsingDeclaration =
false);
1943 enum class LambdaIntroducerTentativeParse {
1960 ParseLambdaIntroducer(LambdaIntroducer &Intro,
1961 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1962 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
1981 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
1996 SourceRange &SpecificationRange,
1997 SmallVectorImpl<ParsedType> &DynamicExceptions,
1998 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2004 SourceRange &SpecificationRange,
2005 SmallVectorImpl<ParsedType> &Exceptions,
2006 SmallVectorImpl<SourceRange> &Ranges);
2010 TypeResult ParseTrailingReturnType(SourceRange &Range,
2011 bool MayBeFollowedByDirectInit);
2019 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2024 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2026 bool ParseCXXTypeSpecifierSeq(
2031 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2033 void ParseDirectNewDeclarator(Declarator &D);
2034 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2035 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2036 SourceLocation Start);
2040 struct ForRangeInfo;
2041 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2045 ForRangeInfo *FRI =
nullptr,
2046 bool EnterForConditionScope =
false);
2048 ParsedAttributes &Attrs);
2059 void ParseTrailingRequiresClause(Declarator &D);
2069 if (Tok.isNot(tok::l_brace))
2071 return ParseBraceInitializer();
2073 bool MayBeDesignationStart();
2075 struct DesignatorCompletionInfo {
2076 SmallVectorImpl<Expr *> &InitExprs;
2077 QualType PreferredBaseType;
2079 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2088 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2089 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2090 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2091 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2092 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2093 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2094 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2095 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2096 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2097 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2098 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2099 bool isSimpleObjCMessageExpression();
2101 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2102 SourceLocation SuperLoc,
2104 Expr *ReceiverExpr);
2105 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2106 SourceLocation LBracloc, SourceLocation SuperLoc,
2107 ParsedType ReceiverType, Expr *ReceiverExpr);
2108 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2114 typedef SmallVector<Expr*, 12> ExprVector;
2117 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2118 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2120 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2121 SourceLocation *TrailingElseLoc =
nullptr);
2122 StmtResult ParseStatementOrDeclarationAfterAttributes(
2123 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2124 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2125 ParsedAttributes &DeclSpecAttrs);
2126 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2127 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2128 ParsedStmtContext StmtCtx);
2129 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2130 bool MissingCase =
false,
2132 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2133 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2134 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2135 unsigned ScopeFlags);
2136 void ParseCompoundStatementLeadingPragmas();
2137 void DiagnoseLabelAtEndOfCompoundStatement();
2139 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2140 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2141 Sema::ConditionResult &CondResult,
2143 SourceLocation &LParenLoc,
2144 SourceLocation &RParenLoc);
2145 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2146 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2147 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2149 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2155 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2157 SourceLocation *TrailingElseLoc,
2158 ParsedAttributes &Attrs);
2162 enum IfExistsBehavior {
2174 struct IfExistsCondition {
2176 SourceLocation KeywordLoc;
2189 IfExistsBehavior Behavior;
2192 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2193 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2194 void ParseMicrosoftIfExistsExternalDeclaration();
2195 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2196 ParsedAttributes &AccessAttrs,
2198 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2200 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2201 SmallVectorImpl<Expr *> &Constraints,
2202 SmallVectorImpl<Expr *> &Exprs);
2208 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2209 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2215 StmtResult ParseSEHExceptBlock(SourceLocation Loc);
2216 StmtResult ParseSEHFinallyBlock(SourceLocation Loc);
2222 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2223 ParsedStmtContext StmtCtx);
2224 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2225 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2226 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2227 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2236 enum class DeclSpecContext {
2241 DSC_alias_declaration,
2246 DSC_template_type_arg,
2247 DSC_objc_method_result,
2256 static bool isTypeSpecifier(DeclSpecContext DSC) {
2258 case DeclSpecContext::DSC_normal:
2259 case DeclSpecContext::DSC_template_param:
2260 case DeclSpecContext::DSC_template_arg:
2261 case DeclSpecContext::DSC_class:
2262 case DeclSpecContext::DSC_top_level:
2263 case DeclSpecContext::DSC_objc_method_result:
2264 case DeclSpecContext::DSC_condition:
2267 case DeclSpecContext::DSC_template_type_arg:
2268 case DeclSpecContext::DSC_type_specifier:
2269 case DeclSpecContext::DSC_conv_operator:
2270 case DeclSpecContext::DSC_trailing:
2271 case DeclSpecContext::DSC_alias_declaration:
2272 case DeclSpecContext::DSC_association:
2273 case DeclSpecContext::DSC_new:
2276 llvm_unreachable(
"Missing DeclSpecContext case");
2280 enum class AllowDefiningTypeSpec {
2297 static AllowDefiningTypeSpec
2298 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2300 case DeclSpecContext::DSC_normal:
2301 case DeclSpecContext::DSC_class:
2302 case DeclSpecContext::DSC_top_level:
2303 case DeclSpecContext::DSC_alias_declaration:
2304 case DeclSpecContext::DSC_objc_method_result:
2305 return AllowDefiningTypeSpec::Yes;
2307 case DeclSpecContext::DSC_condition:
2308 case DeclSpecContext::DSC_template_param:
2309 return AllowDefiningTypeSpec::YesButInvalid;
2311 case DeclSpecContext::DSC_template_type_arg:
2312 case DeclSpecContext::DSC_type_specifier:
2313 return AllowDefiningTypeSpec::NoButErrorRecovery;
2315 case DeclSpecContext::DSC_association:
2316 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2317 : AllowDefiningTypeSpec::Yes;
2319 case DeclSpecContext::DSC_trailing:
2320 case DeclSpecContext::DSC_conv_operator:
2321 case DeclSpecContext::DSC_template_arg:
2322 case DeclSpecContext::DSC_new:
2323 return AllowDefiningTypeSpec::No;
2325 llvm_unreachable(
"Missing DeclSpecContext case");
2329 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2331 case DeclSpecContext::DSC_normal:
2332 case DeclSpecContext::DSC_class:
2333 case DeclSpecContext::DSC_top_level:
2336 case DeclSpecContext::DSC_alias_declaration:
2337 case DeclSpecContext::DSC_objc_method_result:
2338 case DeclSpecContext::DSC_condition:
2339 case DeclSpecContext::DSC_template_param:
2340 case DeclSpecContext::DSC_template_type_arg:
2341 case DeclSpecContext::DSC_type_specifier:
2342 case DeclSpecContext::DSC_trailing:
2343 case DeclSpecContext::DSC_association:
2344 case DeclSpecContext::DSC_conv_operator:
2345 case DeclSpecContext::DSC_template_arg:
2346 case DeclSpecContext::DSC_new:
2350 llvm_unreachable(
"Missing DeclSpecContext case");
2355 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2357 case DeclSpecContext::DSC_normal:
2358 case DeclSpecContext::DSC_template_param:
2359 case DeclSpecContext::DSC_template_arg:
2360 case DeclSpecContext::DSC_class:
2361 case DeclSpecContext::DSC_top_level:
2362 case DeclSpecContext::DSC_condition:
2363 case DeclSpecContext::DSC_type_specifier:
2364 case DeclSpecContext::DSC_association:
2365 case DeclSpecContext::DSC_conv_operator:
2366 case DeclSpecContext::DSC_new:
2369 case DeclSpecContext::DSC_objc_method_result:
2370 case DeclSpecContext::DSC_template_type_arg:
2371 case DeclSpecContext::DSC_trailing:
2372 case DeclSpecContext::DSC_alias_declaration:
2375 llvm_unreachable(
"Missing DeclSpecContext case");
2380 getImplicitTypenameContext(DeclSpecContext DSC) {
2382 case DeclSpecContext::DSC_class:
2383 case DeclSpecContext::DSC_top_level:
2384 case DeclSpecContext::DSC_type_specifier:
2385 case DeclSpecContext::DSC_template_type_arg:
2386 case DeclSpecContext::DSC_trailing:
2387 case DeclSpecContext::DSC_alias_declaration:
2388 case DeclSpecContext::DSC_template_param:
2389 case DeclSpecContext::DSC_new:
2392 case DeclSpecContext::DSC_normal:
2393 case DeclSpecContext::DSC_objc_method_result:
2394 case DeclSpecContext::DSC_condition:
2395 case DeclSpecContext::DSC_template_arg:
2396 case DeclSpecContext::DSC_conv_operator:
2397 case DeclSpecContext::DSC_association:
2400 llvm_unreachable(
"Missing DeclSpecContext case");
2405 struct ForRangeInit {
2406 SourceLocation ColonLoc;
2408 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2409 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2411 struct ForRangeInfo : ForRangeInit {
2416 SourceLocation &DeclEnd,
2417 ParsedAttributes &DeclAttrs,
2418 ParsedAttributes &DeclSpecAttrs,
2419 SourceLocation *DeclSpecStart =
nullptr);
2422 ParsedAttributes &DeclAttrs,
2423 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2424 ForRangeInit *FRI =
nullptr,
2425 SourceLocation *DeclSpecStart =
nullptr);
2428 ParsedAttributes &Attrs,
2429 ParsedTemplateInfo &TemplateInfo,
2430 SourceLocation *DeclEnd =
nullptr,
2431 ForRangeInit *FRI =
nullptr);
2432 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2433 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2434 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2435 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2437 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2438 ForRangeInit *FRI =
nullptr);
2439 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2440 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2446 bool trySkippingFunctionBody();
2448 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2449 const ParsedTemplateInfo &TemplateInfo,
2451 ParsedAttributes &Attrs);
2454 void ParseDeclarationSpecifiers(
2456 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2458 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2459 LateParsedAttrList *LateAttrs =
nullptr) {
2460 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2461 getImplicitTypenameContext(DSC));
2463 void ParseDeclarationSpecifiers(
2464 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS,
2465 DeclSpecContext DSC, LateParsedAttrList *LateAttrs,
2468 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2469 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2470 SourceLocation StartLoc,
2471 SourceLocation EndLoc);
2473 bool DiagnoseMissingSemiAfterTagDefinition(
2475 LateParsedAttrList *LateAttrs =
nullptr);
2477 void ParseSpecifierQualifierList(
2479 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2480 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2483 void ParseSpecifierQualifierList(
2486 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2488 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2491 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2492 const ParsedTemplateInfo &TemplateInfo,
2494 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2495 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2496 RecordDecl *TagDecl);
2498 void ParseStructDeclaration(
2499 ParsingDeclSpec &DS,
2500 llvm::function_ref<
void(ParsingFieldDeclarator &)> FieldsCallback);
2505 bool DisambiguatingWithExpression =
false);
2506 bool isTypeSpecifierQualifier();
2511 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2516 bool isKnownToBeDeclarationSpecifier() {
2529 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2531 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2539 bool isForInitDeclaration() {
2543 return Tok.is(tok::kw_using) ||
2544 isCXXSimpleDeclaration(
true);
2549 bool isForRangeIdentifier();
2553 bool isStartOfObjCClassMessageMissingOpenBracket();
2558 bool isConstructorDeclarator(
2561 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2565 enum TentativeCXXTypeIdContext {
2568 TypeIdAsTemplateArgument,
2569 TypeIdInTrailingReturnType,
2570 TypeIdAsGenericSelectionArgument,
2576 bool isTypeIdInParens(
bool &isAmbiguous) {
2578 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2579 isAmbiguous =
false;
2580 return isTypeSpecifierQualifier();
2582 bool isTypeIdInParens() {
2584 return isTypeIdInParens(isAmbiguous);
2594 bool isTypeIdForGenericSelection() {
2597 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2599 return isTypeSpecifierQualifier();
2605 bool isTypeIdUnambiguously() {
2608 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2610 return isTypeSpecifierQualifier();
2616 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2623 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2632 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2636 struct ConditionDeclarationOrInitStatementState;
2637 enum class ConditionOrInitStatement {
2647 ConditionOrInitStatement
2648 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2649 bool CanBeForRangeDecl);
2651 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2652 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2654 return isCXXTypeId(Context, isAmbiguous);
2659 enum class TPResult {
2660 True, False, Ambiguous,
Error
2670 bool isEnumBase(
bool AllowSemi);
2681 TPResult BracedCastResult = TPResult::False,
2682 bool *InvalidAsDeclSpec =
nullptr);
2687 bool isCXXDeclarationSpecifierAType();
2692 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2697 TPResult isExplicitBool();
2702 bool isTentativelyDeclared(IdentifierInfo *II);
2711 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2712 TPResult TryParseTypeofSpecifier();
2713 TPResult TryParseProtocolQualifiers();
2714 TPResult TryParsePtrOperatorSeq();
2715 TPResult TryParseOperatorId();
2716 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2717 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2718 bool mayHaveDirectInit =
false,
2719 bool mayHaveTrailingReturnType =
false);
2720 TPResult TryParseParameterDeclarationClause(
2721 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2724 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2725 bool NameAfterArrowIsNonType();
2726 TPResult TryParseBracketDeclarator();
2727 TPResult TryConsumeDeclarationSpecifier();
2731 bool TrySkipAttributes();
2735 void DiagnoseBitIntUse(
const Token &Tok);
2742 ParsedAttributes *Attrs =
nullptr);
2745 void ParseBlockId(SourceLocation CaretLoc);
2752 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2753 bool OuterMightBeMessageSend =
false) {
2754 return (Tok.isRegularKeywordAttribute() ||
2755 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2760 bool CheckProhibitedCXX11Attribute() {
2761 assert(Tok.is(tok::l_square));
2764 return DiagnoseProhibitedCXX11Attribute();
2767 bool DiagnoseProhibitedCXX11Attribute();
2768 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2769 SourceLocation CorrectLocation) {
2770 if (!Tok.isRegularKeywordAttribute() &&
2771 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2772 Tok.isNot(tok::kw_alignas))
2774 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2776 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2777 SourceLocation CorrectLocation);
2779 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2783 void ProhibitAttributes(ParsedAttributes &Attrs,
2784 SourceLocation FixItLoc = SourceLocation()) {
2785 if (Attrs.Range.isInvalid())
2787 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2791 void ProhibitAttributes(ParsedAttributesView &Attrs,
2792 SourceLocation FixItLoc = SourceLocation()) {
2793 if (Attrs.Range.isInvalid())
2795 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2796 Attrs.clearListOnly();
2798 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2799 SourceLocation FixItLoc);
2807 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2808 unsigned KeywordDiagId,
2809 bool DiagnoseEmptyAttrs =
false,
2810 bool WarnOnUnknownAttrs =
false);
2815 SourceLocation SkipCXX11Attributes();
2819 void DiagnoseAndSkipCXX11Attributes();
2823 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2825 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2829 SmallVectorImpl<Expr *> &Exprs,
2830 ParsedAttributeArgumentsProperties ArgsProperties);
2837 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2838 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2839 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2840 ParsedAttr::Form Form);
2842 enum ParseAttrKindMask {
2844 PAKM_Declspec = 1 << 1,
2845 PAKM_CXX11 = 1 << 2,
2862 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2863 LateParsedAttrList *LateAttrs =
nullptr);
2866 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2867 LateParsedAttrList *LateAttrs =
nullptr) {
2868 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2869 isAllowedCXX11AttributeSpecifier()) {
2870 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2876 void MaybeParseGNUAttributes(Declarator &D,
2877 LateParsedAttrList *LateAttrs =
nullptr) {
2878 if (Tok.is(tok::kw___attribute)) {
2879 ParsedAttributes Attrs(AttrFactory);
2880 ParseGNUAttributes(Attrs, LateAttrs, &D);
2881 D.takeAttributes(Attrs);
2885 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2886 LateParsedAttrList *LateAttrs =
nullptr) {
2887 if (Tok.is(tok::kw___attribute)) {
2888 ParseGNUAttributes(Attrs, LateAttrs);
2894 void ParseGNUAttributes(ParsedAttributes &Attrs,
2895 LateParsedAttrList *LateAttrs =
nullptr,
2896 Declarator *D =
nullptr);
2897 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2898 SourceLocation AttrNameLoc,
2899 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2900 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2901 ParsedAttr::Form Form, Declarator *D);
2902 IdentifierLoc *ParseIdentifierLoc();
2905 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2906 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2907 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2908 ParsedAttr::Form Form);
2910 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2913 if (!OpenMPTokens.empty()) {
2915 PP.EnterTokenStream(OpenMPTokens,
true,
2920 void MaybeParseCXX11Attributes(Declarator &D) {
2921 if (isAllowedCXX11AttributeSpecifier()) {
2922 ParsedAttributes Attrs(AttrFactory);
2923 ParseCXX11Attributes(Attrs);
2924 D.takeAttributes(Attrs);
2928 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2929 bool OuterMightBeMessageSend =
false) {
2930 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2931 ParseCXX11Attributes(Attrs);
2937 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
2940 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2942 SourceLocation *EndLoc =
nullptr);
2943 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2944 SourceLocation *EndLoc =
nullptr) {
2946 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2947 ReplayOpenMPAttributeTokens(OpenMPTokens);
2949 void ParseCXX11Attributes(ParsedAttributes &attrs);
2952 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
2953 SourceLocation AttrNameLoc,
2954 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2955 IdentifierInfo *ScopeName,
2956 SourceLocation ScopeLoc,
2960 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
2961 IdentifierInfo *AttrName,
2962 SourceLocation AttrNameLoc,
2963 SourceLocation *EndLoc);
2965 IdentifierInfo *TryParseCXX11AttributeIdentifier(
2966 SourceLocation &Loc,
2968 const IdentifierInfo *EnclosingScope =
nullptr);
2970 void MaybeParseHLSLSemantics(Declarator &D,
2971 SourceLocation *EndLoc =
nullptr) {
2972 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLSemantics is for HLSL only");
2973 if (Tok.is(tok::colon)) {
2974 ParsedAttributes Attrs(AttrFactory);
2975 ParseHLSLSemantics(Attrs, EndLoc);
2976 D.takeAttributes(Attrs);
2980 void MaybeParseHLSLSemantics(ParsedAttributes &Attrs,
2981 SourceLocation *EndLoc =
nullptr) {
2982 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLSemantics is for HLSL only");
2984 ParseHLSLSemantics(Attrs, EndLoc);
2987 void ParseHLSLSemantics(ParsedAttributes &Attrs,
2988 SourceLocation *EndLoc =
nullptr);
2989 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
2991 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2993 Tok.is(tok::l_square)) {
2994 ParsedAttributes AttrsWithRange(AttrFactory);
2995 ParseMicrosoftAttributes(AttrsWithRange);
2996 Attrs.takeAllFrom(AttrsWithRange);
2999 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3000 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3001 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3002 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3003 ParseMicrosoftDeclSpecs(Attrs);
3008 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3009 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3010 SourceLocation AttrNameLoc,
3011 ParsedAttributes &Attrs);
3012 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3013 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3014 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3015 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3016 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3017 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3018 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3019 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3020 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3021 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3022 bool isHLSLQualifier(
const Token &Tok)
const;
3023 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3025 VersionTuple ParseVersionTuple(SourceRange &Range);
3026 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3027 SourceLocation AvailabilityLoc,
3028 ParsedAttributes &attrs,
3029 SourceLocation *endLoc,
3030 IdentifierInfo *ScopeName,
3031 SourceLocation ScopeLoc,
3032 ParsedAttr::Form Form);
3034 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3035 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3037 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3039 ParsedAttributes &Attrs,
3040 SourceLocation *EndLoc,
3041 IdentifierInfo *ScopeName,
3042 SourceLocation ScopeLoc,
3043 ParsedAttr::Form Form);
3045 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3046 SourceLocation ObjCBridgeRelatedLoc,
3047 ParsedAttributes &Attrs,
3048 SourceLocation *EndLoc,
3049 IdentifierInfo *ScopeName,
3050 SourceLocation ScopeLoc,
3051 ParsedAttr::Form Form);
3053 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3054 SourceLocation AttrNameLoc,
3055 ParsedAttributes &Attrs,
3056 SourceLocation *EndLoc,
3057 IdentifierInfo *ScopeName,
3058 SourceLocation ScopeLoc,
3059 ParsedAttr::Form Form);
3061 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3062 SourceLocation AttrNameLoc,
3063 ParsedAttributes &Attrs,
3064 SourceLocation *EndLoc,
3065 IdentifierInfo *ScopeName,
3066 SourceLocation ScopeLoc,
3067 ParsedAttr::Form Form);
3069 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3070 SourceLocation AttrNameLoc,
3071 ParsedAttributes &Attrs,
3072 IdentifierInfo *ScopeName,
3073 SourceLocation ScopeLoc,
3074 ParsedAttr::Form Form);
3076 void ParseTypeofSpecifier(DeclSpec &DS);
3077 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3078 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3079 SourceLocation StartLoc,
3080 SourceLocation EndLoc);
3081 void ParseAtomicSpecifier(DeclSpec &DS);
3083 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3084 SourceLocation &EllipsisLoc,
bool &IsType,
3086 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3087 SourceLocation *endLoc =
nullptr);
3092 return isCXX11VirtSpecifier(Tok);
3094 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3095 SourceLocation FriendLoc);
3097 bool isCXX11FinalKeyword()
const;
3098 bool isClassCompatibleKeyword()
const;
3103 class DeclaratorScopeObj {
3109 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3110 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3112 void EnterDeclaratorScope() {
3113 assert(!EnteredScope &&
"Already entered the scope!");
3114 assert(SS.isSet() &&
"C++ scope was not set!");
3116 CreatedScope =
true;
3119 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3120 EnteredScope =
true;
3123 ~DeclaratorScopeObj() {
3125 assert(SS.isSet() &&
"C++ scope was cleared ?");
3126 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3134 void ParseDeclarator(Declarator &D);
3136 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3137 void ParseDeclaratorInternal(Declarator &D,
3138 DirectDeclParseFunction DirectDeclParser);
3140 enum AttrRequirements {
3141 AR_NoAttributesParsed = 0,
3142 AR_GNUAttributesParsedAndRejected = 1 << 0,
3143 AR_GNUAttributesParsed = 1 << 1,
3144 AR_CXX11AttributesParsed = 1 << 2,
3145 AR_DeclspecAttributesParsed = 1 << 3,
3146 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3147 AR_CXX11AttributesParsed |
3148 AR_DeclspecAttributesParsed,
3149 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3150 AR_DeclspecAttributesParsed
3153 void ParseTypeQualifierListOpt(
3154 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3155 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3156 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3158 void ParseDirectDeclarator(Declarator &D);
3159 void ParseDecompositionDeclarator(Declarator &D);
3160 void ParseParenDeclarator(Declarator &D);
3161 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
3163 bool IsAmbiguous,
bool RequiresArg =
false);
3164 void InitCXXThisScopeForDeclaratorIfRelevant(
3165 const Declarator &D,
const DeclSpec &DS,
3166 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3167 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3168 SourceLocation &RefQualifierLoc);
3169 bool isFunctionDeclaratorIdentifierList();
3170 void ParseFunctionDeclaratorIdentifierList(
3172 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3173 void ParseParameterDeclarationClause(
3174 Declarator &D, ParsedAttributes &attrs,
3175 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3176 SourceLocation &EllipsisLoc) {
3177 return ParseParameterDeclarationClause(
3178 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3179 D.getCXXScopeSpec().isSet() &&
3180 D.isFunctionDeclaratorAFunctionDeclaration());
3182 void ParseParameterDeclarationClause(
3184 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3185 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3187 void ParseBracketDeclarator(Declarator &D);
3188 void ParseMisplacedBracketDeclarator(Declarator &D);
3189 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3196 enum CXX11AttributeKind {
3198 CAK_NotAttributeSpecifier,
3200 CAK_AttributeSpecifier,
3203 CAK_InvalidAttributeSpecifier
3206 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3207 bool OuterMightBeMessageSend =
false);
3209 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3212 SourceLocation &DeclEnd,
3213 SourceLocation InlineLoc = SourceLocation());
3215 struct InnerNamespaceInfo {
3216 SourceLocation NamespaceLoc;
3217 SourceLocation InlineLoc;
3218 SourceLocation IdentLoc;
3219 IdentifierInfo *Ident;
3223 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3224 unsigned int index, SourceLocation &InlineLoc,
3225 ParsedAttributes &attrs,
3228 Decl *ParseExportDeclaration();
3231 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3233 SourceLocation UsingLoc,
3234 SourceLocation &DeclEnd,
3235 ParsedAttributes &attrs);
3237 struct UsingDeclarator {
3238 SourceLocation TypenameLoc;
3241 SourceLocation EllipsisLoc;
3244 TypenameLoc = EllipsisLoc = SourceLocation();
3252 const ParsedTemplateInfo &TemplateInfo,
3253 SourceLocation UsingLoc,
3254 SourceLocation &DeclEnd,
3255 ParsedAttributes &Attrs,
3257 Decl *ParseAliasDeclarationAfterDeclarator(
3258 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3260 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3262 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3263 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3264 SourceLocation AliasLoc, IdentifierInfo *Alias,
3265 SourceLocation &DeclEnd);
3269 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3270 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3271 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
3273 DeclSpecContext DSC, ParsedAttributes &Attributes);
3274 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3275 SourceLocation AttrFixitLoc,
3278 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3279 SourceLocation AttrFixitLoc,
3280 ParsedAttributes &Attrs,
unsigned TagType,
3282 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3283 SourceLocation &EqualLoc);
3285 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3288 LateParsedAttrList &LateAttrs);
3289 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3290 VirtSpecifiers &VS);
3293 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
3294 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3297 ParsedAttributes &AccessAttrs,
3299 void ParseConstructorInitializer(Decl *ConstructorDecl);
3301 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3306 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3307 SourceLocation &EndLocation);
3308 void ParseBaseClause(Decl *ClassDecl);
3309 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3312 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3314 bool ObjectHadErrors,
3315 SourceLocation TemplateKWLoc,
3316 IdentifierInfo *Name,
3317 SourceLocation NameLoc,
3318 bool EnteringContext,
3320 bool AssumeTemplateId);
3321 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3330 SourceLocation Loc);
3334 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3335 llvm::omp::TraitSet
Set,
3336 llvm::omp::TraitSelector Selector,
3337 llvm::StringMap<SourceLocation> &Seen);
3340 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3341 llvm::omp::TraitSet
Set,
3342 llvm::StringMap<SourceLocation> &Seen);
3345 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3346 llvm::StringMap<SourceLocation> &Seen);
3349 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3350 llvm::omp::TraitSet
Set,
3351 llvm::StringMap<SourceLocation> &Seen);
3354 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3355 llvm::omp::TraitSet
Set,
3356 llvm::StringMap<SourceLocation> &SeenSelectors);
3359 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3360 llvm::StringMap<SourceLocation> &SeenSets);
3363 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
3366 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3370 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
3371 OMPTraitInfo *ParentTI);
3375 SourceLocation Loc);
3379 SourceLocation Loc);
3382 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
3390 SmallVectorImpl<clang::OMPClause *> &Clauses,
3391 SourceLocation Loc);
3394 void ParseOMPDeclareTargetClauses(Sema::DeclareTargetContextInfo &DTCI);
3399 SourceLocation Loc);
3412 SourceLocation MatchingLoc,
3413 SourceLocation FoundLoc,
3414 bool SkipUntilOpenMPEnd);
3420 Decl *TagDecl =
nullptr);
3425 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3430 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
3431 DeclarationName &Name,
3436 bool tryParseOpenMPArrayShapingCastPart();
3445 bool ParseOpenMPSimpleVarList(
3447 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3449 bool AllowScopeSpecifier);
3455 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3456 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3484 bool ParseOpenMPIndirectClause(Sema::DeclareTargetContextInfo &DTCI,
3499 OMPClause *ParseOpenMPSizesClause();
3507 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3528 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3536 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3543 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3550 bool IsAddressOfOperand =
false);
3554 Sema::OpenMPVarListDataTy &
Data,
3555 const LangOptions &LangOpts);
3558 SmallVectorImpl<Expr *> &Vars,
3559 Sema::OpenMPVarListDataTy &
Data);
3561 bool ObjectHadErrors,
bool EnteringContext,
3562 bool AllowDestructorName,
bool AllowConstructorName,
3563 bool AllowDeductionGuide,
3564 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3587 struct OpenACCDirectiveParseInfo {
3589 SourceLocation StartLoc;
3590 SourceLocation EndLoc;
3598 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3602 void ParseOpenACCCacheVarList();
3604 bool ParseOpenACCVar();
3616 bool ParseOpenACCWaitArgument();
3624 bool ParseOpenACCDeviceTypeList();
3629 bool ParseOpenACCSizeExpr();
3631 bool ParseOpenACCSizeExprList();
3633 bool ParseOpenACCGangArgList();
3635 bool ParseOpenACCGangArg();
3644 SourceLocation &DeclEnd,
3645 ParsedAttributes &AccessAttrs);
3651 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3653 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3654 SmallVectorImpl<NamedDecl *> &TemplateParams,
3655 SourceLocation &LAngleLoc,
3656 SourceLocation &RAngleLoc);
3657 bool ParseTemplateParameterList(
unsigned Depth,
3658 SmallVectorImpl<NamedDecl*> &TemplateParams);
3659 TPResult isStartOfTemplateTypeParameter();
3660 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3661 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3662 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3663 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3664 bool isTypeConstraintAnnotation();
3665 bool TryAnnotateTypeConstraint();
3666 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3667 SourceLocation CorrectLoc,
3668 bool AlreadyHasEllipsis,
3669 bool IdentifierHasName);
3670 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3673 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3675 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3676 SourceLocation &RAngleLoc,
3677 bool ConsumeLastToken,
3678 bool ObjCGenericList);
3679 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3680 SourceLocation &LAngleLoc,
3681 TemplateArgList &TemplateArgs,
3682 SourceLocation &RAngleLoc,
3687 SourceLocation TemplateKWLoc,
3688 UnqualifiedId &TemplateName,
3689 bool AllowTypeAnnotation =
true,
3690 bool TypeConstraint =
false);
3692 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3694 bool IsClassName =
false);
3695 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3696 TemplateTy Template, SourceLocation OpenLoc);
3697 ParsedTemplateArgument ParseTemplateTemplateArgument();
3698 ParsedTemplateArgument ParseTemplateArgument();
3700 SourceLocation ExternLoc,
3701 SourceLocation TemplateLoc,
3702 SourceLocation &DeclEnd,
3703 ParsedAttributes &AccessAttrs,
3707 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3708 SourceLocation &DeclEnd);
3719 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3720 SourceLocation IncludeLoc);
3725 Decl *ParseModuleImport(SourceLocation AtLoc,
3727 bool parseMisplacedModuleImport();
3728 bool tryParseMisplacedModuleImport() {
3730 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3731 Kind == tok::annot_module_include)
3732 return parseMisplacedModuleImport();
3736 bool ParseModuleName(
3737 SourceLocation UseLoc,
3738 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
3752 void CodeCompleteDirective(
bool InConditional)
override;
3753 void CodeCompleteInConditionalExclusion()
override;
3754 void CodeCompleteMacroName(
bool IsDefinition)
override;
3755 void CodeCompletePreprocessorExpression()
override;
3756 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3757 unsigned ArgumentIndex)
override;
3758 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3759 void CodeCompleteNaturalLanguage()
override;
3761 class GNUAsmQualifiers {
3762 unsigned Qualifiers = AQ_unspecified;
3771 static const char *getQualifierName(AQ Qualifier);
3772 bool setAsmQualifier(AQ Qualifier);
3773 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3774 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3775 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3777 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3778 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3779 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3780 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.
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.
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
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.
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.
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr * > &Vars, Sema::OpenMPVarListDataTy &Data)
Parses clauses with list.
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.
bool ParseOpenMPReservedLocator(OpenMPClauseKind Kind, Sema::OpenMPVarListDataTy &Data, const LangOptions &LangOpts)
Parses a reserved locator like 'omp_all_memory'.
DiagnosticBuilder Diag(unsigned DiagID)
SmallVector< Stmt *, 32 > StmtVector
A SmallVector of statements.
bool parseMapperModifier(Sema::OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
bool parseMapTypeModifiers(Sema::OpenMPVarListDataTy &Data)
Parses map-type-modifiers in map clause.
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)
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.
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
void startOpenMPLoop()
If the current region is a loop-based region, mark the start of the loop construct.
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.
@ 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