13 #ifndef LLVM_CLANG_PARSE_PARSER_H
14 #define LLVM_CLANG_PARSE_PARSER_H
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/Frontend/OpenMP/OMPContext.h"
27 #include "llvm/Support/Compiler.h"
28 #include "llvm/Support/PrettyStackTrace.h"
29 #include "llvm/Support/SaveAndRestore.h"
36 class BalancedDelimiterTracker;
37 class CorrectionCandidateCallback;
39 class DiagnosticBuilder;
42 class ParsingDeclRAIIObject;
43 class ParsingDeclSpec;
44 class ParsingDeclarator;
45 class ParsingFieldDeclarator;
46 class ColonProtectionRAIIObject;
47 class InMessageExpressionRAIIObject;
48 class PoisonSEHIdentifiersRAIIObject;
50 class ObjCTypeParamList;
51 struct OMPTraitProperty;
52 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;
158 *Ident_generated_declaration;
171 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
173 std::unique_ptr<PragmaHandler> AlignHandler;
174 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
175 std::unique_ptr<PragmaHandler> OptionsHandler;
176 std::unique_ptr<PragmaHandler> PackHandler;
177 std::unique_ptr<PragmaHandler> MSStructHandler;
178 std::unique_ptr<PragmaHandler> UnusedHandler;
179 std::unique_ptr<PragmaHandler> WeakHandler;
180 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
181 std::unique_ptr<PragmaHandler> FPContractHandler;
182 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
183 std::unique_ptr<PragmaHandler> OpenMPHandler;
184 std::unique_ptr<PragmaHandler> PCSectionHandler;
185 std::unique_ptr<PragmaHandler> MSCommentHandler;
186 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
187 std::unique_ptr<PragmaHandler> FPEvalMethodHandler;
188 std::unique_ptr<PragmaHandler> FloatControlHandler;
189 std::unique_ptr<PragmaHandler> MSPointersToMembers;
190 std::unique_ptr<PragmaHandler> MSVtorDisp;
191 std::unique_ptr<PragmaHandler> MSInitSeg;
192 std::unique_ptr<PragmaHandler> MSDataSeg;
193 std::unique_ptr<PragmaHandler> MSBSSSeg;
194 std::unique_ptr<PragmaHandler> MSConstSeg;
195 std::unique_ptr<PragmaHandler> MSCodeSeg;
196 std::unique_ptr<PragmaHandler> MSSection;
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;
219 std::unique_ptr<CommentHandler> CommentSemaHandler;
225 bool GreaterThanIsOperator;
234 bool OpenMPDirectiveParsing =
false;
241 bool InMessageExpression;
246 bool CalledSignatureHelp =
false;
249 unsigned TemplateParameterDepth;
255 class TemplateParameterDepthRAII {
257 unsigned AddedLevels;
259 explicit TemplateParameterDepthRAII(
unsigned &
Depth)
262 ~TemplateParameterDepthRAII() {
263 Depth -= AddedLevels;
270 void addDepth(
unsigned D) {
274 void setAddedDepth(
unsigned D) {
279 unsigned getDepth()
const {
return Depth; }
280 unsigned getOriginalDepth()
const {
return Depth - AddedLevels; }
284 AttributeFactory AttrFactory;
288 SmallVector<TemplateIdAnnotation *, 16> TemplateIds;
290 void MaybeDestroyTemplateIds() {
291 if (!TemplateIds.empty() &&
293 DestroyTemplateIds();
295 void DestroyTemplateIds();
299 struct DestroyTemplateIdAnnotationsRAIIObj {
302 DestroyTemplateIdAnnotationsRAIIObj(
Parser &Self) : Self(Self) {}
303 ~DestroyTemplateIdAnnotationsRAIIObj() { Self.MaybeDestroyTemplateIds(); }
307 SmallVector<IdentifierInfo *, 8> TentativelyDeclaredIdentifiers;
319 struct AngleBracketTracker {
329 SpaceBeforeLess = 0x0,
331 NoSpaceBeforeLess = 0x1,
362 if (!Locs.empty() && Locs.back().isActive(
P)) {
363 if (Locs.back().Priority <= Prio) {
365 Locs.back().LessLoc = LessLoc;
366 Locs.back().Priority = Prio;
369 Locs.push_back({TemplateName, LessLoc, Prio,
370 P.ParenCount,
P.BracketCount,
P.BraceCount});
378 while (!Locs.empty() && Locs.back().isActiveOrNested(
P))
385 if (!Locs.empty() && Locs.back().isActive(
P))
391 AngleBracketTracker AngleBrackets;
393 IdentifierInfo *getSEHExceptKeyword();
400 bool ParsingInObjCContainer;
406 bool SkipFunctionBodies;
411 SourceLocation ExprStatementTokLoc;
414 enum class ParsedStmtContext {
417 AllowDeclarationsInC = 0x1,
419 AllowStandaloneOpenMPDirectives = 0x2,
426 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
437 Parser(Preprocessor &PP, Sema &Actions,
bool SkipFunctionBodies);
491 assert(!isTokenSpecial() &&
492 "Should consume special tokens with Consume*Token");
495 return PrevTokLocation;
501 assert(!isTokenSpecial() &&
502 "Should consume special tokens with Consume*Token");
511 Loc = PrevTokLocation;
520 return ConsumeParen();
521 if (isTokenBracket())
522 return ConsumeBracket();
524 return ConsumeBrace();
525 if (isTokenStringLiteral())
526 return ConsumeStringToken();
527 if (Tok.
is(tok::code_completion))
528 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
529 : handleUnexpectedCodeCompletionToken();
531 return ConsumeAnnotationToken();
552 bool isTokenParen()
const {
553 return Tok.
isOneOf(tok::l_paren, tok::r_paren);
556 bool isTokenBracket()
const {
557 return Tok.
isOneOf(tok::l_square, tok::r_square);
560 bool isTokenBrace()
const {
561 return Tok.
isOneOf(tok::l_brace, tok::r_brace);
564 bool isTokenStringLiteral()
const {
568 bool isTokenSpecial()
const {
569 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
570 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
575 bool isTokenEqualOrEqualTypo();
579 void UnconsumeToken(Token &Consumed) {
586 SourceLocation ConsumeAnnotationToken() {
596 SourceLocation ConsumeParen() {
597 assert(isTokenParen() &&
"wrong consume method");
598 if (Tok.
getKind() == tok::l_paren)
600 else if (ParenCount) {
601 AngleBrackets.clear(*
this);
606 return PrevTokLocation;
611 SourceLocation ConsumeBracket() {
612 assert(isTokenBracket() &&
"wrong consume method");
613 if (Tok.
getKind() == tok::l_square)
615 else if (BracketCount) {
616 AngleBrackets.clear(*
this);
622 return PrevTokLocation;
627 SourceLocation ConsumeBrace() {
628 assert(isTokenBrace() &&
"wrong consume method");
629 if (Tok.
getKind() == tok::l_brace)
631 else if (BraceCount) {
632 AngleBrackets.clear(*
this);
638 return PrevTokLocation;
645 SourceLocation ConsumeStringToken() {
646 assert(isTokenStringLiteral() &&
647 "Should only consume string literals with this method");
650 return PrevTokLocation;
658 SourceLocation ConsumeCodeCompletionToken() {
659 assert(Tok.
is(tok::code_completion));
662 return PrevTokLocation;
670 SourceLocation handleUnexpectedCodeCompletionToken();
674 void cutOffParsing() {
686 Kind == tok::annot_module_end ||
Kind == tok::annot_module_include;
696 void initializePragmaHandlers();
699 void resetPragmaHandlers();
702 void HandlePragmaUnused();
706 void HandlePragmaVisibility();
710 void HandlePragmaPack();
714 void HandlePragmaMSStruct();
716 void HandlePragmaMSPointersToMembers();
718 void HandlePragmaMSVtorDisp();
720 void HandlePragmaMSPragma();
721 bool HandlePragmaMSSection(StringRef PragmaName,
722 SourceLocation PragmaLocation);
723 bool HandlePragmaMSSegment(StringRef PragmaName,
724 SourceLocation PragmaLocation);
725 bool HandlePragmaMSInitSeg(StringRef PragmaName,
726 SourceLocation PragmaLocation);
727 bool HandlePragmaMSFunction(StringRef PragmaName,
728 SourceLocation PragmaLocation);
729 bool HandlePragmaMSAllocText(StringRef PragmaName,
730 SourceLocation PragmaLocation);
734 void HandlePragmaAlign();
738 void HandlePragmaDump();
742 void HandlePragmaWeak();
746 void HandlePragmaWeakAlias();
750 void HandlePragmaRedefineExtname();
754 void HandlePragmaFPContract();
758 void HandlePragmaFEnvAccess();
762 void HandlePragmaFEnvRound();
766 void HandlePragmaFloatControl();
770 void HandlePragmaFP();
774 void HandlePragmaOpenCLExtension();
782 bool HandlePragmaLoopHint(LoopHint &Hint);
784 bool ParsePragmaAttributeSubjectMatchRuleSet(
786 SourceLocation &AnyLoc, SourceLocation &LastMatchRuleEndLoc);
788 void HandlePragmaAttribute();
797 const Token &GetLookAheadToken(
unsigned N) {
819 "produced a valid-but-null type annotation?");
823 static NamedDecl *getNonTypeAnnotation(
const Token &Tok) {
824 return static_cast<NamedDecl*
>(Tok.getAnnotationValue());
827 static void setNonTypeAnnotation(Token &Tok, NamedDecl *ND) {
828 Tok.setAnnotationValue(ND);
831 static IdentifierInfo *getIdentifierAnnotation(
const Token &Tok) {
832 return static_cast<IdentifierInfo*
>(Tok.getAnnotationValue());
835 static void setIdentifierAnnotation(Token &Tok, IdentifierInfo *ND) {
836 Tok.setAnnotationValue(ND);
841 static ExprResult getExprAnnotation(
const Token &Tok) {
842 return ExprResult::getFromOpaquePointer(Tok.getAnnotationValue());
847 static void setExprAnnotation(Token &Tok,
ExprResult ER) {
848 Tok.setAnnotationValue(ER.getAsOpaquePointer());
860 return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
861 (Tok.is(tok::annot_template_id) &&
863 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
870 enum AnnotatedNameKind {
882 AnnotatedNameKind TryAnnotateName(CorrectionCandidateCallback *CCC =
nullptr);
885 void AnnotateScopeToken(CXXScopeSpec &SS,
bool IsNewAnnotation);
890 bool TryAltiVecToken(DeclSpec &DS, SourceLocation Loc,
891 const char *&PrevSpec,
unsigned &DiagID,
896 if (Tok.getIdentifierInfo() != Ident_vector &&
897 Tok.getIdentifierInfo() != Ident_bool &&
898 Tok.getIdentifierInfo() != Ident_Bool &&
899 (!
getLangOpts().AltiVec || Tok.getIdentifierInfo() != Ident_pixel))
902 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID,
isInvalid);
908 bool TryAltiVecVectorToken() {
910 Tok.getIdentifierInfo() != Ident_vector)
return false;
911 return TryAltiVecVectorTokenOutOfLine();
914 bool TryAltiVecVectorTokenOutOfLine();
915 bool TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
916 const char *&PrevSpec,
unsigned &DiagID,
922 bool isObjCInstancetype() {
924 if (Tok.isAnnotation())
926 if (!Ident_instancetype)
928 return Tok.getIdentifierInfo() == Ident_instancetype;
936 bool TryKeywordIdentFallback(
bool DisableKeyword);
939 TemplateIdAnnotation *takeTemplateIdAnnotation(
const Token &tok);
952 class TentativeParsingAction {
954 PreferredTypeBuilder PrevPreferredType;
956 size_t PrevTentativelyDeclaredIdentifierCount;
957 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
961 explicit TentativeParsingAction(
Parser &p)
962 :
P(p), PrevPreferredType(
P.PreferredType) {
964 PrevTentativelyDeclaredIdentifierCount =
965 P.TentativelyDeclaredIdentifiers.size();
966 PrevParenCount =
P.ParenCount;
967 PrevBracketCount =
P.BracketCount;
968 PrevBraceCount =
P.BraceCount;
969 P.PP.EnableBacktrackAtThisPos();
973 assert(isActive &&
"Parsing action was finished!");
974 P.TentativelyDeclaredIdentifiers.resize(
975 PrevTentativelyDeclaredIdentifierCount);
976 P.PP.CommitBacktrackedTokens();
980 assert(isActive &&
"Parsing action was finished!");
982 P.PreferredType = PrevPreferredType;
984 P.TentativelyDeclaredIdentifiers.resize(
985 PrevTentativelyDeclaredIdentifierCount);
986 P.ParenCount = PrevParenCount;
987 P.BracketCount = PrevBracketCount;
988 P.BraceCount = PrevBraceCount;
991 ~TentativeParsingAction() {
992 assert(!isActive &&
"Forgot to call Commit or Revert!");
997 class RevertingTentativeParsingAction
998 :
private Parser::TentativeParsingAction {
1000 RevertingTentativeParsingAction(
Parser &
P)
1001 :
Parser::TentativeParsingAction(
P) {}
1002 ~RevertingTentativeParsingAction() { Revert(); }
1005 class UnannotatedTentativeParsingAction;
1012 ObjCContainerDecl *DC;
1013 SaveAndRestore<bool> WithinObjCContainer;
1017 WithinObjCContainer(
P.ParsingInObjCContainer, DC != nullptr) {
1019 P.Actions.ActOnObjCTemporaryExitContainerContext(DC);
1023 P.Actions.ActOnObjCReenterContainerContext(DC);
1036 unsigned Diag = diag::err_expected,
1037 StringRef DiagMsg =
"");
1044 bool ExpectAndConsumeSemi(
unsigned DiagID);
1047 enum ExtraSemiKind {
1048 OutsideFunction = 0,
1050 InstanceVariableList = 2,
1051 AfterMemberFunctionDefinition = 3
1063 bool expectIdentifier();
1066 enum class CompoundToken {
1081 void checkCompoundToken(SourceLocation FirstTokLoc,
1104 bool BeforeCompoundStmt =
false)
1106 if (EnteredScope && !BeforeCompoundStmt)
1109 if (BeforeCompoundStmt)
1112 this->Self =
nullptr;
1134 unsigned NumScopes = 0;
1166 class ParseScopeFlags {
1169 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
1170 void operator=(
const ParseScopeFlags &) =
delete;
1173 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
1181 DiagnosticBuilder
Diag(SourceLocation Loc,
unsigned DiagID);
1182 DiagnosticBuilder
Diag(
const Token &Tok,
unsigned DiagID);
1184 return Diag(Tok, DiagID);
1205 static_cast<unsigned>(R));
1219 return SkipUntil(llvm::makeArrayRef(T), Flags);
1247 struct ParsingClass;
1257 class LateParsedDeclaration {
1259 virtual ~LateParsedDeclaration();
1261 virtual void ParseLexedMethodDeclarations();
1262 virtual void ParseLexedMemberInitializers();
1263 virtual void ParseLexedMethodDefs();
1264 virtual void ParseLexedAttributes();
1265 virtual void ParseLexedPragmas();
1270 class LateParsedClass :
public LateParsedDeclaration {
1272 LateParsedClass(
Parser *
P, ParsingClass *C);
1273 ~LateParsedClass()
override;
1275 void ParseLexedMethodDeclarations()
override;
1276 void ParseLexedMemberInitializers()
override;
1277 void ParseLexedMethodDefs()
override;
1278 void ParseLexedAttributes()
override;
1279 void ParseLexedPragmas()
override;
1283 ParsingClass *Class;
1292 struct LateParsedAttribute :
public LateParsedDeclaration {
1295 IdentifierInfo &AttrName;
1296 IdentifierInfo *MacroII =
nullptr;
1297 SourceLocation AttrNameLoc;
1298 SmallVector<Decl*, 2> Decls;
1300 explicit LateParsedAttribute(
Parser *
P, IdentifierInfo &Name,
1302 : Self(
P), AttrName(Name), AttrNameLoc(Loc) {}
1304 void ParseLexedAttributes()
override;
1306 void addDecl(Decl *D) { Decls.push_back(D); }
1313 class LateParsedPragma :
public LateParsedDeclaration {
1320 : Self(
P), AS(AS) {}
1322 void takeToks(
CachedTokens &Cached) { Toks.swap(Cached); }
1326 void ParseLexedPragmas()
override;
1330 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1332 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1334 bool parseSoon() {
return ParseSoon; }
1343 struct LexedMethod :
public LateParsedDeclaration {
1348 explicit LexedMethod(
Parser *
P, Decl *MD) : Self(
P), D(MD) {}
1350 void ParseLexedMethodDefs()
override;
1357 struct LateParsedDefaultArgument {
1358 explicit LateParsedDefaultArgument(Decl *
P,
1359 std::unique_ptr<CachedTokens> Toks =
nullptr)
1360 : Param(
P), Toks(
std::move(Toks)) { }
1369 std::unique_ptr<CachedTokens> Toks;
1376 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1377 explicit LateParsedMethodDeclaration(
Parser *
P, Decl *M)
1378 : Self(
P), Method(M), ExceptionSpecTokens(nullptr) {}
1380 void ParseLexedMethodDeclarations()
override;
1392 SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
1402 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1403 LateParsedMemberInitializer(
Parser *
P, Decl *FD)
1406 void ParseLexedMemberInitializers()
override;
1424 typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer;
1429 struct ParsingClass {
1430 ParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1431 : TopLevelClass(TopLevelClass), IsInterface(IsInterface),
1432 TagOrTemplate(TagOrTemplate) {}
1436 bool TopLevelClass : 1;
1439 bool IsInterface : 1;
1442 Decl *TagOrTemplate;
1447 LateParsedDeclarationsContainer LateParsedDeclarations;
1453 std::stack<ParsingClass *> ClassStack;
1455 ParsingClass &getCurrentClass() {
1456 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1457 return *ClassStack.top();
1461 class ParsingClassDefinition {
1467 ParsingClassDefinition(
Parser &
P, Decl *TagOrTemplate,
bool TopLevelClass,
1470 State(
P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1475 assert(!Popped &&
"Nested class has already been popped");
1477 P.PopParsingClass(
State);
1480 ~ParsingClassDefinition() {
1482 P.PopParsingClass(
State);
1489 struct ParsedTemplateInfo {
1490 ParsedTemplateInfo() :
Kind(NonTemplate), TemplateParams(nullptr) {}
1493 bool isSpecialization,
1494 bool lastParameterListWasEmpty =
false)
1495 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1496 TemplateParams(TemplateParams),
1497 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1499 explicit ParsedTemplateInfo(SourceLocation ExternLoc,
1500 SourceLocation TemplateLoc)
1501 :
Kind(ExplicitInstantiation), TemplateParams(nullptr),
1502 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1503 LastParameterListWasEmpty(
false){ }
1512 ExplicitSpecialization,
1514 ExplicitInstantiation
1523 SourceLocation ExternLoc;
1527 SourceLocation TemplateLoc;
1530 bool LastParameterListWasEmpty;
1536 struct ReenterTemplateScopeRAII;
1537 struct ReenterClassScopeRAII;
1539 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1540 void ParseLateTemplatedFuncDef(LateParsedTemplate &LPT);
1542 static
void LateTemplateParserCallback(
void *
P, LateParsedTemplate &LPT);
1544 Sema::ParsingClassState
1545 PushParsingClass(Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1546 void DeallocateParsedClasses(ParsingClass *Class);
1547 void PopParsingClass(Sema::ParsingClassState);
1549 enum CachedInitKind {
1550 CIK_DefaultArgument,
1551 CIK_DefaultInitializer
1555 const ParsedAttributesView &AccessAttrs,
1556 ParsingDeclarator &D,
1557 const ParsedTemplateInfo &TemplateInfo,
1558 const VirtSpecifiers &VS,
1559 SourceLocation PureSpecLoc);
1560 void ParseCXXNonStaticMemberInitializer(Decl *VarD);
1561 void ParseLexedAttributes(ParsingClass &Class);
1562 void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
1564 void ParseLexedAttribute(LateParsedAttribute &LA,
1566 void ParseLexedMethodDeclarations(ParsingClass &Class);
1567 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1568 void ParseLexedMethodDefs(ParsingClass &Class);
1569 void ParseLexedMethodDef(LexedMethod &LM);
1570 void ParseLexedMemberInitializers(ParsingClass &Class);
1571 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1572 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1573 void ParseLexedPragmas(ParsingClass &Class);
1574 void ParseLexedPragma(LateParsedPragma &LP);
1575 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1576 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1581 bool ConsumeFinalToken =
true) {
1582 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1587 bool ConsumeFinalToken =
true);
1592 ParsingDeclSpec *DS =
nullptr);
1593 bool isDeclarationAfterDeclarator();
1594 bool isStartOfFunctionDefinition(
const ParsingDeclarator &Declarator);
1596 ParseDeclarationOrFunctionDefinition(ParsedAttributes &Attrs,
1597 ParsingDeclSpec *DS =
nullptr,
1599 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributes &Attrs,
1600 ParsingDeclSpec &DS,
1603 void SkipFunctionBody();
1604 Decl *ParseFunctionDefinition(ParsingDeclarator &D,
1605 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1606 LateParsedAttrList *LateParsedAttrs =
nullptr);
1607 void ParseKNRParamDeclarations(Declarator &D);
1609 ExprResult ParseSimpleAsm(
bool ForAsmLabel, SourceLocation *EndLoc);
1610 ExprResult ParseAsmStringLiteral(
bool ForAsmLabel);
1615 DeclGroupPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
1616 Decl *ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
1617 ParsedAttributes &prefixAttrs);
1618 class ObjCTypeParamListScope;
1619 ObjCTypeParamList *parseObjCTypeParamList();
1620 ObjCTypeParamList *parseObjCTypeParamListOrProtocolRefs(
1621 ObjCTypeParamListScope &Scope, SourceLocation &lAngleLoc,
1622 SmallVectorImpl<IdentifierLocPair> &protocolIdents,
1623 SourceLocation &rAngleLoc,
bool mayBeProtocolList =
true);
1625 void HelperActionsForIvarDeclarations(ObjCContainerDecl *interfaceDecl,
1626 SourceLocation atLoc,
1628 SmallVectorImpl<Decl *> &AllIvarDecls,
1629 bool RBraceMissing);
1630 void ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
1632 SourceLocation atLoc);
1633 bool ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &
P,
1634 SmallVectorImpl<SourceLocation> &PLocs,
1635 bool WarnOnDeclarations,
1636 bool ForObjCContainer,
1637 SourceLocation &LAngleLoc,
1638 SourceLocation &EndProtoLoc,
1639 bool consumeLastToken);
1644 void parseObjCTypeArgsOrProtocolQualifiers(
1646 SourceLocation &typeArgsLAngleLoc,
1647 SmallVectorImpl<ParsedType> &typeArgs,
1648 SourceLocation &typeArgsRAngleLoc,
1649 SourceLocation &protocolLAngleLoc,
1650 SmallVectorImpl<Decl *> &protocols,
1651 SmallVectorImpl<SourceLocation> &protocolLocs,
1652 SourceLocation &protocolRAngleLoc,
1653 bool consumeLastToken,
1654 bool warnOnIncompleteProtocols);
1658 void parseObjCTypeArgsAndProtocolQualifiers(
1660 SourceLocation &typeArgsLAngleLoc,
1661 SmallVectorImpl<ParsedType> &typeArgs,
1662 SourceLocation &typeArgsRAngleLoc,
1663 SourceLocation &protocolLAngleLoc,
1664 SmallVectorImpl<Decl *> &protocols,
1665 SmallVectorImpl<SourceLocation> &protocolLocs,
1666 SourceLocation &protocolRAngleLoc,
1667 bool consumeLastToken);
1671 TypeResult parseObjCProtocolQualifierType(SourceLocation &rAngleLoc);
1675 TypeResult parseObjCTypeArgsAndProtocolQualifiers(SourceLocation loc,
1677 bool consumeLastToken,
1678 SourceLocation &endLoc);
1682 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
1683 ParsedAttributes &prefixAttrs);
1685 struct ObjCImplParsingDataRAII {
1689 typedef SmallVector<LexedMethod*, 8> LateParsedObjCMethodContainer;
1690 LateParsedObjCMethodContainer LateParsedObjCMethods;
1692 ObjCImplParsingDataRAII(
Parser &parser, Decl *D)
1693 :
P(parser), Dcl(D), HasCFunction(
false) {
1694 P.CurParsedObjCImpl =
this;
1697 ~ObjCImplParsingDataRAII();
1699 void finish(SourceRange AtEnd);
1700 bool isFinished()
const {
return Finished; }
1705 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1706 void StashAwayMethodOrFunctionBodyTokens(Decl *MDecl);
1708 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
1709 ParsedAttributes &Attrs);
1711 Decl *ParseObjCAtAliasDeclaration(SourceLocation atLoc);
1712 Decl *ParseObjCPropertySynthesize(SourceLocation atLoc);
1713 Decl *ParseObjCPropertyDynamic(SourceLocation atLoc);
1715 IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
1718 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1719 objc_nonnull, objc_nullable, objc_null_unspecified,
1722 IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
1724 bool isTokIdentifier_in()
const;
1727 ParsedAttributes *ParamAttrs);
1728 Decl *ParseObjCMethodPrototype(
1730 bool MethodDefinition =
true);
1733 bool MethodDefinition=
true);
1734 void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
1736 Decl *ParseObjCMethodDefinition();
1762 unsigned &NumLineToksConsumed,
1763 bool IsUnevaluated);
1775 enum CastParseKind {
1780 ExprResult ParseCastExpression(CastParseKind ParseKind,
1781 bool isAddressOfOperand,
1784 bool isVectorLiteral =
false,
1785 bool *NotPrimaryExpression =
nullptr);
1786 ExprResult ParseCastExpression(CastParseKind ParseKind,
1787 bool isAddressOfOperand =
false,
1789 bool isVectorLiteral =
false,
1790 bool *NotPrimaryExpression =
nullptr);
1793 bool isNotExpressionStart();
1797 bool isPostfixExpressionSuffixStart() {
1799 return (K == tok::l_square || K == tok::l_paren ||
1800 K == tok::period || K == tok::arrow ||
1801 K == tok::plusplus || K == tok::minusminus);
1804 bool diagnoseUnknownTemplateId(
ExprResult TemplateName, SourceLocation Less);
1805 void checkPotentialAngleBracket(
ExprResult &PotentialTemplateName);
1806 bool checkPotentialAngleBracketDelimiter(
const AngleBracketTracker::Loc &,
1807 const Token &OpToken);
1808 bool checkPotentialAngleBracketDelimiter(
const Token &OpToken) {
1809 if (
auto *Info = AngleBrackets.getCurrent(*
this))
1810 return checkPotentialAngleBracketDelimiter(*Info, OpToken);
1815 ExprResult ParseUnaryExprOrTypeTraitExpression();
1817 ExprResult ParseSYCLUniqueStableNameExpression();
1819 ExprResult ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1822 SourceRange &CastRange);
1824 typedef SmallVector<SourceLocation, 20> CommaLocsTy;
1827 bool ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
1828 SmallVectorImpl<SourceLocation> &CommaLocs,
1829 llvm::function_ref<
void()> ExpressionStarts =
1830 llvm::function_ref<
void()>(),
1831 bool FailImmediatelyOnInvalidExpr =
false,
1832 bool EarlyTypoCorrection =
false);
1836 bool ParseSimpleExpressionList(SmallVectorImpl<Expr*> &Exprs,
1837 SmallVectorImpl<SourceLocation> &CommaLocs);
1841 enum ParenParseOption {
1848 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1849 bool stopIfCastExpr,
1852 SourceLocation &RParenLoc);
1855 ParenParseOption &ExprType,
ParsedType &CastTy,
1858 SourceLocation LParenLoc,
1859 SourceLocation RParenLoc);
1861 ExprResult ParseGenericSelectionExpression();
1869 ExprResult tryParseCXXIdExpression(CXXScopeSpec &SS,
bool isAddressOfOperand,
1870 Token &Replacement);
1871 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1873 bool areTokensAdjacent(
const Token &A,
const Token &B);
1875 void CheckForTemplateAndDigraph(Token &Next,
ParsedType ObjectTypePtr,
1876 bool EnteringContext, IdentifierInfo &II,
1879 bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
1881 bool ObjectHasErrors,
1882 bool EnteringContext,
1883 bool *MayBePseudoDestructor =
nullptr,
1884 bool IsTypename =
false,
1885 IdentifierInfo **LastII =
nullptr,
1886 bool OnlyNamespace =
false,
1887 bool InUsingDeclaration =
false);
1893 enum class LambdaIntroducerTentativeParse {
1910 ParseLambdaIntroducer(LambdaIntroducer &Intro,
1911 LambdaIntroducerTentativeParse *Tentative =
nullptr);
1912 ExprResult ParseLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro);
1931 ExprResult ParseCXXPseudoDestructor(Expr *
Base, SourceLocation OpLoc,
1946 SourceRange &SpecificationRange,
1947 SmallVectorImpl<ParsedType> &DynamicExceptions,
1948 SmallVectorImpl<SourceRange> &DynamicExceptionRanges,
1954 SourceRange &SpecificationRange,
1955 SmallVectorImpl<ParsedType> &Exceptions,
1956 SmallVectorImpl<SourceRange> &Ranges);
1960 TypeResult ParseTrailingReturnType(SourceRange &Range,
1961 bool MayBeFollowedByDirectInit);
1969 ExprResult ParseCXXTypeConstructExpression(
const DeclSpec &DS);
1974 void ParseCXXSimpleTypeSpecifier(DeclSpec &DS);
1976 bool ParseCXXTypeSpecifierSeq(DeclSpec &DS);
1980 bool ParseExpressionListOrTypeId(SmallVectorImpl<Expr*> &Exprs,
1982 void ParseDirectNewDeclarator(Declarator &D);
1983 ExprResult ParseCXXNewExpression(
bool UseGlobal, SourceLocation Start);
1984 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1985 SourceLocation Start);
1989 struct ForRangeInfo;
1990 Sema::ConditionResult ParseCXXCondition(
StmtResult *InitStmt,
1994 ForRangeInfo *FRI =
nullptr,
1995 bool EnterForConditionScope =
false);
1997 ParsedAttributes &Attrs);
2008 void ParseTrailingRequiresClause(Declarator &D);
2018 if (Tok.isNot(tok::l_brace))
2020 return ParseBraceInitializer();
2022 bool MayBeDesignationStart();
2024 struct DesignatorCompletionInfo {
2025 SmallVectorImpl<Expr *> &InitExprs;
2026 QualType PreferredBaseType;
2028 ExprResult ParseInitializerWithPotentialDesignator(DesignatorCompletionInfo);
2037 ExprResult ParseObjCAtExpression(SourceLocation AtLocation);
2038 ExprResult ParseObjCStringLiteral(SourceLocation AtLoc);
2039 ExprResult ParseObjCCharacterLiteral(SourceLocation AtLoc);
2040 ExprResult ParseObjCNumericLiteral(SourceLocation AtLoc);
2041 ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc,
bool ArgValue);
2042 ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
2043 ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
2044 ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
2045 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
2046 ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
2047 ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
2048 bool isSimpleObjCMessageExpression();
2050 ExprResult ParseObjCMessageExpressionBody(SourceLocation LBracloc,
2051 SourceLocation SuperLoc,
2053 Expr *ReceiverExpr);
2054 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
2055 SourceLocation LBracloc, SourceLocation SuperLoc,
2056 ParsedType ReceiverType, Expr *ReceiverExpr);
2057 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
2064 typedef SmallVector<Stmt*, 32> StmtVector;
2066 typedef SmallVector<Expr*, 12> ExprVector;
2068 typedef SmallVector<ParsedType, 12> TypeVector;
2071 ParseStatement(SourceLocation *TrailingElseLoc =
nullptr,
2072 ParsedStmtContext StmtCtx = ParsedStmtContext::SubStmt);
2074 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2075 SourceLocation *TrailingElseLoc =
nullptr);
2076 StmtResult ParseStatementOrDeclarationAfterAttributes(
2077 StmtVector &Stmts, ParsedStmtContext StmtCtx,
2078 SourceLocation *TrailingElseLoc, ParsedAttributes &Attrs);
2079 StmtResult ParseExprStatement(ParsedStmtContext StmtCtx);
2080 StmtResult ParseLabeledStatement(ParsedAttributes &Attrs,
2081 ParsedStmtContext StmtCtx);
2082 StmtResult ParseCaseStatement(ParsedStmtContext StmtCtx,
2083 bool MissingCase =
false,
2085 StmtResult ParseDefaultStatement(ParsedStmtContext StmtCtx);
2086 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
2087 StmtResult ParseCompoundStatement(
bool isStmtExpr,
2088 unsigned ScopeFlags);
2089 void ParseCompoundStatementLeadingPragmas();
2090 bool ConsumeNullStmt(StmtVector &Stmts);
2091 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
2092 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
2093 Sema::ConditionResult &CondResult,
2095 bool MissingOK, SourceLocation *LParenLoc,
2096 SourceLocation *RParenLoc);
2097 StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc);
2098 StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc);
2099 StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc);
2101 StmtResult ParseForStatement(SourceLocation *TrailingElseLoc);
2107 StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc);
2108 StmtResult ParsePragmaLoopHint(StmtVector &Stmts, ParsedStmtContext StmtCtx,
2109 SourceLocation *TrailingElseLoc,
2110 ParsedAttributes &Attrs);
2114 enum IfExistsBehavior {
2126 struct IfExistsCondition {
2128 SourceLocation KeywordLoc;
2141 IfExistsBehavior Behavior;
2144 bool ParseMicrosoftIfExistsCondition(IfExistsCondition& Result);
2145 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
2146 void ParseMicrosoftIfExistsExternalDeclaration();
2147 void ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
2148 ParsedAttributes &AccessAttrs,
2150 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
2152 bool ParseAsmOperandsOpt(SmallVectorImpl<IdentifierInfo *> &Names,
2153 SmallVectorImpl<Expr *> &Constraints,
2154 SmallVectorImpl<Expr *> &Exprs);
2160 StmtResult ParseCXXTryBlockCommon(SourceLocation TryLoc,
bool FnTry =
false);
2161 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
2167 StmtResult ParseSEHExceptBlock(SourceLocation Loc);
2168 StmtResult ParseSEHFinallyBlock(SourceLocation Loc);
2174 StmtResult ParseObjCAtStatement(SourceLocation atLoc,
2175 ParsedStmtContext StmtCtx);
2176 StmtResult ParseObjCTryStmt(SourceLocation atLoc);
2177 StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
2178 StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
2179 StmtResult ParseObjCAutoreleasePoolStmt(SourceLocation atLoc);
2188 enum class DeclSpecContext {
2193 DSC_alias_declaration,
2196 DSC_template_type_arg,
2197 DSC_objc_method_result,
2203 static bool isTypeSpecifier(DeclSpecContext DSC) {
2205 case DeclSpecContext::DSC_normal:
2206 case DeclSpecContext::DSC_template_param:
2207 case DeclSpecContext::DSC_class:
2208 case DeclSpecContext::DSC_top_level:
2209 case DeclSpecContext::DSC_objc_method_result:
2210 case DeclSpecContext::DSC_condition:
2213 case DeclSpecContext::DSC_template_type_arg:
2214 case DeclSpecContext::DSC_type_specifier:
2215 case DeclSpecContext::DSC_trailing:
2216 case DeclSpecContext::DSC_alias_declaration:
2219 llvm_unreachable(
"Missing DeclSpecContext case");
2223 enum class AllowDefiningTypeSpec {
2240 static AllowDefiningTypeSpec
2241 isDefiningTypeSpecifierContext(DeclSpecContext DSC) {
2243 case DeclSpecContext::DSC_normal:
2244 case DeclSpecContext::DSC_class:
2245 case DeclSpecContext::DSC_top_level:
2246 case DeclSpecContext::DSC_alias_declaration:
2247 case DeclSpecContext::DSC_objc_method_result:
2248 return AllowDefiningTypeSpec::Yes;
2250 case DeclSpecContext::DSC_condition:
2251 case DeclSpecContext::DSC_template_param:
2252 return AllowDefiningTypeSpec::YesButInvalid;
2254 case DeclSpecContext::DSC_template_type_arg:
2255 case DeclSpecContext::DSC_type_specifier:
2256 return AllowDefiningTypeSpec::NoButErrorRecovery;
2258 case DeclSpecContext::DSC_trailing:
2259 return AllowDefiningTypeSpec::No;
2261 llvm_unreachable(
"Missing DeclSpecContext case");
2265 static bool isOpaqueEnumDeclarationContext(DeclSpecContext DSC) {
2267 case DeclSpecContext::DSC_normal:
2268 case DeclSpecContext::DSC_class:
2269 case DeclSpecContext::DSC_top_level:
2272 case DeclSpecContext::DSC_alias_declaration:
2273 case DeclSpecContext::DSC_objc_method_result:
2274 case DeclSpecContext::DSC_condition:
2275 case DeclSpecContext::DSC_template_param:
2276 case DeclSpecContext::DSC_template_type_arg:
2277 case DeclSpecContext::DSC_type_specifier:
2278 case DeclSpecContext::DSC_trailing:
2281 llvm_unreachable(
"Missing DeclSpecContext case");
2286 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
2288 case DeclSpecContext::DSC_normal:
2289 case DeclSpecContext::DSC_template_param:
2290 case DeclSpecContext::DSC_class:
2291 case DeclSpecContext::DSC_top_level:
2292 case DeclSpecContext::DSC_condition:
2293 case DeclSpecContext::DSC_type_specifier:
2296 case DeclSpecContext::DSC_objc_method_result:
2297 case DeclSpecContext::DSC_template_type_arg:
2298 case DeclSpecContext::DSC_trailing:
2299 case DeclSpecContext::DSC_alias_declaration:
2302 llvm_unreachable(
"Missing DeclSpecContext case");
2307 struct ForRangeInit {
2308 SourceLocation ColonLoc;
2311 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
2313 struct ForRangeInfo : ForRangeInit {
2318 SourceLocation &DeclEnd,
2319 ParsedAttributes &Attrs,
2320 SourceLocation *DeclSpecStart =
nullptr);
2323 ParsedAttributes &Attrs,
bool RequireSemi,
2324 ForRangeInit *FRI =
nullptr,
2325 SourceLocation *DeclSpecStart =
nullptr);
2328 SourceLocation *DeclEnd =
nullptr,
2329 ForRangeInit *FRI =
nullptr);
2330 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
2331 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
2332 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
2333 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
2335 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2336 ForRangeInit *FRI =
nullptr);
2337 Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
2338 Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
2344 bool trySkippingFunctionBody();
2346 bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2347 const ParsedTemplateInfo &TemplateInfo,
2349 ParsedAttributes &Attrs);
2352 void ParseDeclarationSpecifiers(
2354 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2356 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
2357 LateParsedAttrList *LateAttrs =
nullptr);
2358 bool DiagnoseMissingSemiAfterTagDefinition(
2360 LateParsedAttrList *LateAttrs =
nullptr);
2362 void ParseSpecifierQualifierList(
2364 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
2366 void ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
2369 void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
2370 const ParsedTemplateInfo &TemplateInfo,
2372 void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl);
2373 void ParseStructUnionBody(SourceLocation StartLoc,
DeclSpec::TST TagType,
2374 RecordDecl *TagDecl);
2376 void ParseStructDeclaration(
2377 ParsingDeclSpec &DS,
2378 llvm::function_ref<
void(ParsingFieldDeclarator &)> FieldsCallback);
2380 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
2381 bool isTypeSpecifierQualifier();
2386 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
2391 bool isKnownToBeDeclarationSpecifier() {
2393 return isCXXDeclarationSpecifier() == TPResult::True;
2394 return isDeclarationSpecifier(
true);
2400 bool isDeclarationStatement() {
2402 return isCXXDeclarationStatement();
2403 return isDeclarationSpecifier(
true);
2410 bool isForInitDeclaration() {
2414 return Tok.is(tok::kw_using) ||
2415 isCXXSimpleDeclaration(
true);
2416 return isDeclarationSpecifier(
true);
2420 bool isForRangeIdentifier();
2424 bool isStartOfObjCClassMessageMissingOpenBracket();
2429 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2433 enum TentativeCXXTypeIdContext {
2436 TypeIdAsTemplateArgument
2443 bool isTypeIdInParens(
bool &isAmbiguous) {
2445 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2446 isAmbiguous =
false;
2447 return isTypeSpecifierQualifier();
2449 bool isTypeIdInParens() {
2451 return isTypeIdInParens(isAmbiguous);
2457 bool isTypeIdUnambiguously() {
2460 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2461 return isTypeSpecifierQualifier();
2467 bool isCXXDeclarationStatement();
2474 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2483 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2485 struct ConditionDeclarationOrInitStatementState;
2486 enum class ConditionOrInitStatement {
2496 ConditionOrInitStatement
2497 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt,
2498 bool CanBeForRangeDecl);
2500 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2501 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2503 return isCXXTypeId(Context, isAmbiguous);
2508 enum class TPResult {
2509 True, False, Ambiguous,
Error
2519 bool isEnumBase(
bool AllowSemi);
2529 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2530 bool *InvalidAsDeclSpec =
nullptr);
2535 bool isCXXDeclarationSpecifierAType();
2540 TPResult isTemplateArgumentList(
unsigned TokensToSkip);
2545 TPResult isExplicitBool();
2550 bool isTentativelyDeclared(IdentifierInfo *II);
2559 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2560 TPResult TryParseTypeofSpecifier();
2561 TPResult TryParseProtocolQualifiers();
2562 TPResult TryParsePtrOperatorSeq();
2563 TPResult TryParseOperatorId();
2564 TPResult TryParseInitDeclaratorList();
2565 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier =
true,
2566 bool mayHaveDirectInit =
false);
2568 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2569 bool VersusTemplateArg =
false);
2570 TPResult TryParseFunctionDeclarator();
2571 TPResult TryParseBracketDeclarator();
2572 TPResult TryConsumeDeclarationSpecifier();
2576 bool TrySkipAttributes();
2580 void DiagnoseBitIntUse(
const Token &Tok);
2587 ParsedAttributes *Attrs =
nullptr);
2590 void ParseBlockId(SourceLocation CaretLoc);
2593 bool standardAttributesAllowed()
const {
2595 return LO.DoubleSquareBracketAttributes;
2600 bool CheckProhibitedCXX11Attribute() {
2601 assert(Tok.is(tok::l_square));
2602 if (!standardAttributesAllowed() ||
NextToken().isNot(tok::l_square))
2604 return DiagnoseProhibitedCXX11Attribute();
2607 bool DiagnoseProhibitedCXX11Attribute();
2608 void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2609 SourceLocation CorrectLocation) {
2610 if (!standardAttributesAllowed())
2612 if ((Tok.isNot(tok::l_square) ||
NextToken().isNot(tok::l_square)) &&
2613 Tok.isNot(tok::kw_alignas))
2615 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2617 void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
2618 SourceLocation CorrectLocation);
2620 void stripTypeAttributesOffDeclSpec(ParsedAttributes &Attrs, DeclSpec &DS,
2624 void ProhibitAttributes(ParsedAttributes &Attrs,
2625 SourceLocation FixItLoc = SourceLocation()) {
2626 if (Attrs.Range.isInvalid())
2628 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2632 void ProhibitAttributes(ParsedAttributesView &Attrs,
2633 SourceLocation FixItLoc = SourceLocation()) {
2634 if (Attrs.Range.isInvalid())
2636 DiagnoseProhibitedAttributes(Attrs.Range, FixItLoc);
2637 Attrs.clearListOnly();
2639 void DiagnoseProhibitedAttributes(
const SourceRange &Range,
2640 SourceLocation FixItLoc);
2648 void ProhibitCXX11Attributes(ParsedAttributes &Attrs,
unsigned DiagID,
2649 bool DiagnoseEmptyAttrs =
false,
2650 bool WarnOnUnknownAttrs =
false);
2655 SourceLocation SkipCXX11Attributes();
2659 void DiagnoseAndSkipCXX11Attributes();
2663 void DiagnoseCXX11AttributeExtension(ParsedAttributes &Attrs);
2670 ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2671 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2672 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2675 enum ParseAttrKindMask {
2677 PAKM_Declspec = 1 << 1,
2678 PAKM_CXX11 = 1 << 2,
2695 void ParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2696 LateParsedAttrList *LateAttrs =
nullptr);
2699 bool MaybeParseAttributes(
unsigned WhichAttrKinds, ParsedAttributes &Attrs,
2700 LateParsedAttrList *LateAttrs =
nullptr) {
2701 if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec) ||
2702 (standardAttributesAllowed() && isCXX11AttributeSpecifier())) {
2703 ParseAttributes(WhichAttrKinds, Attrs, LateAttrs);
2709 void MaybeParseGNUAttributes(Declarator &D,
2710 LateParsedAttrList *LateAttrs =
nullptr) {
2711 if (Tok.is(tok::kw___attribute)) {
2712 ParsedAttributes Attrs(AttrFactory);
2713 ParseGNUAttributes(Attrs, LateAttrs, &D);
2714 D.takeAttributes(Attrs);
2718 bool MaybeParseGNUAttributes(ParsedAttributes &Attrs,
2719 LateParsedAttrList *LateAttrs =
nullptr) {
2720 if (Tok.is(tok::kw___attribute)) {
2721 ParseGNUAttributes(Attrs, LateAttrs);
2727 void ParseGNUAttributes(ParsedAttributes &Attrs,
2728 LateParsedAttrList *LateAttrs =
nullptr,
2729 Declarator *D =
nullptr);
2730 void ParseGNUAttributeArgs(IdentifierInfo *AttrName,
2731 SourceLocation AttrNameLoc,
2732 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2733 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2735 IdentifierLoc *ParseIdentifierLoc();
2738 ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc,
2739 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2740 IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
2743 void ReplayOpenMPAttributeTokens(
CachedTokens &OpenMPTokens) {
2746 if (!OpenMPTokens.empty()) {
2748 PP.EnterTokenStream(OpenMPTokens,
true,
2753 void MaybeParseCXX11Attributes(Declarator &D) {
2754 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2755 ParsedAttributes Attrs(AttrFactory);
2756 ParseCXX11Attributes(Attrs);
2757 D.takeAttributes(Attrs);
2761 bool MaybeParseCXX11Attributes(ParsedAttributes &Attrs,
2762 bool OuterMightBeMessageSend =
false) {
2763 if (standardAttributesAllowed() &&
2764 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend)) {
2765 ParseCXX11Attributes(Attrs);
2771 void ParseOpenMPAttributeArgs(IdentifierInfo *AttrName,
2774 void ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
2776 SourceLocation *EndLoc =
nullptr);
2777 void ParseCXX11AttributeSpecifier(ParsedAttributes &Attrs,
2778 SourceLocation *EndLoc =
nullptr) {
2780 ParseCXX11AttributeSpecifierInternal(Attrs, OpenMPTokens, EndLoc);
2781 ReplayOpenMPAttributeTokens(OpenMPTokens);
2783 void ParseCXX11Attributes(ParsedAttributes &attrs);
2786 bool ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
2787 SourceLocation AttrNameLoc,
2788 ParsedAttributes &Attrs, SourceLocation *EndLoc,
2789 IdentifierInfo *ScopeName,
2790 SourceLocation ScopeLoc,
2793 IdentifierInfo *TryParseCXX11AttributeIdentifier(
2794 SourceLocation &Loc,
2796 const IdentifierInfo *EnclosingScope =
nullptr);
2798 void MaybeParseHLSLSemantics(ParsedAttributes &Attrs,
2799 SourceLocation *EndLoc =
nullptr) {
2801 ParseHLSLSemantics(Attrs, EndLoc);
2804 void ParseHLSLSemantics(ParsedAttributes &Attrs,
2805 SourceLocation *EndLoc =
nullptr);
2807 void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
2809 Tok.is(tok::l_square)) {
2810 ParsedAttributes AttrsWithRange(AttrFactory);
2811 ParseMicrosoftAttributes(AttrsWithRange);
2812 Attrs.takeAllFrom(AttrsWithRange);
2815 void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
2816 void ParseMicrosoftAttributes(ParsedAttributes &Attrs);
2817 bool MaybeParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
2818 if (
getLangOpts().DeclSpecKeyword && Tok.is(tok::kw___declspec)) {
2819 ParseMicrosoftDeclSpecs(Attrs);
2824 void ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs);
2825 bool ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName,
2826 SourceLocation AttrNameLoc,
2827 ParsedAttributes &Attrs);
2828 void ParseMicrosoftTypeAttributes(ParsedAttributes &attrs);
2829 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2830 SourceLocation SkipExtendedMicrosoftTypeAttributes();
2831 void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
2832 void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
2833 void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
2834 void ParseOpenCLQualifiers(ParsedAttributes &Attrs);
2835 void ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs);
2836 void ParseCUDAFunctionAttributes(ParsedAttributes &attrs);
2838 VersionTuple ParseVersionTuple(SourceRange &Range);
2839 void ParseAvailabilityAttribute(IdentifierInfo &Availability,
2840 SourceLocation AvailabilityLoc,
2841 ParsedAttributes &attrs,
2842 SourceLocation *endLoc,
2843 IdentifierInfo *ScopeName,
2844 SourceLocation ScopeLoc,
2848 ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc);
2850 void ParseExternalSourceSymbolAttribute(IdentifierInfo &ExternalSourceSymbol,
2852 ParsedAttributes &Attrs,
2853 SourceLocation *EndLoc,
2854 IdentifierInfo *ScopeName,
2855 SourceLocation ScopeLoc,
2858 void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated,
2859 SourceLocation ObjCBridgeRelatedLoc,
2860 ParsedAttributes &Attrs,
2861 SourceLocation *EndLoc,
2862 IdentifierInfo *ScopeName,
2863 SourceLocation ScopeLoc,
2866 void ParseSwiftNewTypeAttribute(IdentifierInfo &AttrName,
2867 SourceLocation AttrNameLoc,
2868 ParsedAttributes &Attrs,
2869 SourceLocation *EndLoc,
2870 IdentifierInfo *ScopeName,
2871 SourceLocation ScopeLoc,
2874 void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName,
2875 SourceLocation AttrNameLoc,
2876 ParsedAttributes &Attrs,
2877 SourceLocation *EndLoc,
2878 IdentifierInfo *ScopeName,
2879 SourceLocation ScopeLoc,
2882 void ParseAttributeWithTypeArg(IdentifierInfo &AttrName,
2883 SourceLocation AttrNameLoc,
2884 ParsedAttributes &Attrs,
2885 IdentifierInfo *ScopeName,
2886 SourceLocation ScopeLoc,
2889 void ParseTypeofSpecifier(DeclSpec &DS);
2890 SourceLocation ParseDecltypeSpecifier(DeclSpec &DS);
2891 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2892 SourceLocation StartLoc,
2893 SourceLocation EndLoc);
2894 void ParseUnderlyingTypeSpecifier(DeclSpec &DS);
2895 void ParseAtomicSpecifier(DeclSpec &DS);
2897 ExprResult ParseAlignArgument(SourceLocation Start,
2898 SourceLocation &EllipsisLoc);
2899 void ParseAlignmentSpecifier(ParsedAttributes &Attrs,
2900 SourceLocation *endLoc =
nullptr);
2905 return isCXX11VirtSpecifier(Tok);
2907 void ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
bool IsInterface,
2908 SourceLocation FriendLoc);
2910 bool isCXX11FinalKeyword()
const;
2911 bool isClassCompatibleKeyword()
const;
2916 class DeclaratorScopeObj {
2922 DeclaratorScopeObj(
Parser &p, CXXScopeSpec &ss)
2923 :
P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2925 void EnterDeclaratorScope() {
2926 assert(!EnteredScope &&
"Already entered the scope!");
2927 assert(SS.isSet() &&
"C++ scope was not set!");
2929 CreatedScope =
true;
2932 if (!
P.Actions.ActOnCXXEnterDeclaratorScope(
P.getCurScope(), SS))
2933 EnteredScope =
true;
2936 ~DeclaratorScopeObj() {
2938 assert(SS.isSet() &&
"C++ scope was cleared ?");
2939 P.Actions.ActOnCXXExitDeclaratorScope(
P.getCurScope(), SS);
2947 void ParseDeclarator(Declarator &D);
2950 void ParseDeclaratorInternal(Declarator &D,
2951 DirectDeclParseFunction DirectDeclParser);
2953 enum AttrRequirements {
2954 AR_NoAttributesParsed = 0,
2955 AR_GNUAttributesParsedAndRejected = 1 << 0,
2956 AR_GNUAttributesParsed = 1 << 1,
2957 AR_CXX11AttributesParsed = 1 << 2,
2958 AR_DeclspecAttributesParsed = 1 << 3,
2959 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2960 AR_CXX11AttributesParsed |
2961 AR_DeclspecAttributesParsed,
2962 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2963 AR_DeclspecAttributesParsed
2966 void ParseTypeQualifierListOpt(
2967 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2968 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2969 Optional<llvm::function_ref<
void()>> CodeCompletionHandler = None);
2970 void ParseDirectDeclarator(Declarator &D);
2971 void ParseDecompositionDeclarator(Declarator &D);
2972 void ParseParenDeclarator(Declarator &D);
2973 void ParseFunctionDeclarator(Declarator &D, ParsedAttributes &FirstArgAttrs,
2975 bool IsAmbiguous,
bool RequiresArg =
false);
2976 void InitCXXThisScopeForDeclaratorIfRelevant(
2977 const Declarator &D,
const DeclSpec &DS,
2979 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2980 SourceLocation &RefQualifierLoc);
2981 bool isFunctionDeclaratorIdentifierList();
2982 void ParseFunctionDeclaratorIdentifierList(
2984 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo);
2985 void ParseParameterDeclarationClause(
2987 ParsedAttributes &attrs,
2988 SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
2989 SourceLocation &EllipsisLoc);
2990 void ParseBracketDeclarator(Declarator &D);
2991 void ParseMisplacedBracketDeclarator(Declarator &D);
2997 enum CXX11AttributeKind {
2999 CAK_NotAttributeSpecifier,
3001 CAK_AttributeSpecifier,
3004 CAK_InvalidAttributeSpecifier
3007 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
3008 bool OuterMightBeMessageSend =
false);
3010 void DiagnoseUnexpectedNamespace(NamedDecl *Context);
3013 SourceLocation &DeclEnd,
3014 SourceLocation InlineLoc = SourceLocation());
3016 struct InnerNamespaceInfo {
3017 SourceLocation NamespaceLoc;
3018 SourceLocation InlineLoc;
3019 SourceLocation IdentLoc;
3020 IdentifierInfo *Ident;
3024 void ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
3025 unsigned int index, SourceLocation &InlineLoc,
3026 ParsedAttributes &attrs,
3029 Decl *ParseExportDeclaration();
3032 SourceLocation &DeclEnd, ParsedAttributes &Attrs);
3034 SourceLocation UsingLoc,
3035 SourceLocation &DeclEnd,
3036 ParsedAttributes &attrs);
3038 struct UsingDeclarator {
3039 SourceLocation TypenameLoc;
3042 SourceLocation EllipsisLoc;
3045 TypenameLoc = EllipsisLoc = SourceLocation();
3053 const ParsedTemplateInfo &TemplateInfo,
3054 SourceLocation UsingLoc,
3055 SourceLocation &DeclEnd,
3056 ParsedAttributes &Attrs,
3058 Decl *ParseAliasDeclarationAfterDeclarator(
3059 const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc,
3061 ParsedAttributes &Attrs, Decl **OwnedType =
nullptr);
3063 Decl *ParseStaticAssertDeclaration(SourceLocation &DeclEnd);
3064 Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
3065 SourceLocation AliasLoc, IdentifierInfo *Alias,
3066 SourceLocation &DeclEnd);
3070 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
3071 void ParseClassSpecifier(
tok::TokenKind TagTokKind, SourceLocation TagLoc,
3072 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
3074 DeclSpecContext DSC, ParsedAttributes &Attributes);
3075 void SkipCXXMemberSpecification(SourceLocation StartLoc,
3076 SourceLocation AttrFixitLoc,
3079 void ParseCXXMemberSpecification(SourceLocation StartLoc,
3080 SourceLocation AttrFixitLoc,
3081 ParsedAttributes &Attrs,
unsigned TagType,
3083 ExprResult ParseCXXMemberInitializer(Decl *D,
bool IsFunction,
3084 SourceLocation &EqualLoc);
3086 ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
3089 LateParsedAttrList &LateAttrs);
3090 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
3091 VirtSpecifiers &VS);
3094 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
3095 ParsingDeclRAIIObject *DiagsFromTParams =
nullptr);
3098 ParsedAttributes &AccessAttrs,
3100 void ParseConstructorInitializer(Decl *ConstructorDecl);
3102 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
3107 TypeResult ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
3108 SourceLocation &EndLocation);
3109 void ParseBaseClause(Decl *ClassDecl);
3110 BaseResult ParseBaseSpecifier(Decl *ClassDecl);
3113 bool ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS,
3115 bool ObjectHadErrors,
3116 SourceLocation TemplateKWLoc,
3117 IdentifierInfo *Name,
3118 SourceLocation NameLoc,
3119 bool EnteringContext,
3121 bool AssumeTemplateId);
3122 bool ParseUnqualifiedIdOperator(CXXScopeSpec &SS,
bool EnteringContext,
3124 UnqualifiedId &Result);
3131 SourceLocation Loc);
3135 void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
3136 llvm::omp::TraitSet Set,
3137 llvm::omp::TraitSelector Selector,
3138 llvm::StringMap<SourceLocation> &Seen);
3141 void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
3142 llvm::omp::TraitSet Set,
3143 llvm::StringMap<SourceLocation> &Seen);
3146 void parseOMPTraitSetKind(OMPTraitSet &TISet,
3147 llvm::StringMap<SourceLocation> &Seen);
3150 void parseOMPContextProperty(OMPTraitSelector &TISelector,
3151 llvm::omp::TraitSet Set,
3152 llvm::StringMap<SourceLocation> &Seen);
3155 void parseOMPContextSelector(OMPTraitSelector &TISelector,
3156 llvm::omp::TraitSet Set,
3157 llvm::StringMap<SourceLocation> &SeenSelectors);
3160 void parseOMPContextSelectorSet(OMPTraitSet &TISet,
3161 llvm::StringMap<SourceLocation> &SeenSets);
3164 bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI);
3167 bool parseOpenMPAppendArgs(
3168 SmallVectorImpl<OMPDeclareVariantAttr::InteropType> &InterOpTypes);
3172 bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI,
3173 OMPTraitInfo *ParentTI);
3177 SourceLocation Loc);
3181 SourceLocation Loc);
3184 void ParseOpenMPEndAssumesDirective(SourceLocation Loc);
3187 void ParseOMPDeclareTargetClauses(Sema::DeclareTargetContextInfo &DTCI);
3192 SourceLocation Loc);
3205 SourceLocation MatchingLoc,
3206 SourceLocation FoundLoc,
3207 bool SkipUntilOpenMPEnd);
3213 Decl *TagDecl =
nullptr);
3218 void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm);
3223 TypeResult parseOpenMPDeclareMapperVarDecl(SourceRange &Range,
3224 DeclarationName &Name,
3229 bool tryParseOpenMPArrayShapingCastPart();
3238 bool ParseOpenMPSimpleVarList(
3240 const llvm::function_ref<
void(CXXScopeSpec &, DeclarationNameInfo)> &
3242 bool AllowScopeSpecifier);
3248 StmtResult ParseOpenMPDeclarativeOrExecutableDirective(
3249 ParsedStmtContext StmtCtx,
bool ReadDirectiveWithinMetadirective =
false);
3277 bool ParseOpenMPIndirectClause(Sema::DeclareTargetContextInfo &DTCI,
3292 OMPClause *ParseOpenMPSizesClause();
3333 bool IsAddressOfOperand =
false);
3342 int ExtraModifier = -1;
3351 bool IsMapTypeImplicit =
false;
3360 bool ObjectHadErrors,
bool EnteringContext,
3361 bool AllowDestructorName,
bool AllowConstructorName,
3362 bool AllowDeductionGuide,
3385 Decl *ParseSingleDeclarationAfterTemplate(
3393 bool ParseTemplateParameterList(
unsigned Depth,
3395 TPResult isStartOfTemplateTypeParameter();
3396 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
3397 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
3398 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
3399 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
3400 bool isTypeConstraintAnnotation();
3401 bool TryAnnotateTypeConstraint();
3404 bool AlreadyHasEllipsis,
3405 bool IdentifierHasName);
3406 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
3413 bool ConsumeLastToken,
3414 bool ObjCGenericList);
3415 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
3425 bool AllowTypeAnnotation =
true,
3428 bool IsClassName =
false);
3441 ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
3449 bool parseMisplacedModuleImport();
3450 bool tryParseMisplacedModuleImport() {
3452 if (
Kind == tok::annot_module_begin ||
Kind == tok::annot_module_end ||
3453 Kind == tok::annot_module_include)
3454 return parseMisplacedModuleImport();
3458 bool ParseModuleName(
3474 void CodeCompleteDirective(
bool InConditional)
override;
3475 void CodeCompleteInConditionalExclusion()
override;
3476 void CodeCompleteMacroName(
bool IsDefinition)
override;
3477 void CodeCompletePreprocessorExpression()
override;
3479 unsigned ArgumentIndex)
override;
3480 void CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled)
override;
3481 void CodeCompleteNaturalLanguage()
override;
3483 class GNUAsmQualifiers {
3493 static const char *getQualifierName(AQ Qualifier);
3494 bool setAsmQualifier(AQ Qualifier);
3495 inline bool isVolatile()
const {
return Qualifiers & AQ_volatile; };
3496 inline bool isInline()
const {
return Qualifiers & AQ_inline; };
3497 inline bool isGoto()
const {
return Qualifiers & AQ_goto; }
3499 bool isGCCAsmStatement(
const Token &TokAfterAsm)
const;
3500 bool isGNUAsmQualifier(
const Token &TokAfterAsm)
const;
3501 GNUAsmQualifiers::AQ getGNUAsmQualifier(
const Token &Tok)
const;
3502 bool parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ);