13#ifndef LLVM_CLANG_PARSE_PARSER_H
14#define LLVM_CLANG_PARSE_PARSER_H
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/Frontend/OpenMP/OMPContext.h"
26#include "llvm/Support/SaveAndRestore.h"
33 class BalancedDelimiterTracker;
34 class CorrectionCandidateCallback;
36 class DiagnosticBuilder;
39 class ParsingDeclRAIIObject;
40 class ParsingDeclSpec;
41 class ParsingDeclarator;
42 class ParsingFieldDeclarator;
43 class ColonProtectionRAIIObject;
44 class InMessageExpressionRAIIObject;
45 class PoisonSEHIdentifiersRAIIObject;
48 class ObjCTypeParamList;
49 struct OMPTraitProperty;
50 struct OMPTraitSelector;
85 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
86 unsigned short MisplacedModuleBeginCount = 0;
95 enum { ScopeCacheSize = 16 };
96 unsigned NumCachedScopes;
97 Scope *ScopeCache[ScopeCacheSize];
103 *Ident___exception_code,
104 *Ident_GetExceptionCode;
107 *Ident___exception_info,
108 *Ident_GetExceptionInfo;
111 *Ident___abnormal_termination,
112 *Ident_AbnormalTermination;
161 *Ident_generated_declaration, *Ident_USR;
174 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
176 std::unique_ptr<PragmaHandler> AlignHandler;
177 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
178 std::unique_ptr<PragmaHandler> OptionsHandler;
179 std::unique_ptr<PragmaHandler> PackHandler;
180 std::unique_ptr<PragmaHandler> MSStructHandler;
181 std::unique_ptr<PragmaHandler> UnusedHandler;
182 std::unique_ptr<PragmaHandler> WeakHandler;
183 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
184 std::unique_ptr<PragmaHandler> FPContractHandler;
185 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
186 std::unique_ptr<PragmaHandler> OpenMPHandler;
187 std::unique_ptr<PragmaHandler> OpenACCHandler;
188 std::unique_ptr<PragmaHandler> PCSectionHandler;
189 std::unique_ptr<PragmaHandler> MSCommentHandler;
190 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
191 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
192 std::unique_ptr<PragmaHandler> FloatControlHandler;
193 std::unique_ptr<PragmaHandler> MSPointersToMembers;
194 std::unique_ptr<PragmaHandler> MSVtorDisp;
195 std::unique_ptr<PragmaHandler> MSInitSeg;
196 std::unique_ptr<PragmaHandler> MSDataSeg;
197 std::unique_ptr<PragmaHandler> MSBSSSeg;
198 std::unique_ptr<PragmaHandler> MSConstSeg;
199 std::unique_ptr<PragmaHandler> MSCodeSeg;
200 std::unique_ptr<PragmaHandler> MSSection;
201 std::unique_ptr<PragmaHandler> MSStrictGuardStackCheck;
202 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
203 std::unique_ptr<PragmaHandler> MSIntrinsic;
204 std::unique_ptr<PragmaHandler> MSFunction;
205 std::unique_ptr<PragmaHandler> MSOptimize;
206 std::unique_ptr<PragmaHandler> MSFenvAccess;
207 std::unique_ptr<PragmaHandler> MSAllocText;
208 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
209 std::unique_ptr<PragmaHandler> OptimizeHandler;
210 std::unique_ptr<PragmaHandler> LoopHintHandler;
211 std::unique_ptr<PragmaHandler> UnrollHintHandler;
212 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
213 std::unique_ptr<PragmaHandler> UnrollAndJamHintHandler;
214 std::unique_ptr<PragmaHandler> NoUnrollAndJamHintHandler;
215 std::unique_ptr<PragmaHandler> FPHandler;
216 std::unique_ptr<PragmaHandler> STDCFenvAccessHandler;
217 std::unique_ptr<PragmaHandler> STDCFenvRoundHandler;
218 std::unique_ptr<PragmaHandler> STDCCXLIMITHandler;
219 std::unique_ptr<PragmaHandler> STDCUnknownHandler;
220 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
221 std::unique_ptr<PragmaHandler> MaxTokensHerePragmaHandler;
222 std::unique_ptr<PragmaHandler> MaxTokensTotalPragmaHandler;
223 std::unique_ptr<PragmaHandler> RISCVPragmaHandler;
225 std::unique_ptr<CommentHandler> CommentSemaHandler;
231 bool GreaterThanIsOperator;
240 bool OpenMPDirectiveParsing =
false;
243 bool OpenACCDirectiveParsing =
false;
247 bool AllowOpenACCArraySections =
false;
251 class OpenACCArraySectionRAII {
255 OpenACCArraySectionRAII(
Parser &P) :
P(
P) {
256 assert(!
P.AllowOpenACCArraySections);
257 P.AllowOpenACCArraySections =
true;
259 ~OpenACCArraySectionRAII() {
260 assert(
P.AllowOpenACCArraySections);
261 P.AllowOpenACCArraySections =
false;
270 bool InMessageExpression;
275 bool CalledSignatureHelp =
false;
280 unsigned TemplateParameterDepth;
286 class TemplateParameterDepthRAII {
288 unsigned AddedLevels;
290 explicit TemplateParameterDepthRAII(
unsigned &Depth)
291 : Depth(Depth), AddedLevels(0) {}
293 ~TemplateParameterDepthRAII() {
294 Depth -= AddedLevels;
301 void addDepth(
unsigned D) {
305 void setAddedDepth(
unsigned D) {
306 Depth = Depth - AddedLevels + D;
310 unsigned getDepth()
const {
return Depth; }
311 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
315 AttributeFactory AttrFactory;
319 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
325 bool DelayTemplateIdDestruction =
false;
327 void MaybeDestroyTemplateIds() {
328 if (DelayTemplateIdDestruction)
330 if (!TemplateIds.empty() &&
332 DestroyTemplateIds();
334 void DestroyTemplateIds();
338 struct DestroyTemplateIdAnnotationsRAIIObj {
341 DestroyTemplateIdAnnotationsRAIIObj(Parser &Self) : Self(Self) {}
342 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
345 struct DelayTemplateIdDestructionRAII {
347 bool PrevDelayTemplateIdDestruction;
349 DelayTemplateIdDestructionRAII(Parser &Self,
350 bool DelayTemplateIdDestruction) noexcept
352 PrevDelayTemplateIdDestruction(Self.DelayTemplateIdDestruction) {
353 Self.DelayTemplateIdDestruction = DelayTemplateIdDestruction;
356 ~DelayTemplateIdDestructionRAII() noexcept {
357 Self.DelayTemplateIdDestruction = PrevDelayTemplateIdDestruction;
362 SmallVector<const IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
374 struct AngleBracketTracker {
384 SpaceBeforeLess = 0x0,
386 NoSpaceBeforeLess = 0x1,
417 if (!Locs.empty() && Locs.back().isActive(
P)) {
418 if (Locs.back().Priority <= Prio) {
420 Locs.back().LessLoc = LessLoc;
421 Locs.back().Priority = Prio;
424 Locs.push_back({TemplateName, LessLoc, Prio,
425 P.ParenCount,
P.BracketCount,
P.BraceCount});
432 void clear(Parser &
P) {
433 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
439 Loc *getCurrent(Parser &
P) {
440 if (!Locs.empty() && Locs.back().isActive(
P))
446 AngleBracketTracker AngleBrackets;
448 IdentifierInfo *getSEHExceptKeyword();
455 bool ParsingInObjCContainer;
461 bool SkipFunctionBodies;
466 SourceLocation ExprStatementTokLoc;
469 enum class ParsedStmtContext {
471 AllowStandaloneOpenMPDirectives = 0x1,
478 Compound = AllowStandaloneOpenMPDirectives,
489 Parser(Preprocessor &PP, Sema &Actions,
bool SkipFunctionBodies);
546 assert(!isTokenSpecial() &&
547 "Should consume special tokens with Consume*Token");
550 return PrevTokLocation;
556 assert(!isTokenSpecial() &&
557 "Should consume special tokens with Consume*Token");
566 Loc = PrevTokLocation;
575 return ConsumeParen();
576 if (isTokenBracket())
577 return ConsumeBracket();
579 return ConsumeBrace();
580 if (isTokenStringLiteral())
581 return ConsumeStringToken();
582 if (Tok.
is(tok::code_completion))
583 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
584 : handleUnexpectedCodeCompletionToken();
586 return ConsumeAnnotationToken();
607 bool isTokenParen()
const {
608 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
611 bool isTokenBracket()
const {
612 return Tok.
isOneOf(tok::l_square, tok::r_square);
615 bool isTokenBrace()
const {
616 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
619 bool isTokenStringLiteral()
const {
623 bool isTokenSpecial()
const {
624 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
625 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
630 bool isTokenEqualOrEqualTypo();
634 void UnconsumeToken(Token &Consumed) {
641 SourceLocation ConsumeAnnotationToken() {
651 SourceLocation ConsumeParen() {
652 assert(isTokenParen() &&
"wrong consume method");
653 if (Tok.
getKind() == tok::l_paren)
655 else if (ParenCount) {
656 AngleBrackets.clear(*
this);
661 return PrevTokLocation;
666 SourceLocation ConsumeBracket() {
667 assert(isTokenBracket() &&
"wrong consume method");
668 if (Tok.
getKind() == tok::l_square)
670 else if (BracketCount) {
671 AngleBrackets.clear(*
this);
677 return PrevTokLocation;
682 SourceLocation ConsumeBrace() {
683 assert(isTokenBrace() &&
"wrong consume method");
684 if (Tok.
getKind() == tok::l_brace)
686 else if (BraceCount) {
687 AngleBrackets.clear(*
this);
693 return PrevTokLocation;
700 SourceLocation ConsumeStringToken() {
701 assert(isTokenStringLiteral() &&
702 "Should only consume string literals with this method");
705 return PrevTokLocation;
713 SourceLocation ConsumeCodeCompletionToken() {
714 assert(Tok.
is(tok::code_completion));
717 return PrevTokLocation;
725 SourceLocation handleUnexpectedCodeCompletionToken();
729 void cutOffParsing() {
740 return Kind == tok::eof ||
Kind == tok::annot_module_begin ||
741 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include ||
742 Kind == tok::annot_repl_input_end;
752 void initializePragmaHandlers();
755 void resetPragmaHandlers();
758 void HandlePragmaUnused();
762 void HandlePragmaVisibility();
766 void HandlePragmaPack();
770 void HandlePragmaMSStruct();
772 void HandlePragmaMSPointersToMembers();
774 void HandlePragmaMSVtorDisp();
776 void HandlePragmaMSPragma();
777 bool HandlePragmaMSSection(StringRef PragmaName,
778 SourceLocation PragmaLocation);
779 bool HandlePragmaMSSegment(StringRef PragmaName,
780 SourceLocation PragmaLocation);
781 bool HandlePragmaMSInitSeg(StringRef PragmaName,
782 SourceLocation PragmaLocation);
783 bool HandlePragmaMSStrictGuardStackCheck(StringRef PragmaName,
784 SourceLocation PragmaLocation);
785 bool HandlePragmaMSFunction(StringRef PragmaName,
786 SourceLocation PragmaLocation);
787 bool HandlePragmaMSAllocText(StringRef PragmaName,
788 SourceLocation PragmaLocation);
789 bool HandlePragmaMSOptimize(StringRef PragmaName,
790 SourceLocation PragmaLocation);
794 void HandlePragmaAlign();
798 void HandlePragmaDump();
802 void HandlePragmaWeak();
806 void HandlePragmaWeakAlias();
810 void HandlePragmaRedefineExtname();
814 void HandlePragmaFPContract();
818 void HandlePragmaFEnvAccess();
822 void HandlePragmaFEnvRound();
826 void HandlePragmaCXLimitedRange();
830 void HandlePragmaFloatControl();
834 void HandlePragmaFP();
838 void HandlePragmaOpenCLExtension();
846 bool HandlePragmaLoopHint(LoopHint &Hint);
848 bool ParsePragmaAttributeSubjectMatchRuleSet(
850 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
852 void HandlePragmaAttribute();
861 const Token &GetLookAheadToken(
unsigned N) {
862 if (N == 0 || Tok.
is(tok::eof))
return Tok;
882 assert((
T.isInvalid() ||
T.get()) &&
883 "produced a valid-but-null type annotation?");
887 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
888 return static_cast<NamedDecl*
>(Tok.getAnnotationValue());
891 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
892 Tok.setAnnotationValue(ND);
895 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
896 return static_cast<IdentifierInfo*
>(Tok.getAnnotationValue());
899 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
900 Tok.setAnnotationValue(ND);
905 static ExprResult getExprAnnotation(
const Token &Tok) {
906 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
911 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
912 Tok.setAnnotationValue(ER.getAsOpaquePointer());
922 CXXScopeSpec &SS,
bool IsNewScope,
928 (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
929 (Tok.is(tok::annot_template_id) &&
931 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
938 enum AnnotatedNameKind {
952 TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr,
957 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
962 bool TryAltiVecToken(DeclSpec &DS, SourceLocation
Loc,
963 const char *&PrevSpec,
unsigned &DiagID,
968 if (Tok.getIdentifierInfo() != Ident_vector &&
969 Tok.getIdentifierInfo() != Ident_bool &&
970 Tok.getIdentifierInfo() != Ident_Bool &&
971 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
974 return TryAltiVecTokenOutOfLine(DS,
Loc, PrevSpec, DiagID,
isInvalid);
980 bool TryAltiVecVectorToken() {
982 Tok.getIdentifierInfo() != Ident_vector)
return false;
983 return TryAltiVecVectorTokenOutOfLine();
986 bool TryAltiVecVectorTokenOutOfLine();
987 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation
Loc,
988 const char *&PrevSpec,
unsigned &DiagID,
994 bool isObjCInstancetype() {
996 if (Tok.isAnnotation())
998 if (!Ident_instancetype)
1000 return Tok.getIdentifierInfo() == Ident_instancetype;
1008 bool TryKeywordIdentFallback(
bool DisableKeyword);
1011 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
1024 class TentativeParsingAction {
1026 PreferredTypeBuilder PrevPreferredType;
1028 size_t PrevTentativelyDeclaredIdentifierCount;
1029 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
1033 explicit TentativeParsingAction(Parser &p)
1034 :
P(p), PrevPreferredType(
P.PreferredType) {
1036 PrevTentativelyDeclaredIdentifierCount =
1037 P.TentativelyDeclaredIdentifiers.size();
1038 PrevParenCount =
P.ParenCount;
1039 PrevBracketCount =
P.BracketCount;
1040 PrevBraceCount =
P.BraceCount;
1041 P.PP.EnableBacktrackAtThisPos();
1045 assert(isActive &&
"Parsing action was finished!");
1046 P.TentativelyDeclaredIdentifiers.resize(
1047 PrevTentativelyDeclaredIdentifierCount);
1048 P.PP.CommitBacktrackedTokens();
1052 assert(isActive &&
"Parsing action was finished!");
1054 P.PreferredType = PrevPreferredType;
1056 P.TentativelyDeclaredIdentifiers.resize(
1057 PrevTentativelyDeclaredIdentifierCount);
1058 P.ParenCount = PrevParenCount;
1059 P.BracketCount = PrevBracketCount;
1060 P.BraceCount = PrevBraceCount;
1063 ~TentativeParsingAction() {
1064 assert(!isActive &&
"Forgot to call Commit or Revert!");
1069 class RevertingTentativeParsingAction
1070 :
private Parser::TentativeParsingAction {
1072 RevertingTentativeParsingAction(Parser &P)
1073 : Parser::TentativeParsingAction(
P) {}
1074 ~RevertingTentativeParsingAction() { Revert(); }
1077 class UnannotatedTentativeParsingAction;
1084 ObjCContainerDecl *DC;
1085 SaveAndRestore<bool> WithinObjCContainer;
1087 explicit ObjCDeclContextSwitch(Parser &p)
1089 WithinObjCContainer(
P.ParsingInObjCContainer, DC != nullptr) {
1091 P.Actions.ObjC().ActOnObjCTemporaryExitContainerContext(DC);
1093 ~ObjCDeclContextSwitch() {
1095 P.Actions.ObjC().ActOnObjCReenterContainerContext(DC);
1108 unsigned Diag = diag::err_expected,
1109 StringRef DiagMsg =
"");
1116 bool ExpectAndConsumeSemi(
unsigned DiagID , StringRef TokenUsed =
"");
1119 enum ExtraSemiKind {
1120 OutsideFunction = 0,
1122 InstanceVariableList = 2,
1123 AfterMemberFunctionDefinition = 3
1135 bool expectIdentifier();
1138 enum class CompoundToken {
1153 void checkCompoundToken(SourceLocation FirstTokLoc,
1156 void diagnoseUseOfC11Keyword(
const Token &Tok);
1178 bool BeforeCompoundStmt =
false)
1180 if (EnteredScope && !BeforeCompoundStmt)
1181 Self->EnterScope(ScopeFlags);
1183 if (BeforeCompoundStmt)
1184 Self->incrementMSManglingNumber();
1186 this->Self =
nullptr;
1208 unsigned NumScopes = 0;
1215 Self.EnterScope(ScopeFlags);
1240 class ParseScopeFlags {
1242 unsigned OldFlags = 0;
1243 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1244 void operator=(
const ParseScopeFlags &) =
delete;
1247 ParseScopeFlags(
Parser *
Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1255 DiagnosticBuilder
Diag(SourceLocation
Loc,
unsigned DiagID);
1256 DiagnosticBuilder
Diag(
const Token &Tok,
unsigned DiagID);
1258 return Diag(Tok, DiagID);
1279 static_cast<unsigned>(R));
1321 struct ParsingClass;
1331 class LateParsedDeclaration {
1333 virtual ~LateParsedDeclaration();
1335 virtual void ParseLexedMethodDeclarations();
1336 virtual void ParseLexedMemberInitializers();
1337 virtual void ParseLexedMethodDefs();
1338 virtual void ParseLexedAttributes();
1339 virtual void ParseLexedPragmas();
1344 class LateParsedClass :
public LateParsedDeclaration {
1346 LateParsedClass(
Parser *
P, ParsingClass *
C);
1347 ~LateParsedClass()
override;
1349 void ParseLexedMethodDeclarations()
override;
1350 void ParseLexedMemberInitializers()
override;
1351 void ParseLexedMethodDefs()
override;
1352 void ParseLexedAttributes()
override;
1353 void ParseLexedPragmas()
override;
1357 ParsingClass *
Class;
1366 struct LateParsedAttribute :
public LateParsedDeclaration {
1369 IdentifierInfo &AttrName;
1370 IdentifierInfo *MacroII =
nullptr;
1371 SourceLocation AttrNameLoc;
1372 SmallVector<Decl*, 2> Decls;
1374 explicit LateParsedAttribute(Parser *
P, IdentifierInfo &Name,
1376 : Self(
P), AttrName(Name), AttrNameLoc(
Loc) {}
1378 void ParseLexedAttributes()
override;
1380 void addDecl(Decl *D) { Decls.push_back(D); }
1387 class LateParsedPragma :
public LateParsedDeclaration {
1388 Parser *Self =
nullptr;
1394 : Self(
P), AS(AS) {}
1396 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1400 void ParseLexedPragmas()
override;
1404 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1406 LateParsedAttrList(
bool PSoon =
false,
1407 bool LateAttrParseExperimentalExtOnly =
false)
1409 LateAttrParseExperimentalExtOnly(LateAttrParseExperimentalExtOnly) {}
1411 bool parseSoon() {
return ParseSoon; }
1414 bool lateAttrParseExperimentalExtOnly() {
1415 return LateAttrParseExperimentalExtOnly;
1420 bool LateAttrParseExperimentalExtOnly;
1426 struct LexedMethod :
public LateParsedDeclaration {
1431 explicit LexedMethod(Parser *
P, Decl *MD) : Self(
P), D(MD) {}
1433 void ParseLexedMethodDefs()
override;
1440 struct LateParsedDefaultArgument {
1441 explicit LateParsedDefaultArgument(Decl *
P,
1442 std::unique_ptr<CachedTokens> Toks =
nullptr)
1443 : Param(
P), Toks(
std::move(Toks)) { }
1452 std::unique_ptr<CachedTokens> Toks;
1459 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1460 explicit LateParsedMethodDeclaration(Parser *
P, Decl *M)
1461 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1463 void ParseLexedMethodDeclarations()
override;
1475 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1485 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1486 LateParsedMemberInitializer(Parser *
P, Decl *FD)
1489 void ParseLexedMemberInitializers()
override;
1507 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1512 struct ParsingClass {
1513 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1514 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1515 TagOrTemplate(TagOrTemplate) {}
1519 bool TopLevelClass : 1;
1522 bool IsInterface : 1;
1525 Decl *TagOrTemplate;
1530 LateParsedDeclarationsContainer LateParsedDeclarations;
1536 std::stack<ParsingClass *> ClassStack;
1538 ParsingClass &getCurrentClass() {
1539 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1540 return *ClassStack.top();
1544 class ParsingClassDefinition {
1550 ParsingClassDefinition(Parser &P, Decl *TagOrTemplate,
bool TopLevelClass,
1553 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1558 assert(!Popped &&
"Nested class has already been popped");
1560 P.PopParsingClass(State);
1563 ~ParsingClassDefinition() {
1565 P.PopParsingClass(State);
1572 struct ParsedTemplateInfo {
1573 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1576 bool isSpecialization,
1577 bool lastParameterListWasEmpty =
false)
1578 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1579 TemplateParams(TemplateParams),
1580 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1582 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1583 SourceLocation TemplateLoc)
1584 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1585 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1586 LastParameterListWasEmpty(
false){ }
1595 ExplicitSpecialization,
1597 ExplicitInstantiation
1606 SourceLocation ExternLoc;
1610 SourceLocation TemplateLoc;
1613 bool LastParameterListWasEmpty;
1619 struct ReenterTemplateScopeRAII;
1620 struct ReenterClassScopeRAII;
1622 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1623 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1625 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1627 Sema::ParsingClassState
1628 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1629 void DeallocateParsedClasses(ParsingClass *
Class);
1630 void PopParsingClass(Sema::ParsingClassState);
1632 enum CachedInitKind {
1633 CIK_DefaultArgument,
1634 CIK_DefaultInitializer
1638 const ParsedAttributesView &AccessAttrs,
1639 ParsingDeclarator &D,
1640 const ParsedTemplateInfo &TemplateInfo,
1641 const VirtSpecifiers &VS,
1642 SourceLocation PureSpecLoc);
1643 StringLiteral *ParseCXXDeletedFunctionMessage();
1644 void SkipDeletedFunctionBody();
1645 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1646 void ParseLexedAttributes(ParsingClass &
Class);
1647 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1649 void ParseLexedAttribute(LateParsedAttribute &LA,
1651 void ParseLexedMethodDeclarations(ParsingClass &
Class);
1652 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1653 void ParseLexedMethodDefs(ParsingClass &
Class);
1654 void ParseLexedMethodDef(LexedMethod &LM);
1655 void ParseLexedMemberInitializers(ParsingClass &
Class);
1656 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1657 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1658 void ParseLexedPragmas(ParsingClass &
Class);
1659 void ParseLexedPragma(LateParsedPragma &LP);
1660 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1661 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1666 bool ConsumeFinalToken =
true) {
1667 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1672 bool ConsumeFinalToken =
true);
1676 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributes &DeclAttrs,
1677 ParsedAttributes &DeclSpecAttrs,
1678 ParsingDeclSpec *DS =
nullptr);
1679 bool isDeclarationAfterDeclarator();
1680 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1682 ParsedAttributes &DeclAttrs, ParsedAttributes &DeclSpecAttrs,
1684 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1685 ParsedAttributes &DeclSpecAttrs,
1686 ParsingDeclSpec &DS,
1689 void SkipFunctionBody();
1690 Decl *ParseFunctionDefinition(ParsingDeclarator &D,
1691 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1692 LateParsedAttrList *LateParsedAttrs =
nullptr);
1693 void ParseKNRParamDeclarations(Declarator &D);
1695 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1696 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1700 DeclGroupPtrTy ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
1701 ParsedAttributes &DeclSpecAttrs);
1702 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1703 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1704 ParsedAttributes &prefixAttrs);
1705 class ObjCTypeParamListScope;
1706 ObjCTypeParamList *parseObjCTypeParamList();
1707 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1708 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1709 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1710 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1712 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1713 SourceLocation atLoc,
1715 SmallVectorImpl<Decl *> &AllIvarDecls,
1716 bool RBraceMissing);
1717 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1719 SourceLocation atLoc);
1720 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1721 SmallVectorImpl<SourceLocation> &PLocs,
1722 bool WarnOnDeclarations,
1723 bool ForObjCContainer,
1724 SourceLocation &LAngleLoc,
1725 SourceLocation &EndProtoLoc,
1726 bool consumeLastToken);
1731 void parseObjCTypeArgsOrProtocolQualifiers(
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,
1741 bool warnOnIncompleteProtocols);
1745 void parseObjCTypeArgsAndProtocolQualifiers(
1747 SourceLocation &typeArgsLAngleLoc,
1748 SmallVectorImpl<ParsedType> &typeArgs,
1749 SourceLocation &typeArgsRAngleLoc,
1750 SourceLocation &protocolLAngleLoc,
1751 SmallVectorImpl<Decl *> &protocols,
1752 SmallVectorImpl<SourceLocation> &protocolLocs,
1753 SourceLocation &protocolRAngleLoc,
1754 bool consumeLastToken);
1758 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1762 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1764 bool consumeLastToken,
1765 SourceLocation &endLoc);
1769 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1770 ParsedAttributes &prefixAttrs);
1772 struct ObjCImplParsingDataRAII {
1776 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1777 LateParsedObjCMethodContainer LateParsedObjCMethods;
1779 ObjCImplParsingDataRAII(Parser &parser, Decl *D)
1780 :
P(parser), Dcl(D), HasCFunction(
false) {
1781 P.CurParsedObjCImpl =
this;
1784 ~ObjCImplParsingDataRAII();
1786 void finish(SourceRange AtEnd);
1787 bool isFinished()
const {
return Finished; }
1792 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1793 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1795 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1796 ParsedAttributes &Attrs);
1798 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1799 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1800 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1802 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1805 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1806 objc_nonnull, objc_nullable, objc_null_unspecified,
1809 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1811 bool isTokIdentifier_in()
const;
1814 ParsedAttributes *ParamAttrs);
1815 Decl *ParseObjCMethodPrototype(
1817 bool MethodDefinition =
true);
1820 bool MethodDefinition=
true);
1821 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1823 Decl *ParseObjCMethodDefinition();
1851 unsigned &NumLineToksConsumed,
1852 bool IsUnevaluated);
1868 enum CastParseKind {
1873 ExprResult ParseCastExpression(CastParseKind ParseKind,
1874 bool isAddressOfOperand,
1877 bool isVectorLiteral =
false,
1878 bool *NotPrimaryExpression =
nullptr);
1879 ExprResult ParseCastExpression(CastParseKind ParseKind,
1880 bool isAddressOfOperand =
false,
1882 bool isVectorLiteral =
false,
1883 bool *NotPrimaryExpression =
nullptr);
1886 bool isNotExpressionStart();
1890 bool isPostfixExpressionSuffixStart() {
1892 return (K == tok::l_square || K == tok::l_paren ||
1893 K == tok::period || K == tok::arrow ||
1894 K == tok::plusplus || K == tok::minusminus);
1897 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation
Less);
1898 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1899 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1900 const Token &OpToken);
1901 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1902 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1903 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1908 ExprResult ParseUnaryExprOrTypeTraitExpression();
1910 ExprResult ParseSYCLUniqueStableNameExpression();
1912 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1915 SourceRange &CastRange);
1918 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1919 llvm::function_ref<
void()> ExpressionStarts =
1920 llvm::function_ref<
void()>(),
1921 bool FailImmediatelyOnInvalidExpr =
false,
1922 bool EarlyTypoCorrection =
false);
1926 bool ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs);
1929 enum ParenParseOption {
1936 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1937 bool stopIfCastExpr,
1940 SourceLocation &RParenLoc);
1943 ParenParseOption &ExprType,
ParsedType &CastTy,
1946 SourceLocation LParenLoc,
1947 SourceLocation RParenLoc);
1949 ExprResult ParseGenericSelectionExpression();
1957 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1958 Token &Replacement);
1963 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1965 bool areTokensAdjacent(
const Token &A,
const Token &B);
1967 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1968 bool EnteringContext, IdentifierInfo &II,
1971 bool ParseOptionalCXXScopeSpecifier(
1972 CXXScopeSpec &SS,
ParsedType ObjectType,
bool ObjectHasErrors,
1973 bool EnteringContext,
bool *MayBePseudoDestructor =
nullptr,
1974 bool IsTypename =
false,
const IdentifierInfo **LastII =
nullptr,
1975 bool OnlyNamespace =
false,
bool InUsingDeclaration =
false);
1981 enum class LambdaIntroducerTentativeParse {
1998 ParseLambdaIntroducer(LambdaIntroducer &Intro,
1999 LambdaIntroducerTentativeParse *Tentative =
nullptr);
2000 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
2019 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
2034 SourceRange &SpecificationRange,
2035 SmallVectorImpl<ParsedType> &DynamicExceptions,
2036 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
2042 SourceRange &SpecificationRange,
2043 SmallVectorImpl<ParsedType> &Exceptions,
2044 SmallVectorImpl<SourceRange> &Ranges);
2049 bool MayBeFollowedByDirectInit);
2057 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
2062 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
2064 bool ParseCXXTypeSpecifierSeq(
2069 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
2071 void ParseDirectNewDeclarator(Declarator &D);
2072 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
2073 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
2074 SourceLocation Start);
2078 struct ForRangeInfo;
2079 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
2083 ForRangeInfo *FRI =
nullptr,
2084 bool EnterForConditionScope =
false);
2086 ParsedAttributes &Attrs);
2097 void ParseTrailingRequiresClause(Declarator &D);
2107 if (Tok.isNot(tok::l_brace))
2109 return ParseBraceInitializer();
2111 bool MayBeDesignationStart();
2113 struct DesignatorCompletionInfo {
2114 SmallVectorImpl<Expr *> &InitExprs;
2115 QualType PreferredBaseType;
2117 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2126 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2127 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2128 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2129 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2130 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2131 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2132 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2133 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2134 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2135 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2136 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2137 bool isSimpleObjCMessageExpression();
2139 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2140 SourceLocation SuperLoc,
2142 Expr *ReceiverExpr);
2143 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2144 SourceLocation LBracloc, SourceLocation SuperLoc,
2145 ParsedType ReceiverType, Expr *ReceiverExpr);
2146 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2152 typedef SmallVector<Expr*, 12> ExprVector;
2155 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2156 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2158 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2159 SourceLocation *TrailingElseLoc =
nullptr);
2160 StmtResult ParseStatementOrDeclarationAfterAttributes(
2161 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2162 SourceLocation *TrailingElseLoc, ParsedAttributes &DeclAttrs,
2163 ParsedAttributes &DeclSpecAttrs);
2164 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2165 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2166 ParsedStmtContext StmtCtx);
2167 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2168 bool MissingCase =
false,
2170 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2171 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2172 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2173 unsigned ScopeFlags);
2174 void ParseCompoundStatementLeadingPragmas();
2175 void DiagnoseLabelAtEndOfCompoundStatement();
2177 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2178 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2179 Sema::ConditionResult &CondResult,
2181 SourceLocation &LParenLoc,
2182 SourceLocation &RParenLoc);
2183 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2184 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2185 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2187 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2193 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2195 SourceLocation *TrailingElseLoc,
2196 ParsedAttributes &Attrs);
2200 enum IfExistsBehavior {
2212 struct IfExistsCondition {
2214 SourceLocation KeywordLoc;
2227 IfExistsBehavior Behavior;
2230 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
2231 void ParseMicrosoftIfExistsStatement(
StmtVector &Stmts);
2232 void ParseMicrosoftIfExistsExternalDeclaration();
2233 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2234 ParsedAttributes &AccessAttrs,
2236 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2238 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2239 SmallVectorImpl<Expr *> &Constraints,
2240 SmallVectorImpl<Expr *> &Exprs);
2246 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2247 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2260 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2261 ParsedStmtContext StmtCtx);
2262 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2263 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2264 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2265 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2274 enum class DeclSpecContext {
2279 DSC_alias_declaration,
2284 DSC_template_type_arg,
2285 DSC_objc_method_result,
2294 static bool isTypeSpecifier(DeclSpecContext DSC) {
2296 case DeclSpecContext::DSC_normal:
2297 case DeclSpecContext::DSC_template_param:
2298 case DeclSpecContext::DSC_template_arg:
2299 case DeclSpecContext::DSC_class:
2300 case DeclSpecContext::DSC_top_level:
2301 case DeclSpecContext::DSC_objc_method_result:
2302 case DeclSpecContext::DSC_condition:
2305 case DeclSpecContext::DSC_template_type_arg:
2306 case DeclSpecContext::DSC_type_specifier:
2307 case DeclSpecContext::DSC_conv_operator:
2308 case DeclSpecContext::DSC_trailing:
2309 case DeclSpecContext::DSC_alias_declaration:
2310 case DeclSpecContext::DSC_association:
2311 case DeclSpecContext::DSC_new:
2314 llvm_unreachable(
"Missing DeclSpecContext case");
2318 enum class AllowDefiningTypeSpec {
2335 static AllowDefiningTypeSpec
2336 isDefiningTypeSpecifierContext(DeclSpecContext DSC,
bool IsCPlusPlus) {
2338 case DeclSpecContext::DSC_normal:
2339 case DeclSpecContext::DSC_class:
2340 case DeclSpecContext::DSC_top_level:
2341 case DeclSpecContext::DSC_alias_declaration:
2342 case DeclSpecContext::DSC_objc_method_result:
2343 return AllowDefiningTypeSpec::Yes;
2345 case DeclSpecContext::DSC_condition:
2346 case DeclSpecContext::DSC_template_param:
2347 return AllowDefiningTypeSpec::YesButInvalid;
2349 case DeclSpecContext::DSC_template_type_arg:
2350 case DeclSpecContext::DSC_type_specifier:
2351 return AllowDefiningTypeSpec::NoButErrorRecovery;
2353 case DeclSpecContext::DSC_association:
2354 return IsCPlusPlus ? AllowDefiningTypeSpec::NoButErrorRecovery
2355 : AllowDefiningTypeSpec::Yes;
2357 case DeclSpecContext::DSC_trailing:
2358 case DeclSpecContext::DSC_conv_operator:
2359 case DeclSpecContext::DSC_template_arg:
2360 case DeclSpecContext::DSC_new:
2361 return AllowDefiningTypeSpec::No;
2363 llvm_unreachable(
"Missing DeclSpecContext case");
2367 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2369 case DeclSpecContext::DSC_normal:
2370 case DeclSpecContext::DSC_class:
2371 case DeclSpecContext::DSC_top_level:
2374 case DeclSpecContext::DSC_alias_declaration:
2375 case DeclSpecContext::DSC_objc_method_result:
2376 case DeclSpecContext::DSC_condition:
2377 case DeclSpecContext::DSC_template_param:
2378 case DeclSpecContext::DSC_template_type_arg:
2379 case DeclSpecContext::DSC_type_specifier:
2380 case DeclSpecContext::DSC_trailing:
2381 case DeclSpecContext::DSC_association:
2382 case DeclSpecContext::DSC_conv_operator:
2383 case DeclSpecContext::DSC_template_arg:
2384 case DeclSpecContext::DSC_new:
2388 llvm_unreachable(
"Missing DeclSpecContext case");
2393 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2395 case DeclSpecContext::DSC_normal:
2396 case DeclSpecContext::DSC_template_param:
2397 case DeclSpecContext::DSC_template_arg:
2398 case DeclSpecContext::DSC_class:
2399 case DeclSpecContext::DSC_top_level:
2400 case DeclSpecContext::DSC_condition:
2401 case DeclSpecContext::DSC_type_specifier:
2402 case DeclSpecContext::DSC_association:
2403 case DeclSpecContext::DSC_conv_operator:
2404 case DeclSpecContext::DSC_new:
2407 case DeclSpecContext::DSC_objc_method_result:
2408 case DeclSpecContext::DSC_template_type_arg:
2409 case DeclSpecContext::DSC_trailing:
2410 case DeclSpecContext::DSC_alias_declaration:
2413 llvm_unreachable(
"Missing DeclSpecContext case");
2418 getImplicitTypenameContext(DeclSpecContext DSC) {
2420 case DeclSpecContext::DSC_class:
2421 case DeclSpecContext::DSC_top_level:
2422 case DeclSpecContext::DSC_type_specifier:
2423 case DeclSpecContext::DSC_template_type_arg:
2424 case DeclSpecContext::DSC_trailing:
2425 case DeclSpecContext::DSC_alias_declaration:
2426 case DeclSpecContext::DSC_template_param:
2427 case DeclSpecContext::DSC_new:
2430 case DeclSpecContext::DSC_normal:
2431 case DeclSpecContext::DSC_objc_method_result:
2432 case DeclSpecContext::DSC_condition:
2433 case DeclSpecContext::DSC_template_arg:
2434 case DeclSpecContext::DSC_conv_operator:
2435 case DeclSpecContext::DSC_association:
2438 llvm_unreachable(
"Missing DeclSpecContext case");
2443 struct ForRangeInit {
2444 SourceLocation ColonLoc;
2446 SmallVector<MaterializeTemporaryExpr *, 8> LifetimeExtendTemps;
2447 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2449 struct ForRangeInfo : ForRangeInit {
2454 SourceLocation &DeclEnd,
2455 ParsedAttributes &DeclAttrs,
2456 ParsedAttributes &DeclSpecAttrs,
2457 SourceLocation *DeclSpecStart =
nullptr);
2460 ParsedAttributes &DeclAttrs,
2461 ParsedAttributes &DeclSpecAttrs,
bool RequireSemi,
2462 ForRangeInit *FRI =
nullptr,
2463 SourceLocation *DeclSpecStart =
nullptr);
2466 ParsedAttributes &Attrs,
2467 ParsedTemplateInfo &TemplateInfo,
2468 SourceLocation *DeclEnd =
nullptr,
2469 ForRangeInit *FRI =
nullptr);
2470 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2471 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2472 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2473 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2475 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2476 ForRangeInit *FRI =
nullptr);
2477 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2478 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2484 bool trySkippingFunctionBody();
2486 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2488 DeclSpecContext DSC, ParsedAttributes &Attrs);
2492 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2494 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2495 LateParsedAttrList *LateAttrs =
nullptr) {
2496 return ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC, LateAttrs,
2497 getImplicitTypenameContext(DSC));
2500 ParseDeclarationSpecifiers(DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
2502 LateParsedAttrList *LateAttrs,
2505 SourceLocation ParsePackIndexingType(DeclSpec &DS);
2506 void AnnotateExistingIndexedTypeNamePack(
ParsedType T,
2507 SourceLocation StartLoc,
2508 SourceLocation EndLoc);
2510 bool DiagnoseMissingSemiAfterTagDefinition(
2512 LateParsedAttrList *LateAttrs =
nullptr);
2514 void ParseSpecifierQualifierList(
2516 DeclSpecContext DSC = DeclSpecContext::DSC_normal) {
2517 ParseSpecifierQualifierList(DS, getImplicitTypenameContext(DSC), AS, DSC);
2520 void ParseSpecifierQualifierList(
2523 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2525 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2528 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2529 const ParsedTemplateInfo &TemplateInfo,
2531 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2532 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2533 RecordDecl *TagDecl);
2535 void ParseStructDeclaration(
2536 ParsingDeclSpec &DS,
2537 llvm::function_ref<
void(ParsingFieldDeclarator &)> FieldsCallback);
2542 bool DisambiguatingWithExpression =
false);
2543 bool isTypeSpecifierQualifier();
2548 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2553 bool isKnownToBeDeclarationSpecifier() {
2566 bool isDeclarationStatement(
bool DisambiguatingWithExpression =
false) {
2568 return isCXXDeclarationStatement(DisambiguatingWithExpression);
2576 bool isForInitDeclaration() {
2580 return Tok.is(tok::kw_using) ||
2581 isCXXSimpleDeclaration(
true);
2586 bool isForRangeIdentifier();
2590 bool isStartOfObjCClassMessageMissingOpenBracket();
2595 bool isConstructorDeclarator(
2598 const ParsedTemplateInfo *TemplateInfo =
nullptr);
2602 enum TentativeCXXTypeIdContext {
2605 TypeIdAsTemplateArgument,
2606 TypeIdInTrailingReturnType,
2607 TypeIdAsGenericSelectionArgument,
2613 bool isTypeIdInParens(
bool &isAmbiguous) {
2615 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2616 isAmbiguous =
false;
2617 return isTypeSpecifierQualifier();
2619 bool isTypeIdInParens() {
2621 return isTypeIdInParens(isAmbiguous);
2631 bool isTypeIdForGenericSelection() {
2634 return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
2636 return isTypeSpecifierQualifier();
2642 bool isTypeIdUnambiguously() {
2645 return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
2647 return isTypeSpecifierQualifier();
2653 bool isCXXDeclarationStatement(
bool DisambiguatingWithExpression =
false);
2660 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2669 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr,
2673 struct ConditionDeclarationOrInitStatementState;
2674 enum class ConditionOrInitStatement {
2684 ConditionOrInitStatement
2685 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2686 bool CanBeForRangeDecl);
2688 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2689 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2691 return isCXXTypeId(Context, isAmbiguous);
2696 enum class TPResult {
2697 True, False, Ambiguous,
Error
2707 bool isEnumBase(
bool AllowSemi);
2718 TPResult BracedCastResult = TPResult::False,
2719 bool *InvalidAsDeclSpec =
nullptr);
2724 bool isCXXDeclarationSpecifierAType();
2729 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2734 TPResult isExplicitBool();
2739 bool isTentativelyDeclared(IdentifierInfo *II);
2748 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2749 TPResult TryParseTypeofSpecifier();
2750 TPResult TryParseProtocolQualifiers();
2751 TPResult TryParsePtrOperatorSeq();
2752 TPResult TryParseOperatorId();
2753 TPResult TryParseInitDeclaratorList(
bool MayHaveTrailingReturnType =
false);
2754 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2755 bool mayHaveDirectInit =
false,
2756 bool mayHaveTrailingReturnType =
false);
2757 TPResult TryParseParameterDeclarationClause(
2758 bool *InvalidAsDeclaration =
nullptr,
bool VersusTemplateArg =
false,
2761 TPResult TryParseFunctionDeclarator(
bool MayHaveTrailingReturnType =
false);
2762 bool NameAfterArrowIsNonType();
2763 TPResult TryParseBracketDeclarator();
2764 TPResult TryConsumeDeclarationSpecifier();
2768 bool TrySkipAttributes();
2772 void DiagnoseBitIntUse(
const Token &Tok);
2779 ParsedAttributes *Attrs =
nullptr);
2782 void ParseBlockId(SourceLocation CaretLoc);
2789 bool isAllowedCXX11AttributeSpecifier(
bool Disambiguate =
false,
2790 bool OuterMightBeMessageSend =
false) {
2791 return (Tok.isRegularKeywordAttribute() ||
2792 isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
2797 bool CheckProhibitedCXX11Attribute() {
2798 assert(Tok.is(tok::l_square));
2801 return DiagnoseProhibitedCXX11Attribute();
2804 bool DiagnoseProhibitedCXX11Attribute();
2805 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2806 SourceLocation CorrectLocation) {
2807 if (!Tok.isRegularKeywordAttribute() &&
2808 (Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2809 Tok.isNot(tok::kw_alignas))
2811 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2813 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2814 SourceLocation CorrectLocation);
2816 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2820 void ProhibitAttributes(ParsedAttributes &Attrs,
2821 SourceLocation FixItLoc = SourceLocation()) {
2822 if (Attrs.Range.isInvalid())
2824 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2828 void ProhibitAttributes(ParsedAttributesView &Attrs,
2829 SourceLocation FixItLoc = SourceLocation()) {
2830 if (Attrs.Range.isInvalid())
2832 DiagnoseProhibitedAttributes(Attrs, FixItLoc);
2833 Attrs.clearListOnly();
2835 void DiagnoseProhibitedAttributes(
const ParsedAttributesView &Attrs,
2836 SourceLocation FixItLoc);
2844 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned AttrDiagID,
2845 unsigned KeywordDiagId,
2846 bool DiagnoseEmptyAttrs =
false,
2847 bool WarnOnUnknownAttrs =
false);
2852 SourceLocation SkipCXX11Attributes();
2856 void DiagnoseAndSkipCXX11Attributes();
2860 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2862 ExprResult ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName);
2866 SmallVectorImpl<Expr *> &Exprs,
2867 ParsedAttributeArgumentsProperties ArgsProperties);
2874 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2875 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2876 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2877 ParsedAttr::Form Form);
2879 enum ParseAttrKindMask {
2881 PAKM_Declspec = 1 << 1,
2882 PAKM_CXX11 = 1 << 2,
2899 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2900 LateParsedAttrList *LateAttrs =
nullptr);
2903 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2904 LateParsedAttrList *LateAttrs =
nullptr) {
2905 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2906 isAllowedCXX11AttributeSpecifier()) {
2907 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2913 void MaybeParseGNUAttributes(Declarator &D,
2914 LateParsedAttrList *LateAttrs =
nullptr) {
2915 if (Tok.is(tok::kw___attribute)) {
2916 ParsedAttributes Attrs(AttrFactory);
2917 ParseGNUAttributes(Attrs, LateAttrs, &D);
2918 D.takeAttributes(Attrs);
2922 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2923 LateParsedAttrList *LateAttrs =
nullptr) {
2924 if (Tok.is(tok::kw___attribute)) {
2925 ParseGNUAttributes(Attrs, LateAttrs);
2931 void ParseGNUAttributes(ParsedAttributes &Attrs,
2932 LateParsedAttrList *LateAttrs =
nullptr,
2933 Declarator *D =
nullptr);
2934 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2935 SourceLocation AttrNameLoc,
2936 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2937 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2938 ParsedAttr::Form Form, Declarator *D);
2939 IdentifierLoc *ParseIdentifierLoc();
2942 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2943 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2944 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2945 ParsedAttr::Form Form);
2947 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2950 if (!OpenMPTokens.empty()) {
2952 PP.EnterTokenStream(OpenMPTokens,
true,
2957 void MaybeParseCXX11Attributes(Declarator &D) {
2958 if (isAllowedCXX11AttributeSpecifier()) {
2959 ParsedAttributes Attrs(AttrFactory);
2960 ParseCXX11Attributes(Attrs);
2961 D.takeAttributes(Attrs);
2965 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2966 bool OuterMightBeMessageSend =
false) {
2967 if (isAllowedCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2968 ParseCXX11Attributes(Attrs);
2974 void ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
2977 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2979 SourceLocation *EndLoc =
nullptr);
2980 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2981 SourceLocation *EndLoc =
nullptr) {
2983 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2984 ReplayOpenMPAttributeTokens(OpenMPTokens);
2986 void ParseCXX11Attributes(ParsedAttributes &attrs);
2989 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
2990 SourceLocation AttrNameLoc,
2991 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2992 IdentifierInfo *ScopeName,
2993 SourceLocation ScopeLoc,
2997 bool ParseCXXAssumeAttributeArg(ParsedAttributes &Attrs,
2998 IdentifierInfo *AttrName,
2999 SourceLocation AttrNameLoc,
3000 SourceLocation *EndLoc);
3002 IdentifierInfo *TryParseCXX11AttributeIdentifier(
3003 SourceLocation &
Loc,
3006 const IdentifierInfo *EnclosingScope =
nullptr);
3008 void MaybeParseHLSLAnnotations(Declarator &D,
3009 SourceLocation *EndLoc =
nullptr) {
3010 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3011 if (Tok.is(tok::colon)) {
3012 ParsedAttributes Attrs(AttrFactory);
3013 ParseHLSLAnnotations(Attrs, EndLoc);
3014 D.takeAttributes(Attrs);
3018 void MaybeParseHLSLAnnotations(ParsedAttributes &Attrs,
3019 SourceLocation *EndLoc =
nullptr) {
3020 assert(
getLangOpts().
HLSL &&
"MaybeParseHLSLAnnotations is for HLSL only");
3022 ParseHLSLAnnotations(Attrs, EndLoc);
3025 void ParseHLSLAnnotations(ParsedAttributes &Attrs,
3026 SourceLocation *EndLoc =
nullptr);
3027 Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
3029 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
3031 Tok.is(tok::l_square)) {
3032 ParsedAttributes AttrsWithRange(AttrFactory);
3033 ParseMicrosoftAttributes(AttrsWithRange);
3034 Attrs.takeAllFrom(AttrsWithRange);
3037 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
3038 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
3039 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
3040 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
3041 ParseMicrosoftDeclSpecs(Attrs);
3046 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
3047 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
3048 SourceLocation AttrNameLoc,
3049 ParsedAttributes &Attrs);
3050 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
3051 void ParseWebAssemblyFuncrefTypeAttribute(ParsedAttributes &Attrs);
3052 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
3053 SourceLocation SkipExtendedMicrosoftTypeAttributes();
3054 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3055 void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
3056 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
3057 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
3058 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
3059 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
3060 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
3061 bool isHLSLQualifier(
const Token &Tok)
const;
3062 void ParseHLSLQualifiers(ParsedAttributes &Attrs);
3064 VersionTuple ParseVersionTuple(SourceRange &
Range);
3065 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
3066 SourceLocation AvailabilityLoc,
3067 ParsedAttributes &attrs,
3068 SourceLocation *endLoc,
3069 IdentifierInfo *ScopeName,
3070 SourceLocation ScopeLoc,
3071 ParsedAttr::Form Form);
3073 std::optional<AvailabilitySpec> ParseAvailabilitySpec();
3074 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
3076 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
3078 ParsedAttributes &Attrs,
3079 SourceLocation *EndLoc,
3080 IdentifierInfo *ScopeName,
3081 SourceLocation ScopeLoc,
3082 ParsedAttr::Form Form);
3084 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
3085 SourceLocation ObjCBridgeRelatedLoc,
3086 ParsedAttributes &Attrs,
3087 SourceLocation *EndLoc,
3088 IdentifierInfo *ScopeName,
3089 SourceLocation ScopeLoc,
3090 ParsedAttr::Form Form);
3092 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
3093 SourceLocation AttrNameLoc,
3094 ParsedAttributes &Attrs,
3095 SourceLocation *EndLoc,
3096 IdentifierInfo *ScopeName,
3097 SourceLocation ScopeLoc,
3098 ParsedAttr::Form Form);
3100 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
3101 SourceLocation AttrNameLoc,
3102 ParsedAttributes &Attrs,
3103 SourceLocation *EndLoc,
3104 IdentifierInfo *ScopeName,
3105 SourceLocation ScopeLoc,
3106 ParsedAttr::Form Form);
3108 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
3109 SourceLocation AttrNameLoc,
3110 ParsedAttributes &Attrs,
3111 IdentifierInfo *ScopeName,
3112 SourceLocation ScopeLoc,
3113 ParsedAttr::Form Form);
3115 void ParseBoundsAttribute(IdentifierInfo &AttrName,
3116 SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
3117 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
3118 ParsedAttr::Form Form);
3120 void ParseTypeofSpecifier(DeclSpec &DS);
3121 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
3122 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
3123 SourceLocation StartLoc,
3124 SourceLocation EndLoc);
3125 void ParseAtomicSpecifier(DeclSpec &DS);
3127 ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
3128 SourceLocation &EllipsisLoc,
bool &IsType,
3130 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
3131 SourceLocation *endLoc =
nullptr);
3136 return isCXX11VirtSpecifier(Tok);
3138 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
3139 SourceLocation FriendLoc);
3141 bool isCXX11FinalKeyword()
const;
3142 bool isClassCompatibleKeyword()
const;
3147 class DeclaratorScopeObj {
3153 DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
3154 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
3156 void EnterDeclaratorScope() {
3157 assert(!EnteredScope &&
"Already entered the scope!");
3158 assert(SS.isSet() &&
"C++ scope was not set!");
3160 CreatedScope =
true;
3163 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
3164 EnteredScope =
true;
3167 ~DeclaratorScopeObj() {
3169 assert(SS.isSet() &&
"C++ scope was cleared ?");
3170 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
3178 void ParseDeclarator(Declarator &D);
3180 typedef void (Parser::*DirectDeclParseFunction)(
Declarator&);
3181 void ParseDeclaratorInternal(Declarator &D,
3182 DirectDeclParseFunction DirectDeclParser);
3184 enum AttrRequirements {
3185 AR_NoAttributesParsed = 0,
3186 AR_GNUAttributesParsedAndRejected = 1 << 0,
3187 AR_GNUAttributesParsed = 1 << 1,
3188 AR_CXX11AttributesParsed = 1 << 2,
3189 AR_DeclspecAttributesParsed = 1 << 3,
3190 AR_AllAttributesParsed = AR_GNUAttributesParsed |
3191 AR_CXX11AttributesParsed |
3192 AR_DeclspecAttributesParsed,
3193 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
3194 AR_DeclspecAttributesParsed
3197 void ParseTypeQualifierListOpt(
3198 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
3199 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
3200 std::optional<llvm::function_ref<
void()>> CodeCompletionHandler =
3202 void ParseDirectDeclarator(Declarator &D);
3203 void ParseDecompositionDeclarator(Declarator &D);
3204 void ParseParenDeclarator(Declarator &D);
3205 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
3207 bool IsAmbiguous,
bool RequiresArg =
false);
3208 void InitCXXThisScopeForDeclaratorIfRelevant(
3209 const Declarator &D,
const DeclSpec &DS,
3210 std::optional<Sema::CXXThisScopeRAII> &ThisScope);
3211 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
3212 SourceLocation &RefQualifierLoc);
3213 bool isFunctionDeclaratorIdentifierList();
3214 void ParseFunctionDeclaratorIdentifierList(
3216 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
3217 void ParseParameterDeclarationClause(
3218 Declarator &D, ParsedAttributes &attrs,
3219 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3220 SourceLocation &EllipsisLoc) {
3221 return ParseParameterDeclarationClause(
3222 D.getContext(), attrs, ParamInfo, EllipsisLoc,
3223 D.getCXXScopeSpec().isSet() &&
3224 D.isFunctionDeclaratorAFunctionDeclaration());
3226 void ParseParameterDeclarationClause(
3228 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
3229 SourceLocation &EllipsisLoc,
bool IsACXXFunctionDeclaration =
false);
3231 void ParseBracketDeclarator(Declarator &D);
3232 void ParseMisplacedBracketDeclarator(Declarator &D);
3233 bool MaybeParseTypeTransformTypeSpecifier(DeclSpec &DS);
3240 enum CXX11AttributeKind {
3242 CAK_NotAttributeSpecifier,
3244 CAK_AttributeSpecifier,
3247 CAK_InvalidAttributeSpecifier
3250 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3251 bool OuterMightBeMessageSend =
false);
3253 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3256 SourceLocation &DeclEnd,
3257 SourceLocation InlineLoc = SourceLocation());
3259 struct InnerNamespaceInfo {
3260 SourceLocation NamespaceLoc;
3261 SourceLocation InlineLoc;
3262 SourceLocation IdentLoc;
3263 IdentifierInfo *Ident;
3267 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3268 unsigned int index, SourceLocation &InlineLoc,
3269 ParsedAttributes &attrs,
3272 Decl *ParseExportDeclaration();
3275 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3277 SourceLocation UsingLoc,
3278 SourceLocation &DeclEnd,
3279 ParsedAttributes &attrs);
3281 struct UsingDeclarator {
3282 SourceLocation TypenameLoc;
3285 SourceLocation EllipsisLoc;
3288 TypenameLoc = EllipsisLoc = SourceLocation();
3296 const ParsedTemplateInfo &TemplateInfo,
3297 SourceLocation UsingLoc,
3298 SourceLocation &DeclEnd,
3299 ParsedAttributes &Attrs,
3301 Decl *ParseAliasDeclarationAfterDeclarator(
3302 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3304 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3306 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3307 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3308 SourceLocation AliasLoc, IdentifierInfo *Alias,
3309 SourceLocation &DeclEnd);
3313 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3314 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3315 DeclSpec &DS, ParsedTemplateInfo &TemplateInfo,
3317 DeclSpecContext DSC, ParsedAttributes &Attributes);
3318 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3319 SourceLocation AttrFixitLoc,
3322 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3323 SourceLocation AttrFixitLoc,
3324 ParsedAttributes &Attrs,
unsigned TagType,
3326 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3327 SourceLocation &EqualLoc);
3329 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3332 LateParsedAttrList &LateAttrs);
3333 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3334 VirtSpecifiers &VS);
3337 ParsedTemplateInfo &TemplateInfo,
3338 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3341 ParsedAttributes &AccessAttrs,
3343 void ParseConstructorInitializer(Decl *ConstructorDecl);
3345 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3350 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3351 SourceLocation &EndLocation);
3352 void ParseBaseClause(Decl *ClassDecl);
3353 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3356 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3358 bool ObjectHadErrors,
3359 SourceLocation TemplateKWLoc,
3360 IdentifierInfo *Name,
3361 SourceLocation NameLoc,
3362 bool EnteringContext,
3364 bool AssumeTemplateId);
3365 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3374 SourceLocation
Loc);
3378 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3379 llvm::omp::TraitSet
Set,
3380 llvm::omp::TraitSelector Selector,
3381 llvm::StringMap<SourceLocation> &Seen);
3384 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3385 llvm::omp::TraitSet
Set,
3386 llvm::StringMap<SourceLocation> &Seen);
3389 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3390 llvm::StringMap<SourceLocation> &Seen);
3393 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3394 llvm::omp::TraitSet
Set,
3395 llvm::StringMap<SourceLocation> &Seen);
3398 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3399 llvm::omp::TraitSet
Set,
3400 llvm::StringMap<SourceLocation> &SeenSelectors);
3403 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3404 llvm::StringMap<SourceLocation> &SeenSets);
3407 bool parseOMPContextSelectors(SourceLocation
Loc, OMPTraitInfo &TI);
3410 bool parseOpenMPAppendArgs(SmallVectorImpl<OMPInteropInfo> &InteropInfos);
3414 bool parseOMPDeclareVariantMatchClause(SourceLocation
Loc, OMPTraitInfo &TI,
3415 OMPTraitInfo *ParentTI);
3419 SourceLocation
Loc);
3423 SourceLocation
Loc);
3426 void ParseOpenMPEndAssumesDirective(SourceLocation
Loc);
3434 SmallVectorImpl<clang::OMPClause *> &Clauses,
3435 SourceLocation
Loc);
3438 void ParseOMPDeclareTargetClauses(SemaOpenMP::DeclareTargetContextInfo &DTCI);
3443 SourceLocation
Loc);
3456 SourceLocation MatchingLoc,
3457 SourceLocation FoundLoc,
3458 bool SkipUntilOpenMPEnd);
3464 Decl *TagDecl =
nullptr);
3469 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3475 DeclarationName &Name,
3480 bool tryParseOpenMPArrayShapingCastPart();
3489 bool ParseOpenMPSimpleVarList(
3491 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3493 bool AllowScopeSpecifier);
3499 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3500 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3528 bool ParseOpenMPIndirectClause(SemaOpenMP::DeclareTargetContextInfo &DTCI,
3543 OMPClause *ParseOpenMPSizesClause();
3551 OMPClause *ParseOpenMPClause(
OpenMPClauseKind Kind,
bool ParseOnly =
false);
3572 SourceLocation &ClauseNameLoc,
3573 SourceLocation &OpenLoc,
3574 SourceLocation &CloseLoc,
3575 SmallVectorImpl<Expr *> &Exprs,
3576 bool ReqIntConst =
false);
3589 bool ParseOMPInteropInfo(OMPInteropInfo &InteropInfo,
OpenMPClauseKind Kind);
3597 OMPClause *ParseOpenMPInteropClause(
OpenMPClauseKind Kind,
bool ParseOnly);
3604 OMPClause *ParseOpenMPOMPXAttributesClause(
bool ParseOnly);
3611 bool IsAddressOfOperand =
false);
3615 SemaOpenMP::OpenMPVarListDataTy &
Data,
3616 const LangOptions &LangOpts);
3619 SmallVectorImpl<Expr *> &Vars,
3620 SemaOpenMP::OpenMPVarListDataTy &
Data);
3622 bool ObjectHadErrors,
bool EnteringContext,
3623 bool AllowDestructorName,
bool AllowConstructorName,
3624 bool AllowDeductionGuide,
3625 SourceLocation *TemplateKWLoc, UnqualifiedId &
Result);
3648 struct OpenACCDirectiveParseInfo {
3650 SourceLocation StartLoc;
3651 SourceLocation EndLoc;
3652 SmallVector<OpenACCClause *> Clauses;
3657 struct OpenACCWaitParseInfo {
3658 bool Failed =
false;
3659 Expr *DevNumExpr =
nullptr;
3660 SourceLocation QueuesLoc;
3661 SmallVector<Expr *> QueueIdExprs;
3666 enum class OpenACCParseCanContinue { Cannot = 0, Can = 1 };
3672 using OpenACCClauseParseResult =
3673 llvm::PointerIntPair<OpenACCClause *, 1, OpenACCParseCanContinue>;
3675 OpenACCClauseParseResult OpenACCCanContinue();
3676 OpenACCClauseParseResult OpenACCCannotContinue();
3677 OpenACCClauseParseResult OpenACCSuccess(OpenACCClause *Clause);
3681 OpenACCDirectiveParseInfo ParseOpenACCDirective();
3685 void ParseOpenACCCacheVarList();
3687 using OpenACCVarParseResult = std::pair<ExprResult, OpenACCParseCanContinue>;
3689 OpenACCVarParseResult ParseOpenACCVar();
3694 OpenACCClauseParseResult
3695 ParseOpenACCClauseParams(ArrayRef<const OpenACCClause *> ExistingClauses,
3697 SourceLocation ClauseLoc);
3700 OpenACCClauseParseResult
3701 ParseOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
3704 SmallVector<OpenACCClause *>
3706 OpenACCWaitParseInfo ParseOpenACCWaitArgument(SourceLocation
Loc,
3715 using OpenACCIntExprParseResult =
3716 std::pair<ExprResult, OpenACCParseCanContinue>;
3721 SourceLocation
Loc);
3728 bool ParseOpenACCDeviceTypeList(
3734 SourceLocation
Loc);
3736 bool ParseOpenACCSizeExpr();
3738 bool ParseOpenACCSizeExprList();
3740 bool ParseOpenACCGangArgList(SourceLocation GangLoc);
3742 bool ParseOpenACCGangArg(SourceLocation GangLoc);
3753 SourceLocation &DeclEnd,
3754 ParsedAttributes &AccessAttrs);
3760 ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd,
3762 bool ParseTemplateParameters(MultiParseScope &TemplateScopes,
unsigned Depth,
3763 SmallVectorImpl<NamedDecl *> &TemplateParams,
3764 SourceLocation &LAngleLoc,
3765 SourceLocation &RAngleLoc);
3766 bool ParseTemplateParameterList(
unsigned Depth,
3767 SmallVectorImpl<NamedDecl*> &TemplateParams);
3768 TPResult isStartOfTemplateTypeParameter();
3769 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3770 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3771 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3772 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3773 bool isTypeConstraintAnnotation();
3774 bool TryAnnotateTypeConstraint();
3775 void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
3776 SourceLocation CorrectLoc,
3777 bool AlreadyHasEllipsis,
3778 bool IdentifierHasName);
3779 void DiagnoseMisplacedEllipsisInDeclarator(SourceLocation EllipsisLoc,
3782 typedef SmallVector<ParsedTemplateArgument, 16> TemplateArgList;
3784 bool ParseGreaterThanInTemplateList(SourceLocation LAngleLoc,
3785 SourceLocation &RAngleLoc,
3786 bool ConsumeLastToken,
3787 bool ObjCGenericList);
3788 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3789 SourceLocation &LAngleLoc,
3790 TemplateArgList &TemplateArgs,
3791 SourceLocation &RAngleLoc,
3796 SourceLocation TemplateKWLoc,
3797 UnqualifiedId &TemplateName,
3798 bool AllowTypeAnnotation =
true,
3799 bool TypeConstraint =
false);
3801 AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
3803 bool IsClassName =
false);
3804 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
3805 TemplateTy Template, SourceLocation OpenLoc);
3806 ParsedTemplateArgument ParseTemplateTemplateArgument();
3807 ParsedTemplateArgument ParseTemplateArgument();
3809 SourceLocation ExternLoc,
3810 SourceLocation TemplateLoc,
3811 SourceLocation &DeclEnd,
3812 ParsedAttributes &AccessAttrs,
3816 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3817 SourceLocation &DeclEnd);
3828 TypeResult ParseTypeFromString(StringRef TypeStr, StringRef Context,
3829 SourceLocation IncludeLoc);
3834 Decl *ParseModuleImport(SourceLocation AtLoc,
3836 bool parseMisplacedModuleImport();
3837 bool tryParseMisplacedModuleImport() {
3839 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
3840 Kind == tok::annot_module_include)
3841 return parseMisplacedModuleImport();
3845 bool ParseModuleName(
3846 SourceLocation UseLoc,
3847 SmallVectorImpl<std::pair<IdentifierInfo *, SourceLocation>> &Path,
3861 void CodeCompleteDirective(
bool InConditional)
override;
3862 void CodeCompleteInConditionalExclusion()
override;
3863 void CodeCompleteMacroName(
bool IsDefinition)
override;
3864 void CodeCompletePreprocessorExpression()
override;
3865 void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo,
3866 unsigned ArgumentIndex)
override;
3867 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3868 void CodeCompleteNaturalLanguage()
override;
3870 class GNUAsmQualifiers {
3871 unsigned Qualifiers = AQ_unspecified;
3880 static const char *getQualifierName(AQ Qualifier);
3881 bool setAsmQualifier(AQ Qualifier);
3882 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3883 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3884 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3886 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3887 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3888 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3889 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 facilities that support code completion.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static bool isInvalid(LocType Loc, bool *Invalid)
The result of parsing/analyzing an expression, statement etc.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Callback handler that receives notifications when performing code completion within the preprocessor.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
static const TST TST_unspecified
Decl - This represents one declaration (or definition), e.g.
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
This represents one expression.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
ObjCContainerDecl - Represents a container for method declarations.
Wrapper for void* pointer.
static OpaquePtr getFromOpaquePtr(void *P)
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
Introduces zero or more scopes for parsing.
MultiParseScope(Parser &Self)
void Enter(unsigned ScopeFlags)
ParseScope - Introduces a new scope for parsing.
ParseScope(Parser *Self, unsigned ScopeFlags, bool EnteredScope=true, bool BeforeCompoundStmt=false)
Parser - This implements a parser for the C family of languages.
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr * > &Vars, SemaOpenMP::OpenMPVarListDataTy &Data)
Parses clauses with list.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope, ImplicitTypenameContext AllowImplicitTypename)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
Preprocessor & getPreprocessor() const
bool parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data)
Parses map-type-modifiers in map clause.
Sema::FullExprArg FullExprArg
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
AttributeFactory & getAttrFactory()
void incrementMSManglingNumber() const
Sema & getActions() const
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
bool parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data)
Parses the mapper modifier in map, to, and from clauses.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext=false)
friend class ColonProtectionRAIIObject
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
StmtResult ParseOpenACCDirectiveStmt()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
friend constexpr SkipUntilFlags operator|(SkipUntilFlags L, SkipUntilFlags R)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
SourceLocation getEndOfPreviousToken()
ExprResult ParseArrayBoundExpression()
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
const TargetInfo & getTargetInfo() const
OpaquePtr< TemplateName > TemplateTy
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
const Token & getCurToken() const
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind...
friend class ObjCDeclContextSwitch
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
void ExitScope()
ExitScope - Pop a scope off the scope stack.
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc, bool IsAddressOfOperand=false)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
SourceLocation MisleadingIndentationElseLoc
The location of the first statement inside an else that might have a missleading indentation.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result, Sema::ModuleImportState &ImportState)
Parse the first top-level declaration in a translation unit.
DiagnosticBuilder Diag(unsigned DiagID)
SmallVector< Stmt *, 32 > StmtVector
A SmallVector of statements.
SkipUntilFlags
Control flags for SkipUntil functions.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
bool MightBeCXXScopeToken()
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ParseUnevaluatedStringLiteralExpression()
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
bool ParseOpenMPReservedLocator(OpenMPClauseKind Kind, SemaOpenMP::OpenMPVarListDataTy &Data, const LangOptions &LangOpts)
Parses a reserved locator like 'omp_all_memory'.
ObjCContainerDecl * getObjCDeclContext() const
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
friend class BalancedDelimiterTracker
bool TryConsumeToken(tok::TokenKind Expected, SourceLocation &Loc)
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
void Initialize()
Initialize - Warm up the parser.
unsigned ReenterTemplateScopes(MultiParseScope &S, Decl *D)
Re-enter the template scopes for a declaration that might be a template.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
Activates OpenACC parsing mode to preseve OpenACC specific annotation tokens.
Activates OpenMP parsing mode to preseve OpenMP specific annotation tokens.
Tracks expected type during expression parsing, for use in code completion.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void setCodeCompletionReached()
Note that we hit the code-completion point.
bool mightHavePendingAnnotationTokens()
Determine whether it's possible for a future call to Lex to produce an annotation token created by a ...
void Lex(Token &Result)
Lex the next token for this preprocessor.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
const TargetInfo & getTargetInfo() const
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
const LangOptions & getLangOpts() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
Scope - A scope is a transient data structure that is used while parsing the program.
ObjCContainerDecl * getObjCDeclContext() const
void startOpenMPLoop()
If the current region is a loop-based region, mark the start of the loop construct.
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
ProcessingContextState ParsingClassState
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
void incrementMSManglingNumber() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Exposes information about the current target.
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setAnnotationValue(void *val)
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
@ LLVM_MARK_AS_BITMASK_ENUM
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
bool Pop(InterpState &S, CodePtr OpPC)
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
NullabilityKind
Describes the nullability of a particular type.
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
ActionResult< CXXCtorInitializer * > MemInitResult
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
ActionResult< ParsedType > TypeResult
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
const FunctionProtoType * T
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< CXXBaseSpecifier * > BaseResult
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
unsigned short BracketCount
unsigned short BraceCount
AngleBracketTracker::Priority Priority
bool isActive(Parser &P) const
unsigned short ParenCount
bool isActiveOrNested(Parser &P) const