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) : ParseSoon(PSoon) { }
1403 bool parseSoon() {
return ParseSoon; }
1412 struct LexedMethod :
public LateParsedDeclaration {
1417 explicit LexedMethod(Parser *
P, Decl *MD) : Self(
P), D(MD) {}
1419 void ParseLexedMethodDefs()
override;
1426 struct LateParsedDefaultArgument {
1427 explicit LateParsedDefaultArgument(Decl *
P,
1428 std::unique_ptr<CachedTokens> Toks =
nullptr)
1429 : Param(
P), Toks(
std::move(Toks)) { }
1438 std::unique_ptr<CachedTokens> Toks;
1445 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1446 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1447 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1449 void ParseLexedMethodDeclarations()
override;
1461 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1471 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1472 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1475 void ParseLexedMemberInitializers()
override;
1493 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1498 struct ParsingClass {
1499 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1500 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1501 TagOrTemplate(TagOrTemplate) {}
1505 bool TopLevelClass : 1;
1508 bool IsInterface : 1;
1511 Decl *TagOrTemplate;
1516 LateParsedDeclarationsContainer LateParsedDeclarations;
1522 std::stack<ParsingClass *> ClassStack;
1524 ParsingClass &getCurrentClass() {
1525 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1526 return *ClassStack.top();
1530 class ParsingClassDefinition {
1536 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1539 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1544 assert(!Popped &&
"Nested class has already been popped");
1546 P.PopParsingClass(State);
1549 ~ParsingClassDefinition() {
1551 P.PopParsingClass(State);
1558 struct ParsedTemplateInfo {
1559 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1562 bool isSpecialization,
1563 bool lastParameterListWasEmpty =
false)
1564 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1565 TemplateParams(TemplateParams),
1566 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1568 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1569 SourceLocation TemplateLoc)
1570 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1571 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1572 LastParameterListWasEmpty(
false){ }
1581 ExplicitSpecialization,
1583 ExplicitInstantiation
1592 SourceLocation ExternLoc;
1596 SourceLocation TemplateLoc;
1599 bool LastParameterListWasEmpty;
1605 struct ReenterTemplateScopeRAII;
1606 struct ReenterClassScopeRAII;
1608 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1609 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1611 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1613 Sema::ParsingClassState
1614 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1615 void DeallocateParsedClasses(ParsingClass *
Class);
1616 void PopParsingClass(Sema::ParsingClassState);
1618 enum CachedInitKind {
1619 CIK_DefaultArgument,
1620 CIK_DefaultInitializer
1624 const ParsedAttributesView &AccessAttrs,
1625 ParsingDeclarator &D,
1626 const ParsedTemplateInfo &TemplateInfo,
1627 const VirtSpecifiers &VS,
1628 SourceLocation PureSpecLoc);
1629 StringLiteral *ParseCXXDeletedFunctionMessage();
1630 void SkipDeletedFunctionBody();
1631 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1632 void ParseLexedAttributes(ParsingClass &
Class);
1633 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1635 void ParseLexedAttribute(LateParsedAttribute &LA,
1637 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1638 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1639 void ParseLexedMethodDefs(ParsingClass &
Class);
1640 void ParseLexedMethodDef(LexedMethod &LM);
1641 void ParseLexedMemberInitializers(ParsingClass &
Class);
1642 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1643 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1644 void ParseLexedPragmas(ParsingClass &
Class);
1645 void ParseLexedPragma(LateParsedPragma &LP);
1646 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1647 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1652 bool ConsumeFinalToken =
true) {
1653 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1658 bool ConsumeFinalToken =
true);
1662 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1663 ParsedAttributes &DeclSpecAttrs,
1664 ParsingDeclSpec *DS =
nullptr);
1665 bool isDeclarationAfterDeclarator();
1666 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1668 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1670 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1671 ParsedAttributes &DeclSpecAttrs,
1672 ParsingDeclSpec &DS,
1675 void SkipFunctionBody();
1676 Decl *ParseFunctionDefinition(ParsingDeclarator &D,
1677 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1678 LateParsedAttrList *LateParsedAttrs =
nullptr);
1679 void ParseKNRParamDeclarations(Declarator &D);
1681 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1682 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1686 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1687 ParsedAttributes &DeclSpecAttrs);
1688 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1689 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1690 ParsedAttributes &prefixAttrs);
1691 class ObjCTypeParamListScope;
1692 ObjCTypeParamList *parseObjCTypeParamList();
1693 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1694 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1695 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1696 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1698 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1699 SourceLocation atLoc,
1701 SmallVectorImpl<Decl *> &AllIvarDecls,
1702 bool RBraceMissing);
1703 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1705 SourceLocation atLoc);
1706 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1707 SmallVectorImpl<SourceLocation> &PLocs,
1708 bool WarnOnDeclarations,
1709 bool ForObjCContainer,
1710 SourceLocation &LAngleLoc,
1711 SourceLocation &EndProtoLoc,
1712 bool consumeLastToken);
1717 void parseObjCTypeArgsOrProtocolQualifiers(
1719 SourceLocation &typeArgsLAngleLoc,
1720 SmallVectorImpl<ParsedType> &typeArgs,
1721 SourceLocation &typeArgsRAngleLoc,
1722 SourceLocation &protocolLAngleLoc,
1723 SmallVectorImpl<Decl *> &protocols,
1724 SmallVectorImpl<SourceLocation> &protocolLocs,
1725 SourceLocation &protocolRAngleLoc,
1726 bool consumeLastToken,
1727 bool warnOnIncompleteProtocols);
1731 void parseObjCTypeArgsAndProtocolQualifiers(
1733 SourceLocation &typeArgsLAngleLoc,
1734 SmallVectorImpl<ParsedType> &typeArgs,
1735 SourceLocation &typeArgsRAngleLoc,
1736 SourceLocation &protocolLAngleLoc,
1737 SmallVectorImpl<Decl *> &protocols,
1738 SmallVectorImpl<SourceLocation> &protocolLocs,
1739 SourceLocation &protocolRAngleLoc,
1740 bool consumeLastToken);
1744 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1748 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1750 bool consumeLastToken,
1751 SourceLocation &endLoc);
1755 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1756 ParsedAttributes &prefixAttrs);
1758 struct ObjCImplParsingDataRAII {
1762 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1763 LateParsedObjCMethodContainer LateParsedObjCMethods;
1765 ObjCImplParsingDataRAII(Parser &parser, Decl *D)
1766 :
P(parser), Dcl(D), HasCFunction(
false) {
1767 P.CurParsedObjCImpl =
this;
1770 ~ObjCImplParsingDataRAII();
1772 void finish(SourceRange AtEnd);
1773 bool isFinished()
const {
return Finished; }
1778 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1779 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1781 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1782 ParsedAttributes &Attrs);
1784 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1785 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1786 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1788 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1791 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1792 objc_nonnull, objc_nullable, objc_null_unspecified,
1795 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1797 bool isTokIdentifier_in()
const;
1800 ParsedAttributes *ParamAttrs);
1801 Decl *ParseObjCMethodPrototype(
1803 bool MethodDefinition =
true);
1806 bool MethodDefinition=
true);
1807 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1809 Decl *ParseObjCMethodDefinition();
1837 unsigned &NumLineToksConsumed,
1838 bool IsUnevaluated);
1854 enum CastParseKind {
1859 ExprResult ParseCastExpression(CastParseKind ParseKind,
1860 bool isAddressOfOperand,
1863 bool isVectorLiteral =
false,
1864 bool *NotPrimaryExpression =
nullptr);
1865 ExprResult ParseCastExpression(CastParseKind ParseKind,
1866 bool isAddressOfOperand =
false,
1868 bool isVectorLiteral =
false,
1869 bool *NotPrimaryExpression =
nullptr);
1872 bool isNotExpressionStart();
1876 bool isPostfixExpressionSuffixStart() {
1878 return (K == tok::l_square || K == tok::l_paren ||
1879 K == tok::period || K == tok::arrow ||
1880 K == tok::plusplus || K == tok::minusminus);
1883 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1884 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1885 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1886 const Token &OpToken);
1887 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1888 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1889 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1894 ExprResult ParseUnaryExprOrTypeTraitExpression();
1896 ExprResult ParseSYCLUniqueStableNameExpression();
1898 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1901 SourceRange &CastRange);
1904 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1905 llvm::function_ref<
void()> ExpressionStarts =
1906 llvm::function_ref<
void()>(),
1907 bool FailImmediatelyOnInvalidExpr =
false,
1908 bool EarlyTypoCorrection =
false);
1912 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1915 enum ParenParseOption {
1922 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1923 bool stopIfCastExpr,
1926 SourceLocation &RParenLoc);
1929 ParenParseOption &ExprType,
ParsedType &CastTy,
1932 SourceLocation LParenLoc,
1933 SourceLocation RParenLoc);
1935 ExprResult ParseGenericSelectionExpression();
1943 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1944 Token &Replacement);
1949 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1951 bool areTokensAdjacent(
const Token &A,
const Token &B);
1953 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1954 bool EnteringContext, IdentifierInfo &II,
1957 bool ParseOptionalCXXScopeSpecifier(
1958 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
1959 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
1960 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
1961 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false);
1967 enum class LambdaIntroducerTentativeParse {
1984 ParseLambdaIntroducer(LambdaIntroducer &Intro,
1985 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1986 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
2005 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
2020 SourceRange &SpecificationRange,
2021 SmallVectorImpl<ParsedType> &DynamicExceptions,
2022 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2028 SourceRange &SpecificationRange,
2029 SmallVectorImpl<ParsedType> &Exceptions,
2030 SmallVectorImpl<SourceRange> &Ranges);
2034 TypeResult ParseTrailingReturnType(SourceRange &Range,
2035 bool MayBeFollowedByDirectInit);
2043 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2048 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2050 bool ParseCXXTypeSpecifierSeq(
2055 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2057 void ParseDirectNewDeclarator(Declarator &D);
2058 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2059 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2060 SourceLocation Start);
2064 struct ForRangeInfo;
2065 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2069 ForRangeInfo *FRI =
nullptr,
2070 bool EnterForConditionScope =
false);
2072 ParsedAttributes &Attrs);
2083 void ParseTrailingRequiresClause(Declarator &D);
2093 if (Tok.isNot(tok::l_brace))
2095 return ParseBraceInitializer();
2097 bool MayBeDesignationStart();
2099 struct DesignatorCompletionInfo {
2100 SmallVectorImpl<Expr *> &InitExprs;
2101 QualType PreferredBaseType;
2103 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2112 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2113 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2114 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2115 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2116 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2117 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2118 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2119 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2120 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2121 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2122 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2123 bool isSimpleObjCMessageExpression();
2125 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2126 SourceLocation SuperLoc,
2128 Expr *ReceiverExpr);
2129 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2130 SourceLocation LBracloc, SourceLocation SuperLoc,
2131 ParsedType ReceiverType, Expr *ReceiverExpr);
2132 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2138 typedef SmallVector<Expr*, 12> ExprVector;
2141 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2142 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2144 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2145 SourceLocation *TrailingElseLoc =
nullptr);
2146 StmtResult ParseStatementOrDeclarationAfterAttributes(
2147 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2148 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2149 ParsedAttributes &DeclSpecAttrs);
2150 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2151 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2152 ParsedStmtContext StmtCtx);
2153 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2154 bool MissingCase =
false,
2156 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2157 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2158 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2159 unsigned ScopeFlags);
2160 void ParseCompoundStatementLeadingPragmas();
2161 void DiagnoseLabelAtEndOfCompoundStatement();
2163 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2164 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2165 Sema::ConditionResult &CondResult,
2167 SourceLocation &LParenLoc,
2168 SourceLocation &RParenLoc);
2169 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2170 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2171 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2173 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2179 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2181 SourceLocation *TrailingElseLoc,
2182 ParsedAttributes &Attrs);
2186 enum IfExistsBehavior {
2198 struct IfExistsCondition {
2200 SourceLocation KeywordLoc;
2213 IfExistsBehavior Behavior;
2216 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2217 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2218 void ParseMicrosoftIfExistsExternalDeclaration();
2219 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2220 ParsedAttributes &AccessAttrs,
2222 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2224 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2225 SmallVectorImpl<Expr *> &Constraints,
2226 SmallVectorImpl<Expr *> &Exprs);
2232 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2233 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2239 StmtResult ParseSEHExceptBlock(SourceLocation Loc);
2240 StmtResult ParseSEHFinallyBlock(SourceLocation Loc);
2246 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2247 ParsedStmtContext StmtCtx);
2248 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2249 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2250 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2251 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2260 enum class DeclSpecContext {
2265 DSC_alias_declaration,
2270 DSC_template_type_arg,
2271 DSC_objc_method_result,
2280 static bool isTypeSpecifier(DeclSpecContext DSC) {
2282 case DeclSpecContext::DSC_normal:
2283 case DeclSpecContext::DSC_template_param:
2284 case DeclSpecContext::DSC_template_arg:
2285 case DeclSpecContext::DSC_class:
2286 case DeclSpecContext::DSC_top_level:
2287 case DeclSpecContext::DSC_objc_method_result:
2288 case DeclSpecContext::DSC_condition:
2291 case DeclSpecContext::DSC_template_type_arg:
2292 case DeclSpecContext::DSC_type_specifier:
2293 case DeclSpecContext::DSC_conv_operator:
2294 case DeclSpecContext::DSC_trailing:
2295 case DeclSpecContext::DSC_alias_declaration:
2296 case DeclSpecContext::DSC_association:
2297 case DeclSpecContext::DSC_new:
2300 llvm_unreachable(
"Missing DeclSpecContext case");
2304 enum class AllowDefiningTypeSpec {
2321 static AllowDefiningTypeSpec
2322 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2324 case DeclSpecContext::DSC_normal:
2325 case DeclSpecContext::DSC_class:
2326 case DeclSpecContext::DSC_top_level:
2327 case DeclSpecContext::DSC_alias_declaration:
2328 case DeclSpecContext::DSC_objc_method_result:
2329 return AllowDefiningTypeSpec::Yes;
2331 case DeclSpecContext::DSC_condition:
2332 case DeclSpecContext::DSC_template_param:
2333 return AllowDefiningTypeSpec::YesButInvalid;
2335 case DeclSpecContext::DSC_template_type_arg:
2336 case DeclSpecContext::DSC_type_specifier:
2337 return AllowDefiningTypeSpec::NoButErrorRecovery;
2339 case DeclSpecContext::DSC_association:
2340 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2341 : AllowDefiningTypeSpec::Yes;
2343 case DeclSpecContext::DSC_trailing:
2344 case DeclSpecContext::DSC_conv_operator:
2345 case DeclSpecContext::DSC_template_arg:
2346 case DeclSpecContext::DSC_new:
2347 return AllowDefiningTypeSpec::No;
2349 llvm_unreachable(
"Missing DeclSpecContext case");
2353 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2355 case DeclSpecContext::DSC_normal:
2356 case DeclSpecContext::DSC_class:
2357 case DeclSpecContext::DSC_top_level:
2360 case DeclSpecContext::DSC_alias_declaration:
2361 case DeclSpecContext::DSC_objc_method_result:
2362 case DeclSpecContext::DSC_condition:
2363 case DeclSpecContext::DSC_template_param:
2364 case DeclSpecContext::DSC_template_type_arg:
2365 case DeclSpecContext::DSC_type_specifier:
2366 case DeclSpecContext::DSC_trailing:
2367 case DeclSpecContext::DSC_association:
2368 case DeclSpecContext::DSC_conv_operator:
2369 case DeclSpecContext::DSC_template_arg:
2370 case DeclSpecContext::DSC_new:
2374 llvm_unreachable(
"Missing DeclSpecContext case");
2379 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2381 case DeclSpecContext::DSC_normal:
2382 case DeclSpecContext::DSC_template_param:
2383 case DeclSpecContext::DSC_template_arg:
2384 case DeclSpecContext::DSC_class:
2385 case DeclSpecContext::DSC_top_level:
2386 case DeclSpecContext::DSC_condition:
2387 case DeclSpecContext::DSC_type_specifier:
2388 case DeclSpecContext::DSC_association:
2389 case DeclSpecContext::DSC_conv_operator:
2390 case DeclSpecContext::DSC_new:
2393 case DeclSpecContext::DSC_objc_method_result:
2394 case DeclSpecContext::DSC_template_type_arg:
2395 case DeclSpecContext::DSC_trailing:
2396 case DeclSpecContext::DSC_alias_declaration:
2399 llvm_unreachable(
"Missing DeclSpecContext case");
2404 getImplicitTypenameContext(DeclSpecContext DSC) {
2406 case DeclSpecContext::DSC_class:
2407 case DeclSpecContext::DSC_top_level:
2408 case DeclSpecContext::DSC_type_specifier:
2409 case DeclSpecContext::DSC_template_type_arg:
2410 case DeclSpecContext::DSC_trailing:
2411 case DeclSpecContext::DSC_alias_declaration:
2412 case DeclSpecContext::DSC_template_param:
2413 case DeclSpecContext::DSC_new:
2416 case DeclSpecContext::DSC_normal:
2417 case DeclSpecContext::DSC_objc_method_result:
2418 case DeclSpecContext::DSC_condition:
2419 case DeclSpecContext::DSC_template_arg:
2420 case DeclSpecContext::DSC_conv_operator:
2421 case DeclSpecContext::DSC_association:
2424 llvm_unreachable(
"Missing DeclSpecContext case");
2429 struct ForRangeInit {
2430 SourceLocation ColonLoc;
2432 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2433 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2435 struct ForRangeInfo : ForRangeInit {
2440 SourceLocation &DeclEnd,
2441 ParsedAttributes &DeclAttrs,
2442 ParsedAttributes &DeclSpecAttrs,
2443 SourceLocation *DeclSpecStart =
nullptr);
2446 ParsedAttributes &DeclAttrs,
2447 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2448 ForRangeInit *FRI =
nullptr,
2449 SourceLocation *DeclSpecStart =
nullptr);
2452 ParsedAttributes &Attrs,
2453 ParsedTemplateInfo &TemplateInfo,
2454 SourceLocation *DeclEnd =
nullptr,
2455 ForRangeInit *FRI =
nullptr);
2456 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2457 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2458 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2459 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2461 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2462 ForRangeInit *FRI =
nullptr);
2463 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2464 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2470 bool trySkippingFunctionBody();
2472 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2473 const ParsedTemplateInfo &TemplateInfo,
2475 ParsedAttributes &Attrs);
2478 void ParseDeclarationSpecifiers(
2480 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2482 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2483 LateParsedAttrList *LateAttrs =
nullptr) {
2484 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2485 getImplicitTypenameContext(DSC));
2487 void ParseDeclarationSpecifiers(
2488 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS,
2489 DeclSpecContext DSC, LateParsedAttrList *LateAttrs,
2492 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2493 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2494 SourceLocation StartLoc,
2495 SourceLocation EndLoc);
2497 bool DiagnoseMissingSemiAfterTagDefinition(
2499 LateParsedAttrList *LateAttrs =
nullptr);
2501 void ParseSpecifierQualifierList(
2503 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2504 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2507 void ParseSpecifierQualifierList(
2510 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2512 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2515 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2516 const ParsedTemplateInfo &TemplateInfo,
2518 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2519 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2520 RecordDecl *TagDecl);
2522 void ParseStructDeclaration(
2523 ParsingDeclSpec &DS,
2524 llvm::function_ref<
void(ParsingFieldDeclarator &)> FieldsCallback);
2529 bool DisambiguatingWithExpression =
false);
2530 bool isTypeSpecifierQualifier();
2535 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2540 bool isKnownToBeDeclarationSpecifier() {
2553 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2555 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2563 bool isForInitDeclaration() {
2567 return Tok.is(tok::kw_using) ||
2568 isCXXSimpleDeclaration(
true);
2573 bool isForRangeIdentifier();
2577 bool isStartOfObjCClassMessageMissingOpenBracket();
2582 bool isConstructorDeclarator(
2585 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2589 enum TentativeCXXTypeIdContext {
2592 TypeIdAsTemplateArgument,
2593 TypeIdInTrailingReturnType,
2594 TypeIdAsGenericSelectionArgument,
2600 bool isTypeIdInParens(
bool &isAmbiguous) {
2602 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2603 isAmbiguous =
false;
2604 return isTypeSpecifierQualifier();
2606 bool isTypeIdInParens() {
2608 return isTypeIdInParens(isAmbiguous);
2618 bool isTypeIdForGenericSelection() {
2621 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2623 return isTypeSpecifierQualifier();
2629 bool isTypeIdUnambiguously() {
2632 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2634 return isTypeSpecifierQualifier();
2640 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2647 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2656 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2660 struct ConditionDeclarationOrInitStatementState;
2661 enum class ConditionOrInitStatement {
2671 ConditionOrInitStatement
2672 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2673 bool CanBeForRangeDecl);
2675 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2676 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2678 return isCXXTypeId(Context, isAmbiguous);
2683 enum class TPResult {
2684 True, False, Ambiguous,
Error
2694 bool isEnumBase(
bool AllowSemi);
2705 TPResult BracedCastResult = TPResult::False,
2706 bool *InvalidAsDeclSpec =
nullptr);
2711 bool isCXXDeclarationSpecifierAType();
2716 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2721 TPResult isExplicitBool();
2726 bool isTentativelyDeclared(IdentifierInfo *II);
2735 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2736 TPResult TryParseTypeofSpecifier();
2737 TPResult TryParseProtocolQualifiers();
2738 TPResult TryParsePtrOperatorSeq();
2739 TPResult TryParseOperatorId();
2740 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2741 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2742 bool mayHaveDirectInit =
false,
2743 bool mayHaveTrailingReturnType =
false);
2744 TPResult TryParseParameterDeclarationClause(
2745 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2748 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2749 bool NameAfterArrowIsNonType();
2750 TPResult TryParseBracketDeclarator();
2751 TPResult TryConsumeDeclarationSpecifier();
2755 bool TrySkipAttributes();
2759 void DiagnoseBitIntUse(
const Token &Tok);
2766 ParsedAttributes *Attrs =
nullptr);
2769 void ParseBlockId(SourceLocation CaretLoc);
2776 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2777 bool OuterMightBeMessageSend =
false) {
2778 return (Tok.isRegularKeywordAttribute() ||
2779 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2784 bool CheckProhibitedCXX11Attribute() {
2785 assert(Tok.is(tok::l_square));
2788 return DiagnoseProhibitedCXX11Attribute();
2791 bool DiagnoseProhibitedCXX11Attribute();
2792 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2793 SourceLocation CorrectLocation) {
2794 if (!Tok.isRegularKeywordAttribute() &&
2795 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2796 Tok.isNot(tok::kw_alignas))
2798 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2800 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2801 SourceLocation CorrectLocation);
2803 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2807 void ProhibitAttributes(ParsedAttributes &Attrs,
2808 SourceLocation FixItLoc = SourceLocation()) {
2809 if (Attrs.Range.isInvalid())
2811 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2815 void ProhibitAttributes(ParsedAttributesView &Attrs,
2816 SourceLocation FixItLoc = SourceLocation()) {
2817 if (Attrs.Range.isInvalid())
2819 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2820 Attrs.clearListOnly();
2822 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2823 SourceLocation FixItLoc);
2831 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2832 unsigned KeywordDiagId,
2833 bool DiagnoseEmptyAttrs =
false,
2834 bool WarnOnUnknownAttrs =
false);
2839 SourceLocation SkipCXX11Attributes();
2843 void DiagnoseAndSkipCXX11Attributes();
2847 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2849 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2853 SmallVectorImpl<Expr *> &Exprs,
2854 ParsedAttributeArgumentsProperties ArgsProperties);
2861 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2862 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2863 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2864 ParsedAttr::Form Form);
2866 enum ParseAttrKindMask {
2868 PAKM_Declspec = 1 << 1,
2869 PAKM_CXX11 = 1 << 2,
2886 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2887 LateParsedAttrList *LateAttrs =
nullptr);
2890 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2891 LateParsedAttrList *LateAttrs =
nullptr) {
2892 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2893 isAllowedCXX11AttributeSpecifier()) {
2894 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2900 void MaybeParseGNUAttributes(Declarator &D,
2901 LateParsedAttrList *LateAttrs =
nullptr) {
2902 if (Tok.is(tok::kw___attribute)) {
2903 ParsedAttributes Attrs(AttrFactory);
2904 ParseGNUAttributes(Attrs, LateAttrs, &D);
2905 D.takeAttributes(Attrs);
2909 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2910 LateParsedAttrList *LateAttrs =
nullptr) {
2911 if (Tok.is(tok::kw___attribute)) {
2912 ParseGNUAttributes(Attrs, LateAttrs);
2918 void ParseGNUAttributes(ParsedAttributes &Attrs,
2919 LateParsedAttrList *LateAttrs =
nullptr,
2920 Declarator *D =
nullptr);
2921 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2922 SourceLocation AttrNameLoc,
2923 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2924 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2925 ParsedAttr::Form Form, Declarator *D);
2926 IdentifierLoc *ParseIdentifierLoc();
2929 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2930 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2931 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2932 ParsedAttr::Form Form);
2934 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2937 if (!OpenMPTokens.empty()) {
2939 PP.EnterTokenStream(OpenMPTokens,
true,
2944 void MaybeParseCXX11Attributes(Declarator &D) {
2945 if (isAllowedCXX11AttributeSpecifier()) {
2946 ParsedAttributes Attrs(AttrFactory);
2947 ParseCXX11Attributes(Attrs);
2948 D.takeAttributes(Attrs);
2952 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2953 bool OuterMightBeMessageSend =
false) {
2954 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2955 ParseCXX11Attributes(Attrs);
2961 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
2964 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2966 SourceLocation *EndLoc =
nullptr);
2967 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2968 SourceLocation *EndLoc =
nullptr) {
2970 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2971 ReplayOpenMPAttributeTokens(OpenMPTokens);
2973 void ParseCXX11Attributes(ParsedAttributes &attrs);
2976 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
2977 SourceLocation AttrNameLoc,
2978 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2979 IdentifierInfo *ScopeName,
2980 SourceLocation ScopeLoc,
2984 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
2985 IdentifierInfo *AttrName,
2986 SourceLocation AttrNameLoc,
2987 SourceLocation *EndLoc);
2989 IdentifierInfo *TryParseCXX11AttributeIdentifier(
2990 SourceLocation &Loc,
2992 const IdentifierInfo *EnclosingScope =
nullptr);
2994 void MaybeParseHLSLAnnotations(Declarator &D,
2995 SourceLocation *EndLoc =
nullptr) {
2996 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
2997 if (Tok.is(tok::colon)) {
2998 ParsedAttributes Attrs(AttrFactory);
2999 ParseHLSLAnnotations(Attrs, EndLoc);
3000 D.takeAttributes(Attrs);
3004 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
3005 SourceLocation *EndLoc =
nullptr) {
3006 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3008 ParseHLSLAnnotations(Attrs, EndLoc);
3011 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
3012 SourceLocation *EndLoc =
nullptr);
3013 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
3015 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3017 Tok.is(tok::l_square)) {
3018 ParsedAttributes AttrsWithRange(AttrFactory);
3019 ParseMicrosoftAttributes(AttrsWithRange);
3020 Attrs.takeAllFrom(AttrsWithRange);
3023 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3024 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3025 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3026 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3027 ParseMicrosoftDeclSpecs(Attrs);
3032 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3033 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3034 SourceLocation AttrNameLoc,
3035 ParsedAttributes &Attrs);
3036 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3037 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3038 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3039 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3040 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3041 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3042 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3043 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3044 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3045 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3046 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3047 bool isHLSLQualifier(
const Token &Tok)
const;
3048 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3050 VersionTuple ParseVersionTuple(SourceRange &Range);
3051 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3052 SourceLocation AvailabilityLoc,
3053 ParsedAttributes &attrs,
3054 SourceLocation *endLoc,
3055 IdentifierInfo *ScopeName,
3056 SourceLocation ScopeLoc,
3057 ParsedAttr::Form Form);
3059 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3060 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3062 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3064 ParsedAttributes &Attrs,
3065 SourceLocation *EndLoc,
3066 IdentifierInfo *ScopeName,
3067 SourceLocation ScopeLoc,
3068 ParsedAttr::Form Form);
3070 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3071 SourceLocation ObjCBridgeRelatedLoc,
3072 ParsedAttributes &Attrs,
3073 SourceLocation *EndLoc,
3074 IdentifierInfo *ScopeName,
3075 SourceLocation ScopeLoc,
3076 ParsedAttr::Form Form);
3078 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3079 SourceLocation AttrNameLoc,
3080 ParsedAttributes &Attrs,
3081 SourceLocation *EndLoc,
3082 IdentifierInfo *ScopeName,
3083 SourceLocation ScopeLoc,
3084 ParsedAttr::Form Form);
3086 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3087 SourceLocation AttrNameLoc,
3088 ParsedAttributes &Attrs,
3089 SourceLocation *EndLoc,
3090 IdentifierInfo *ScopeName,
3091 SourceLocation ScopeLoc,
3092 ParsedAttr::Form Form);
3094 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3095 SourceLocation AttrNameLoc,
3096 ParsedAttributes &Attrs,
3097 IdentifierInfo *ScopeName,
3098 SourceLocation ScopeLoc,
3099 ParsedAttr::Form Form);
3101 void ParseBoundsAttribute(IdentifierInfo &AttrName,
3102 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
3103 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3104 ParsedAttr::Form Form);
3106 void ParseTypeofSpecifier(DeclSpec &DS);
3107 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3108 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3109 SourceLocation StartLoc,
3110 SourceLocation EndLoc);
3111 void ParseAtomicSpecifier(DeclSpec &DS);
3113 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3114 SourceLocation &EllipsisLoc,
bool &IsType,
3116 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3117 SourceLocation *endLoc =
nullptr);
3122 return isCXX11VirtSpecifier(Tok);
3124 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3125 SourceLocation FriendLoc);
3127 bool isCXX11FinalKeyword()
const;
3128 bool isClassCompatibleKeyword()
const;
3133 class DeclaratorScopeObj {
3139 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3140 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3142 void EnterDeclaratorScope() {
3143 assert(!EnteredScope &&
"Already entered the scope!");
3144 assert(SS.isSet() &&
"C++ scope was not set!");
3146 CreatedScope =
true;
3149 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3150 EnteredScope =
true;
3153 ~DeclaratorScopeObj() {
3155 assert(SS.isSet() &&
"C++ scope was cleared ?");
3156 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3164 void ParseDeclarator(Declarator &D);
3166 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3167 void ParseDeclaratorInternal(Declarator &D,
3168 DirectDeclParseFunction DirectDeclParser);
3170 enum AttrRequirements {
3171 AR_NoAttributesParsed = 0,
3172 AR_GNUAttributesParsedAndRejected = 1 << 0,
3173 AR_GNUAttributesParsed = 1 << 1,
3174 AR_CXX11AttributesParsed = 1 << 2,
3175 AR_DeclspecAttributesParsed = 1 << 3,
3176 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3177 AR_CXX11AttributesParsed |
3178 AR_DeclspecAttributesParsed,
3179 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3180 AR_DeclspecAttributesParsed
3183 void ParseTypeQualifierListOpt(
3184 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3185 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3186 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3188 void ParseDirectDeclarator(Declarator &D);
3189 void ParseDecompositionDeclarator(Declarator &D);
3190 void ParseParenDeclarator(Declarator &D);
3191 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
3193 bool IsAmbiguous,
bool RequiresArg =
false);
3194 void InitCXXThisScopeForDeclaratorIfRelevant(
3195 const Declarator &D,
const DeclSpec &DS,
3196 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3197 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3198 SourceLocation &RefQualifierLoc);
3199 bool isFunctionDeclaratorIdentifierList();
3200 void ParseFunctionDeclaratorIdentifierList(
3202 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3203 void ParseParameterDeclarationClause(
3204 Declarator &D, ParsedAttributes &attrs,
3205 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3206 SourceLocation &EllipsisLoc) {
3207 return ParseParameterDeclarationClause(
3208 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3209 D.getCXXScopeSpec().isSet() &&
3210 D.isFunctionDeclaratorAFunctionDeclaration());
3212 void ParseParameterDeclarationClause(
3214 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3215 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3217 void ParseBracketDeclarator(Declarator &D);
3218 void ParseMisplacedBracketDeclarator(Declarator &D);
3219 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3226 enum CXX11AttributeKind {
3228 CAK_NotAttributeSpecifier,
3230 CAK_AttributeSpecifier,
3233 CAK_InvalidAttributeSpecifier
3236 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3237 bool OuterMightBeMessageSend =
false);
3239 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3242 SourceLocation &DeclEnd,
3243 SourceLocation InlineLoc = SourceLocation());
3245 struct InnerNamespaceInfo {
3246 SourceLocation NamespaceLoc;
3247 SourceLocation InlineLoc;
3248 SourceLocation IdentLoc;
3249 IdentifierInfo *Ident;
3253 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3254 unsigned int index, SourceLocation &InlineLoc,
3255 ParsedAttributes &attrs,
3258 Decl *ParseExportDeclaration();
3261 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3263 SourceLocation UsingLoc,
3264 SourceLocation &DeclEnd,
3265 ParsedAttributes &attrs);
3267 struct UsingDeclarator {
3268 SourceLocation TypenameLoc;
3271 SourceLocation EllipsisLoc;
3274 TypenameLoc = EllipsisLoc = SourceLocation();
3282 const ParsedTemplateInfo &TemplateInfo,
3283 SourceLocation UsingLoc,
3284 SourceLocation &DeclEnd,
3285 ParsedAttributes &Attrs,
3287 Decl *ParseAliasDeclarationAfterDeclarator(
3288 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3290 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3292 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3293 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3294 SourceLocation AliasLoc, IdentifierInfo *Alias,
3295 SourceLocation &DeclEnd);
3299 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3300 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3301 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
3303 DeclSpecContext DSC, ParsedAttributes &Attributes);
3304 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3305 SourceLocation AttrFixitLoc,
3308 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3309 SourceLocation AttrFixitLoc,
3310 ParsedAttributes &Attrs,
unsigned TagType,
3312 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3313 SourceLocation &EqualLoc);
3315 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3318 LateParsedAttrList &LateAttrs);
3319 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3320 VirtSpecifiers &VS);
3323 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
3324 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3327 ParsedAttributes &AccessAttrs,
3329 void ParseConstructorInitializer(Decl *ConstructorDecl);
3331 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3336 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3337 SourceLocation &EndLocation);
3338 void ParseBaseClause(Decl *ClassDecl);
3339 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3342 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3344 bool ObjectHadErrors,
3345 SourceLocation TemplateKWLoc,
3346 IdentifierInfo *Name,
3347 SourceLocation NameLoc,
3348 bool EnteringContext,
3350 bool AssumeTemplateId);
3351 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3360 SourceLocation Loc);
3364 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3365 llvm::omp::TraitSet
Set,
3366 llvm::omp::TraitSelector Selector,
3367 llvm::StringMap<SourceLocation> &Seen);
3370 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3371 llvm::omp::TraitSet
Set,
3372 llvm::StringMap<SourceLocation> &Seen);
3375 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3376 llvm::StringMap<SourceLocation> &Seen);
3379 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3380 llvm::omp::TraitSet
Set,
3381 llvm::StringMap<SourceLocation> &Seen);
3384 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3385 llvm::omp::TraitSet
Set,
3386 llvm::StringMap<SourceLocation> &SeenSelectors);
3389 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3390 llvm::StringMap<SourceLocation> &SeenSets);
3393 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
3396 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3400 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
3401 OMPTraitInfo *ParentTI);
3405 SourceLocation Loc);
3409 SourceLocation Loc);
3412 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
3420 SmallVectorImpl<clang::OMPClause *> &Clauses,
3421 SourceLocation Loc);
3424 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
3429 SourceLocation Loc);
3442 SourceLocation MatchingLoc,
3443 SourceLocation FoundLoc,
3444 bool SkipUntilOpenMPEnd);
3450 Decl *TagDecl =
nullptr);
3455 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3460 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
3461 DeclarationName &Name,
3466 bool tryParseOpenMPArrayShapingCastPart();
3475 bool ParseOpenMPSimpleVarList(
3477 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3479 bool AllowScopeSpecifier);
3485 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3486 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3514 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
3529 OMPClause *ParseOpenMPSizesClause();
3537 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3558 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3566 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3573 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3580 bool IsAddressOfOperand =
false);
3584 SemaOpenMP::OpenMPVarListDataTy &
Data,
3585 const LangOptions &LangOpts);
3588 SmallVectorImpl<Expr *> &Vars,
3589 SemaOpenMP::OpenMPVarListDataTy &
Data);
3591 bool ObjectHadErrors,
bool EnteringContext,
3592 bool AllowDestructorName,
bool AllowConstructorName,
3593 bool AllowDeductionGuide,
3594 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3617 struct OpenACCDirectiveParseInfo {
3619 SourceLocation StartLoc;
3620 SourceLocation EndLoc;
3621 SmallVector<OpenACCClause *> Clauses;
3628 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
3634 using OpenACCClauseParseResult =
3635 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
3637 OpenACCClauseParseResult OpenACCCanContinue();
3638 OpenACCClauseParseResult OpenACCCannotContinue();
3639 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
3643 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3647 void ParseOpenACCCacheVarList();
3649 bool ParseOpenACCVar();
3655 OpenACCClauseParseResult
3656 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
3658 SourceLocation ClauseLoc);
3661 OpenACCClauseParseResult
3662 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
3665 SmallVector<OpenACCClause *>
3667 bool ParseOpenACCWaitArgument(SourceLocation Loc,
bool IsDirective);
3675 using OpenACCIntExprParseResult =
3676 std::pair<ExprResult, OpenACCParseCanContinue>;
3681 SourceLocation Loc);
3688 bool ParseOpenACCDeviceTypeList();
3693 bool ParseOpenACCSizeExpr();
3695 bool ParseOpenACCSizeExprList();
3697 bool ParseOpenACCGangArgList(SourceLocation GangLoc);
3699 bool ParseOpenACCGangArg(SourceLocation GangLoc);
3710 SourceLocation &DeclEnd,
3711 ParsedAttributes &AccessAttrs);
3717 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3719 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3720 SmallVectorImpl<NamedDecl *> &TemplateParams,
3721 SourceLocation &LAngleLoc,
3722 SourceLocation &RAngleLoc);
3723 bool ParseTemplateParameterList(
unsigned Depth,
3724 SmallVectorImpl<NamedDecl*> &TemplateParams);
3725 TPResult isStartOfTemplateTypeParameter();
3726 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3727 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3728 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3729 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3730 bool isTypeConstraintAnnotation();
3731 bool TryAnnotateTypeConstraint();
3732 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3733 SourceLocation CorrectLoc,
3734 bool AlreadyHasEllipsis,
3735 bool IdentifierHasName);
3736 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3739 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3741 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3742 SourceLocation &RAngleLoc,
3743 bool ConsumeLastToken,
3744 bool ObjCGenericList);
3745 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3746 SourceLocation &LAngleLoc,
3747 TemplateArgList &TemplateArgs,
3748 SourceLocation &RAngleLoc,
3753 SourceLocation TemplateKWLoc,
3754 UnqualifiedId &TemplateName,
3755 bool AllowTypeAnnotation =
true,
3756 bool TypeConstraint =
false);
3758 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3760 bool IsClassName =
false);
3761 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3762 TemplateTy Template, SourceLocation OpenLoc);
3763 ParsedTemplateArgument ParseTemplateTemplateArgument();
3764 ParsedTemplateArgument ParseTemplateArgument();
3766 SourceLocation ExternLoc,
3767 SourceLocation TemplateLoc,
3768 SourceLocation &DeclEnd,
3769 ParsedAttributes &AccessAttrs,
3773 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3774 SourceLocation &DeclEnd);
3785 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3786 SourceLocation IncludeLoc);
3791 Decl *ParseModuleImport(SourceLocation AtLoc,
3793 bool parseMisplacedModuleImport();
3794 bool tryParseMisplacedModuleImport() {
3796 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3797 Kind == tok::annot_module_include)
3798 return parseMisplacedModuleImport();
3802 bool ParseModuleName(
3803 SourceLocation UseLoc,
3804 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
3818 void CodeCompleteDirective(
bool InConditional)
override;
3819 void CodeCompleteInConditionalExclusion()
override;
3820 void CodeCompleteMacroName(
bool IsDefinition)
override;
3821 void CodeCompletePreprocessorExpression()
override;
3822 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3823 unsigned ArgumentIndex)
override;
3824 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3825 void CodeCompleteNaturalLanguage()
override;
3827 class GNUAsmQualifiers {
3828 unsigned Qualifiers = AQ_unspecified;
3837 static const char *getQualifierName(AQ Qualifier);
3838 bool setAsmQualifier(AQ Qualifier);
3839 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3840 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3841 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3843 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3844 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3845 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3846 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