14 #ifndef LLVM_CLANG_PARSE_PARSER_H 15 #define LLVM_CLANG_PARSE_PARSER_H 26 #include "llvm/ADT/SmallVector.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;
41 class ParsingDeclRAIIObject;
42 class ParsingDeclSpec;
43 class ParsingDeclarator;
44 class ParsingFieldDeclarator;
45 class ColonProtectionRAIIObject;
46 class InMessageExpressionRAIIObject;
47 class PoisonSEHIdentifiersRAIIObject;
50 class ObjCTypeParamList;
51 class ObjCTypeParameter;
77 unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
78 unsigned short MisplacedModuleBeginCount = 0;
87 enum { ScopeCacheSize = 16 };
88 unsigned NumCachedScopes;
89 Scope *ScopeCache[ScopeCacheSize];
95 *Ident___exception_code,
96 *Ident_GetExceptionCode;
99 *Ident___exception_info,
100 *Ident_GetExceptionInfo;
103 *Ident___abnormal_termination,
104 *Ident_AbnormalTermination;
147 *Ident_generated_declaration;
156 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind> RevertibleTypeTraits;
158 std::unique_ptr<PragmaHandler> AlignHandler;
159 std::unique_ptr<PragmaHandler> GCCVisibilityHandler;
160 std::unique_ptr<PragmaHandler> OptionsHandler;
161 std::unique_ptr<PragmaHandler> PackHandler;
162 std::unique_ptr<PragmaHandler> MSStructHandler;
163 std::unique_ptr<PragmaHandler> UnusedHandler;
164 std::unique_ptr<PragmaHandler> WeakHandler;
165 std::unique_ptr<PragmaHandler> RedefineExtnameHandler;
166 std::unique_ptr<PragmaHandler> FPContractHandler;
167 std::unique_ptr<PragmaHandler> OpenCLExtensionHandler;
168 std::unique_ptr<PragmaHandler> OpenMPHandler;
169 std::unique_ptr<PragmaHandler> PCSectionHandler;
170 std::unique_ptr<PragmaHandler> MSCommentHandler;
171 std::unique_ptr<PragmaHandler> MSDetectMismatchHandler;
172 std::unique_ptr<PragmaHandler> MSPointersToMembers;
173 std::unique_ptr<PragmaHandler> MSVtorDisp;
174 std::unique_ptr<PragmaHandler> MSInitSeg;
175 std::unique_ptr<PragmaHandler> MSDataSeg;
176 std::unique_ptr<PragmaHandler> MSBSSSeg;
177 std::unique_ptr<PragmaHandler> MSConstSeg;
178 std::unique_ptr<PragmaHandler> MSCodeSeg;
179 std::unique_ptr<PragmaHandler> MSSection;
180 std::unique_ptr<PragmaHandler> MSRuntimeChecks;
181 std::unique_ptr<PragmaHandler> MSIntrinsic;
182 std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler;
183 std::unique_ptr<PragmaHandler> OptimizeHandler;
184 std::unique_ptr<PragmaHandler> LoopHintHandler;
185 std::unique_ptr<PragmaHandler> UnrollHintHandler;
186 std::unique_ptr<PragmaHandler> NoUnrollHintHandler;
187 std::unique_ptr<PragmaHandler> FPHandler;
188 std::unique_ptr<PragmaHandler> AttributePragmaHandler;
190 std::unique_ptr<CommentHandler> CommentSemaHandler;
196 bool GreaterThanIsOperator;
209 bool InMessageExpression;
212 unsigned TemplateParameterDepth;
215 class TemplateParameterDepthRAII {
217 unsigned AddedLevels;
219 explicit TemplateParameterDepthRAII(
unsigned &Depth)
220 : Depth(Depth), AddedLevels(0) {}
222 ~TemplateParameterDepthRAII() {
223 Depth -= AddedLevels;
230 void addDepth(
unsigned D) {
234 unsigned getDepth()
const {
return Depth; }
254 bool ParsingInObjCContainer;
260 bool SkipFunctionBodies;
317 assert(!isTokenSpecial() &&
318 "Should consume special tokens with Consume*Token");
321 return PrevTokLocation;
325 if (Tok.
isNot(Expected))
327 assert(!isTokenSpecial() &&
328 "Should consume special tokens with Consume*Token");
337 Loc = PrevTokLocation;
346 return ConsumeParen();
347 if (isTokenBracket())
348 return ConsumeBracket();
350 return ConsumeBrace();
351 if (isTokenStringLiteral())
352 return ConsumeStringToken();
353 if (Tok.
is(tok::code_completion))
354 return ConsumeCodeCompletionTok ? ConsumeCodeCompletionToken()
355 : handleUnexpectedCodeCompletionToken();
357 return ConsumeAnnotationToken();
378 bool isTokenParen()
const {
379 return Tok.
getKind() == tok::l_paren || Tok.
getKind() == tok::r_paren;
382 bool isTokenBracket()
const {
383 return Tok.
getKind() == tok::l_square || Tok.
getKind() == tok::r_square;
386 bool isTokenBrace()
const {
387 return Tok.
getKind() == tok::l_brace || Tok.
getKind() == tok::r_brace;
390 bool isTokenStringLiteral()
const {
394 bool isTokenSpecial()
const {
395 return isTokenStringLiteral() || isTokenParen() || isTokenBracket() ||
396 isTokenBrace() || Tok.
is(tok::code_completion) || Tok.
isAnnotation();
401 bool isTokenEqualOrEqualTypo();
405 void UnconsumeToken(
Token &Consumed) {
423 assert(isTokenParen() &&
"wrong consume method");
424 if (Tok.
getKind() == tok::l_paren)
430 return PrevTokLocation;
436 assert(isTokenBracket() &&
"wrong consume method");
437 if (Tok.
getKind() == tok::l_square)
439 else if (BracketCount)
444 return PrevTokLocation;
450 assert(isTokenBrace() &&
"wrong consume method");
451 if (Tok.
getKind() == tok::l_brace)
458 return PrevTokLocation;
466 assert(isTokenStringLiteral() &&
467 "Should only consume string literals with this method");
470 return PrevTokLocation;
479 assert(Tok.
is(tok::code_completion));
482 return PrevTokLocation;
494 void cutOffParsing() {
505 return Kind ==
tok::eof || Kind == tok::annot_module_begin ||
506 Kind == tok::annot_module_end || Kind == tok::annot_module_include;
516 void initializePragmaHandlers();
519 void resetPragmaHandlers();
522 void HandlePragmaUnused();
526 void HandlePragmaVisibility();
530 void HandlePragmaPack();
534 void HandlePragmaMSStruct();
538 void HandlePragmaMSComment();
540 void HandlePragmaMSPointersToMembers();
542 void HandlePragmaMSVtorDisp();
544 void HandlePragmaMSPragma();
545 bool HandlePragmaMSSection(StringRef PragmaName,
547 bool HandlePragmaMSSegment(StringRef PragmaName,
549 bool HandlePragmaMSInitSeg(StringRef PragmaName,
554 void HandlePragmaAlign();
558 void HandlePragmaDump();
562 void HandlePragmaWeak();
566 void HandlePragmaWeakAlias();
570 void HandlePragmaRedefineExtname();
574 void HandlePragmaFPContract();
578 void HandlePragmaFP();
582 void HandlePragmaOpenCLExtension();
590 bool HandlePragmaLoopHint(
LoopHint &Hint);
592 bool ParsePragmaAttributeSubjectMatchRuleSet(
596 void HandlePragmaAttribute();
605 const Token &GetLookAheadToken(
unsigned N) {
648 enum AnnotatedNameKind {
661 TryAnnotateName(
bool IsAddressOfOperand,
662 std::unique_ptr<CorrectionCandidateCallback> CCC =
nullptr);
665 void AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation);
671 const char *&PrevSpec,
unsigned &DiagID,
681 return TryAltiVecTokenOutOfLine(DS, Loc, PrevSpec, DiagID, isInvalid);
687 bool TryAltiVecVectorToken() {
690 return TryAltiVecVectorTokenOutOfLine();
693 bool TryAltiVecVectorTokenOutOfLine();
695 const char *&PrevSpec,
unsigned &DiagID,
701 bool isObjCInstancetype() {
705 if (!Ident_instancetype)
715 bool TryKeywordIdentFallback(
bool DisableKeyword);
731 class TentativeParsingAction {
734 size_t PrevTentativelyDeclaredIdentifierCount;
735 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
739 explicit TentativeParsingAction(
Parser& p) :
P(p) {
741 PrevTentativelyDeclaredIdentifierCount =
742 P.TentativelyDeclaredIdentifiers.size();
743 PrevParenCount = P.ParenCount;
744 PrevBracketCount = P.BracketCount;
745 PrevBraceCount = P.BraceCount;
750 assert(isActive &&
"Parsing action was finished!");
751 P.TentativelyDeclaredIdentifiers.resize(
752 PrevTentativelyDeclaredIdentifierCount);
757 assert(isActive &&
"Parsing action was finished!");
760 P.TentativelyDeclaredIdentifiers.resize(
761 PrevTentativelyDeclaredIdentifierCount);
762 P.ParenCount = PrevParenCount;
763 P.BracketCount = PrevBracketCount;
764 P.BraceCount = PrevBraceCount;
767 ~TentativeParsingAction() {
768 assert(!isActive &&
"Forgot to call Commit or Revert!");
773 class RevertingTentativeParsingAction
774 :
private Parser::TentativeParsingAction {
776 RevertingTentativeParsingAction(
Parser &
P)
777 : Parser::TentativeParsingAction(P) {}
778 ~RevertingTentativeParsingAction() { Revert(); }
793 WithinObjCContainer(P.ParsingInObjCContainer, DC !=
nullptr) {
812 unsigned Diag = diag::err_expected,
813 StringRef DiagMsg =
"");
820 bool ExpectAndConsumeSemi(
unsigned DiagID);
826 InstanceVariableList = 2,
827 AfterMemberFunctionDefinition = 3
831 void ConsumeExtraSemi(ExtraSemiKind Kind,
unsigned TST =
TST_unspecified);
839 bool expectIdentifier();
861 bool BeforeCompoundStmt =
false)
863 if (EnteredScope && !BeforeCompoundStmt)
866 if (BeforeCompoundStmt)
869 this->Self =
nullptr;
895 class ParseScopeFlags {
898 ParseScopeFlags(
const ParseScopeFlags &) =
delete;
899 void operator=(
const ParseScopeFlags &) =
delete;
902 ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
bool ManageFlags =
true);
913 return Diag(Tok, DiagID);
934 static_cast<unsigned>(R));
947 return SkipUntil(llvm::makeArrayRef(T), Flags);
980 class LateParsedDeclaration {
982 virtual ~LateParsedDeclaration();
984 virtual void ParseLexedMethodDeclarations();
985 virtual void ParseLexedMemberInitializers();
986 virtual void ParseLexedMethodDefs();
987 virtual void ParseLexedAttributes();
992 class LateParsedClass :
public LateParsedDeclaration {
994 LateParsedClass(
Parser *
P, ParsingClass *
C);
995 ~LateParsedClass()
override;
997 void ParseLexedMethodDeclarations()
override;
998 void ParseLexedMemberInitializers()
override;
999 void ParseLexedMethodDefs()
override;
1000 void ParseLexedAttributes()
override;
1004 ParsingClass *Class;
1013 struct LateParsedAttribute :
public LateParsedDeclaration {
1022 : Self(P), AttrName(Name), AttrNameLoc(Loc) {}
1024 void ParseLexedAttributes()
override;
1026 void addDecl(
Decl *D) { Decls.push_back(D); }
1030 class LateParsedAttrList:
public SmallVector<LateParsedAttribute *, 2> {
1032 LateParsedAttrList(
bool PSoon =
false) : ParseSoon(PSoon) { }
1034 bool parseSoon() {
return ParseSoon; }
1043 struct LexedMethod :
public LateParsedDeclaration {
1054 : Self(P), D(MD), TemplateScope(
false) {}
1056 void ParseLexedMethodDefs()
override;
1063 struct LateParsedDefaultArgument {
1064 explicit LateParsedDefaultArgument(
Decl *
P,
1065 std::unique_ptr<CachedTokens> Toks =
nullptr)
1066 : Param(P), Toks(std::move(Toks)) { }
1075 std::unique_ptr<CachedTokens> Toks;
1082 struct LateParsedMethodDeclaration :
public LateParsedDeclaration {
1083 explicit LateParsedMethodDeclaration(
Parser *
P,
Decl *M)
1084 : Self(P), Method(M), TemplateScope(
false),
1085 ExceptionSpecTokens(
nullptr) {}
1087 void ParseLexedMethodDeclarations()
override;
1114 struct LateParsedMemberInitializer :
public LateParsedDeclaration {
1116 : Self(P), Field(FD) { }
1118 void ParseLexedMemberInitializers()
override;
1141 struct ParsingClass {
1142 ParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface)
1143 : TopLevelClass(TopLevelClass), TemplateScope(
false),
1144 IsInterface(IsInterface), TagOrTemplate(TagOrTemplate) { }
1148 bool TopLevelClass : 1;
1153 bool TemplateScope : 1;
1156 bool IsInterface : 1;
1159 Decl *TagOrTemplate;
1164 LateParsedDeclarationsContainer LateParsedDeclarations;
1170 std::stack<ParsingClass *> ClassStack;
1172 ParsingClass &getCurrentClass() {
1173 assert(!ClassStack.empty() &&
"No lexed method stacks!");
1174 return *ClassStack.top();
1178 class ParsingClassDefinition {
1184 ParsingClassDefinition(
Parser &P,
Decl *TagOrTemplate,
bool TopLevelClass,
1186 :
P(P), Popped(
false),
1187 State(P.PushParsingClass(TagOrTemplate, TopLevelClass, IsInterface)) {
1192 assert(!Popped &&
"Nested class has already been popped");
1194 P.PopParsingClass(State);
1197 ~ParsingClassDefinition() {
1199 P.PopParsingClass(State);
1206 struct ParsedTemplateInfo {
1207 ParsedTemplateInfo()
1208 :
Kind(NonTemplate), TemplateParams(
nullptr), TemplateLoc() { }
1210 ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
1211 bool isSpecialization,
1212 bool lastParameterListWasEmpty =
false)
1213 :
Kind(isSpecialization? ExplicitSpecialization : Template),
1214 TemplateParams(TemplateParams),
1215 LastParameterListWasEmpty(lastParameterListWasEmpty) { }
1219 :
Kind(ExplicitInstantiation), TemplateParams(
nullptr),
1220 ExternLoc(ExternLoc), TemplateLoc(TemplateLoc),
1221 LastParameterListWasEmpty(
false){ }
1230 ExplicitSpecialization,
1232 ExplicitInstantiation
1237 TemplateParameterLists *TemplateParams;
1248 bool LastParameterListWasEmpty;
1253 void LexTemplateFunctionForLateParsing(
CachedTokens &Toks);
1257 static void LateTemplateParserCleanupCallback(
void *P);
1260 PushParsingClass(
Decl *TagOrTemplate,
bool TopLevelClass,
bool IsInterface);
1261 void DeallocateParsedClasses(ParsingClass *Class);
1264 enum CachedInitKind {
1265 CIK_DefaultArgument,
1266 CIK_DefaultInitializer
1272 const ParsedTemplateInfo &TemplateInfo,
1275 void ParseCXXNonStaticMemberInitializer(
Decl *VarD);
1276 void ParseLexedAttributes(ParsingClass &Class);
1277 void ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1278 bool EnterScope,
bool OnDefinition);
1279 void ParseLexedAttribute(LateParsedAttribute &LA,
1280 bool EnterScope,
bool OnDefinition);
1281 void ParseLexedMethodDeclarations(ParsingClass &Class);
1282 void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
1283 void ParseLexedMethodDefs(ParsingClass &Class);
1284 void ParseLexedMethodDef(LexedMethod &LM);
1285 void ParseLexedMemberInitializers(ParsingClass &Class);
1286 void ParseLexedMemberInitializer(LateParsedMemberInitializer &MI);
1287 void ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod);
1288 bool ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks);
1289 bool ConsumeAndStoreInitializer(
CachedTokens &Toks, CachedInitKind CIK);
1294 bool ConsumeFinalToken =
true) {
1295 return ConsumeAndStoreUntil(T1, T1, Toks,
StopAtSemi, ConsumeFinalToken);
1300 bool ConsumeFinalToken =
true);
1316 DeclGroupPtrTy ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
1318 bool isDeclarationAfterDeclarator();
1320 DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
1321 ParsedAttributesWithRange &attrs,
1324 DeclGroupPtrTy ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1328 void SkipFunctionBody();
1330 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1331 LateParsedAttrList *LateParsedAttrs =
nullptr);
1332 void ParseKNRParamDeclarations(Declarator &D);
1340 DeclGroupPtrTy ParseObjCAtDirectives();
1341 DeclGroupPtrTy ParseObjCAtClassDeclaration(
SourceLocation atLoc);
1354 bool RBraceMissing);
1355 void ParseObjCClassInstanceVariables(
Decl *interfaceDecl,
1360 bool WarnOnDeclarations,
1361 bool ForObjCContainer,
1364 bool consumeLastToken);
1369 void parseObjCTypeArgsOrProtocolQualifiers(
1378 bool consumeLastToken,
1379 bool warnOnIncompleteProtocols);
1383 void parseObjCTypeArgsAndProtocolQualifiers(
1392 bool consumeLastToken);
1402 bool consumeLastToken,
1407 DeclGroupPtrTy ParseObjCAtProtocolDeclaration(
SourceLocation atLoc,
1410 struct ObjCImplParsingDataRAII {
1415 LateParsedObjCMethodContainer LateParsedObjCMethods;
1417 ObjCImplParsingDataRAII(
Parser &parser,
Decl *D)
1418 :
P(parser), Dcl(D), HasCFunction(
false) {
1419 P.CurParsedObjCImpl =
this;
1422 ~ObjCImplParsingDataRAII();
1425 bool isFinished()
const {
return Finished; }
1430 ObjCImplParsingDataRAII *CurParsedObjCImpl;
1431 void StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl);
1433 DeclGroupPtrTy ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc);
1434 DeclGroupPtrTy ParseObjCAtEndDeclaration(
SourceRange atEnd);
1442 objc_in=0, objc_out, objc_inout, objc_oneway, objc_bycopy, objc_byref,
1443 objc_nonnull, objc_nullable, objc_null_unspecified,
1448 bool isTokIdentifier_in()
const;
1452 void ParseObjCMethodRequirement();
1453 Decl *ParseObjCMethodPrototype(
1455 bool MethodDefinition =
true);
1458 bool MethodDefinition=
true);
1461 Decl *ParseObjCMethodDefinition();
1483 unsigned &NumLineToksConsumed,
1484 bool IsUnevaluated);
1493 ExprResult ParseCastExpression(
bool isUnaryExpression,
1494 bool isAddressOfOperand,
1497 bool isVectorLiteral =
false);
1498 ExprResult ParseCastExpression(
bool isUnaryExpression,
1499 bool isAddressOfOperand =
false,
1501 bool isVectorLiteral =
false);
1504 bool isNotExpressionStart();
1508 bool isPostfixExpressionSuffixStart() {
1510 return (K == tok::l_square || K == tok::l_paren ||
1511 K == tok::period || K == tok::arrow ||
1512 K == tok::plusplus || K == tok::minusminus);
1518 ExprResult ParseUnaryExprOrTypeTraitExpression();
1530 bool ParseExpressionList(
1533 llvm::function_ref<
void()> Completer = llvm::function_ref<
void()>());
1542 enum ParenParseOption {
1548 ExprResult ParseParenExpression(ParenParseOption &ExprType,
1549 bool stopIfCastExpr,
1555 ParenParseOption &ExprType,
ParsedType &CastTy,
1561 ExprResult ParseStringLiteralExpression(
bool AllowUserDefinedLiteral =
false);
1563 ExprResult ParseGenericSelectionExpression();
1573 ExprResult ParseCXXIdExpression(
bool isAddressOfOperand =
false);
1575 bool areTokensAdjacent(
const Token &A,
const Token &B);
1577 void CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectTypePtr,
1583 bool EnteringContext,
1584 bool *MayBePseudoDestructor =
nullptr,
1585 bool IsTypename =
false,
1587 bool OnlyNamespace =
false);
1596 bool *SkippedInits =
nullptr);
1598 ExprResult ParseLambdaExpressionAfterIntroducer(
1657 void ParseCXXSimpleTypeSpecifier(
DeclSpec &DS);
1659 bool ParseCXXTypeSpecifierSeq(
DeclSpec &DS);
1665 void ParseDirectNewDeclarator(Declarator &D);
1667 ExprResult ParseCXXDeleteExpression(
bool UseGlobal,
1689 if (Tok.
isNot(tok::l_brace))
1691 return ParseBraceInitializer();
1693 bool MayBeDesignationStart();
1695 ExprResult ParseInitializerWithPotentialDesignator();
1715 bool isSimpleObjCMessageExpression();
1720 Expr *ReceiverExpr);
1721 ExprResult ParseAssignmentExprWithObjCMessageExprStart(
1724 bool ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr);
1738 bool AllowOpenMPStandalone =
false);
1739 enum AllowedConstructsKind {
1743 ACK_StatementsOpenMPNonStandalone,
1745 ACK_StatementsOpenMPAnyExecutable
1748 ParseStatementOrDeclaration(StmtVector &Stmts, AllowedConstructsKind Allowed,
1750 StmtResult ParseStatementOrDeclarationAfterAttributes(
1752 AllowedConstructsKind Allowed,
1754 ParsedAttributesWithRange &Attrs);
1756 StmtResult ParseLabeledStatement(ParsedAttributesWithRange &attrs);
1757 StmtResult ParseCaseStatement(
bool MissingCase =
false,
1760 StmtResult ParseCompoundStatement(
bool isStmtExpr =
false);
1761 StmtResult ParseCompoundStatement(
bool isStmtExpr,
1762 unsigned ScopeFlags);
1763 void ParseCompoundStatementLeadingPragmas();
1764 StmtResult ParseCompoundStatementBody(
bool isStmtExpr =
false);
1765 bool ParseParenExprOrCondition(
StmtResult *InitStmt,
1780 StmtResult ParsePragmaLoopHint(StmtVector &Stmts,
1781 AllowedConstructsKind Allowed,
1783 ParsedAttributesWithRange &Attrs);
1787 enum IfExistsBehavior {
1799 struct IfExistsCondition {
1814 IfExistsBehavior Behavior;
1817 bool ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result);
1818 void ParseMicrosoftIfExistsStatement(StmtVector &Stmts);
1819 void ParseMicrosoftIfExistsExternalDeclaration();
1822 bool ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
1833 StmtResult ParseCXXCatchBlock(
bool FnCatch =
false);
1859 enum class DeclSpecContext {
1864 DSC_alias_declaration,
1867 DSC_template_type_arg,
1868 DSC_objc_method_result,
1874 static bool isTypeSpecifier(DeclSpecContext DSC) {
1876 case DeclSpecContext::DSC_normal:
1877 case DeclSpecContext::DSC_template_param:
1878 case DeclSpecContext::DSC_class:
1879 case DeclSpecContext::DSC_top_level:
1880 case DeclSpecContext::DSC_objc_method_result:
1881 case DeclSpecContext::DSC_condition:
1884 case DeclSpecContext::DSC_template_type_arg:
1885 case DeclSpecContext::DSC_type_specifier:
1886 case DeclSpecContext::DSC_trailing:
1887 case DeclSpecContext::DSC_alias_declaration:
1890 llvm_unreachable(
"Missing DeclSpecContext case");
1895 static bool isClassTemplateDeductionContext(DeclSpecContext DSC) {
1897 case DeclSpecContext::DSC_normal:
1898 case DeclSpecContext::DSC_template_param:
1899 case DeclSpecContext::DSC_class:
1900 case DeclSpecContext::DSC_top_level:
1901 case DeclSpecContext::DSC_condition:
1902 case DeclSpecContext::DSC_type_specifier:
1905 case DeclSpecContext::DSC_objc_method_result:
1906 case DeclSpecContext::DSC_template_type_arg:
1907 case DeclSpecContext::DSC_trailing:
1908 case DeclSpecContext::DSC_alias_declaration:
1911 llvm_unreachable(
"Missing DeclSpecContext case");
1916 struct ForRangeInit {
1920 bool ParsedForRangeDecl() {
return !ColonLoc.
isInvalid(); }
1925 ParsedAttributesWithRange &attrs);
1928 ParsedAttributesWithRange &attrs,
1930 ForRangeInit *FRI =
nullptr);
1934 ForRangeInit *FRI =
nullptr);
1935 Decl *ParseDeclarationAfterDeclarator(Declarator &D,
1936 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
1937 bool ParseAsmAttributesAfterDeclarator(Declarator &D);
1938 Decl *ParseDeclarationAfterDeclaratorAndAttributes(
1940 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1941 ForRangeInit *FRI =
nullptr);
1949 bool trySkippingFunctionBody();
1952 const ParsedTemplateInfo &TemplateInfo,
1954 ParsedAttributesWithRange &Attrs);
1957 void ParseDeclarationSpecifiers(
1959 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
1961 DeclSpecContext DSC = DeclSpecContext::DSC_normal,
1962 LateParsedAttrList *LateAttrs =
nullptr);
1963 bool DiagnoseMissingSemiAfterTagDefinition(
1965 LateParsedAttrList *LateAttrs =
nullptr);
1967 void ParseSpecifierQualifierList(
1969 DeclSpecContext DSC = DeclSpecContext::DSC_normal);
1975 const ParsedTemplateInfo &TemplateInfo,
1981 void ParseStructDeclaration(
1985 bool isDeclarationSpecifier(
bool DisambiguatingWithExpression =
false);
1986 bool isTypeSpecifierQualifier();
1991 bool isKnownToBeTypeSpecifier(
const Token &Tok)
const;
1996 bool isKnownToBeDeclarationSpecifier() {
1998 return isCXXDeclarationSpecifier() == TPResult::True;
1999 return isDeclarationSpecifier(
true);
2005 bool isDeclarationStatement() {
2007 return isCXXDeclarationStatement();
2008 return isDeclarationSpecifier(
true);
2015 bool isForInitDeclaration() {
2017 return isCXXSimpleDeclaration(
true);
2018 return isDeclarationSpecifier(
true);
2022 bool isForRangeIdentifier();
2026 bool isStartOfObjCClassMessageMissingOpenBracket();
2031 bool isConstructorDeclarator(
bool Unqualified,
bool DeductionGuide =
false);
2035 enum TentativeCXXTypeIdContext {
2038 TypeIdAsTemplateArgument
2045 bool isTypeIdInParens(
bool &isAmbiguous) {
2047 return isCXXTypeId(TypeIdInParens, isAmbiguous);
2048 isAmbiguous =
false;
2049 return isTypeSpecifierQualifier();
2051 bool isTypeIdInParens() {
2053 return isTypeIdInParens(isAmbiguous);
2059 bool isTypeIdUnambiguously() {
2062 return isCXXTypeId(TypeIdUnambiguous, IsAmbiguous);
2063 return isTypeSpecifierQualifier();
2069 bool isCXXDeclarationStatement();
2076 bool isCXXSimpleDeclaration(
bool AllowForRangeDecl);
2085 bool isCXXFunctionDeclarator(
bool *IsAmbiguous =
nullptr);
2088 enum class ConditionOrInitStatement {
2097 ConditionOrInitStatement
2098 isCXXConditionDeclarationOrInitStatement(
bool CanBeInitStmt);
2100 bool isCXXTypeId(TentativeCXXTypeIdContext Context,
bool &isAmbiguous);
2101 bool isCXXTypeId(TentativeCXXTypeIdContext Context) {
2103 return isCXXTypeId(Context, isAmbiguous);
2108 enum class TPResult {
2109 True, False, Ambiguous, Error
2132 isCXXDeclarationSpecifier(TPResult BracedCastResult = TPResult::False,
2133 bool *HasMissingTypename =
nullptr);
2138 bool isCXXDeclarationSpecifierAType();
2152 TPResult TryParseSimpleDeclaration(
bool AllowForRangeDecl);
2153 TPResult TryParseTypeofSpecifier();
2154 TPResult TryParseProtocolQualifiers();
2155 TPResult TryParsePtrOperatorSeq();
2156 TPResult TryParseOperatorId();
2157 TPResult TryParseInitDeclaratorList();
2158 TPResult TryParseDeclarator(
bool mayBeAbstract,
bool mayHaveIdentifier=
true);
2160 TryParseParameterDeclarationClause(
bool *InvalidAsDeclaration =
nullptr,
2161 bool VersusTemplateArg =
false);
2162 TPResult TryParseFunctionDeclarator();
2163 TPResult TryParseBracketDeclarator();
2164 TPResult TryConsumeDeclarationSpecifier();
2171 Decl **OwnedType =
nullptr,
2178 bool standardAttributesAllowed()
const {
2180 return LO.DoubleSquareBracketAttributes;
2185 bool CheckProhibitedCXX11Attribute() {
2186 assert(Tok.
is(tok::l_square));
2187 if (!standardAttributesAllowed() ||
NextToken().
isNot(tok::l_square))
2189 return DiagnoseProhibitedCXX11Attribute();
2192 bool DiagnoseProhibitedCXX11Attribute();
2193 void CheckMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2195 if (!standardAttributesAllowed())
2198 Tok.
isNot(tok::kw_alignas))
2200 DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
2202 void DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
2205 void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
2209 void ProhibitAttributes(ParsedAttributesWithRange &attrs,
2211 if (!attrs.Range.isValid())
return;
2212 DiagnoseProhibitedAttributes(attrs, FixItLoc);
2215 void DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs,
2221 void ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
2231 void DiagnoseAndSkipCXX11Attributes();
2243 void MaybeParseGNUAttributes(Declarator &D,
2244 LateParsedAttrList *LateAttrs =
nullptr) {
2245 if (Tok.
is(tok::kw___attribute)) {
2248 ParseGNUAttributes(attrs, &endLoc, LateAttrs, &D);
2254 LateParsedAttrList *LateAttrs =
nullptr) {
2255 if (Tok.
is(tok::kw___attribute))
2256 ParseGNUAttributes(attrs, endLoc, LateAttrs);
2260 LateParsedAttrList *LateAttrs =
nullptr,
2261 Declarator *D =
nullptr);
2278 void MaybeParseCXX11Attributes(Declarator &D) {
2279 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2280 ParsedAttributesWithRange attrs(AttrFactory);
2282 ParseCXX11Attributes(attrs, &endLoc);
2288 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
2289 ParsedAttributesWithRange attrsWithRange(AttrFactory);
2290 ParseCXX11Attributes(attrsWithRange, endLoc);
2294 void MaybeParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2296 bool OuterMightBeMessageSend =
false) {
2297 if (standardAttributesAllowed() &&
2298 isCXX11AttributeSpecifier(
false, OuterMightBeMessageSend))
2299 ParseCXX11Attributes(attrs, endLoc);
2304 void ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
2319 ParseMicrosoftAttributes(attrs, endLoc);
2327 if (LO.DeclSpecKeyword && Tok.
is(tok::kw___declspec))
2328 ParseMicrosoftDeclSpecs(Attrs,
End);
2336 void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2347 return ParseOpenCLUnrollHintAttribute(Attrs);
2367 void ParseExternalSourceSymbolAttribute(
IdentifierInfo &ExternalSourceSymbol,
2375 void ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
2399 void ParseTypeofSpecifier(
DeclSpec &DS);
2401 void AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
2404 void ParseUnderlyingTypeSpecifier(
DeclSpec &DS);
2405 void ParseAtomicSpecifier(
DeclSpec &DS);
2414 return isCXX11VirtSpecifier(Tok);
2416 void ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
bool IsInterface,
2419 bool isCXX11FinalKeyword()
const;
2424 class DeclaratorScopeObj {
2431 : P(p), SS(ss), EnteredScope(
false), CreatedScope(
false) {}
2433 void EnterDeclaratorScope() {
2434 assert(!EnteredScope &&
"Already entered the scope!");
2435 assert(SS.
isSet() &&
"C++ scope was not set!");
2437 CreatedScope =
true;
2441 EnteredScope =
true;
2444 ~DeclaratorScopeObj() {
2446 assert(SS.
isSet() &&
"C++ scope was cleared ?");
2455 void ParseDeclarator(Declarator &D);
2457 typedef void (
Parser::*DirectDeclParseFunction)(Declarator&);
2458 void ParseDeclaratorInternal(Declarator &D,
2459 DirectDeclParseFunction DirectDeclParser);
2461 enum AttrRequirements {
2462 AR_NoAttributesParsed = 0,
2463 AR_GNUAttributesParsedAndRejected = 1 << 0,
2464 AR_GNUAttributesParsed = 1 << 1,
2465 AR_CXX11AttributesParsed = 1 << 2,
2466 AR_DeclspecAttributesParsed = 1 << 3,
2467 AR_AllAttributesParsed = AR_GNUAttributesParsed |
2468 AR_CXX11AttributesParsed |
2469 AR_DeclspecAttributesParsed,
2470 AR_VendorAttributesParsed = AR_GNUAttributesParsed |
2471 AR_DeclspecAttributesParsed
2474 void ParseTypeQualifierListOpt(
2475 DeclSpec &DS,
unsigned AttrReqs = AR_AllAttributesParsed,
2476 bool AtomicAllowed =
true,
bool IdentifierRequired =
false,
2478 void ParseDirectDeclarator(Declarator &D);
2479 void ParseDecompositionDeclarator(Declarator &D);
2480 void ParseParenDeclarator(Declarator &D);
2481 void ParseFunctionDeclarator(Declarator &D,
2485 bool RequiresArg =
false);
2486 bool ParseRefQualifier(
bool &RefQualifierIsLValueRef,
2488 bool isFunctionDeclaratorIdentifierList();
2489 void ParseFunctionDeclaratorIdentifierList(
2492 void ParseParameterDeclarationClause(
2497 void ParseBracketDeclarator(Declarator &D);
2498 void ParseMisplacedBracketDeclarator(Declarator &D);
2504 enum CXX11AttributeKind {
2506 CAK_NotAttributeSpecifier,
2508 CAK_AttributeSpecifier,
2511 CAK_InvalidAttributeSpecifier
2514 isCXX11AttributeSpecifier(
bool Disambiguate =
false,
2515 bool OuterMightBeMessageSend =
false);
2517 void DiagnoseUnexpectedNamespace(
NamedDecl *Context);
2522 void ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc,
2523 std::vector<IdentifierInfo *> &Ident,
2524 std::vector<SourceLocation> &NamespaceLoc,
2529 Decl *ParseExportDeclaration();
2530 DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
2538 struct UsingDeclarator {
2554 const ParsedTemplateInfo &TemplateInfo,
2558 Decl *ParseAliasDeclarationAfterDeclarator(
2570 bool isValidAfterTypeSpecifier(
bool CouldBeBitfield);
2572 DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo,
2574 DeclSpecContext DSC,
2575 ParsedAttributesWithRange &Attributes);
2582 ParsedAttributesWithRange &Attrs,
2587 bool ParseCXXMemberDeclaratorBeforeInitializer(Declarator &DeclaratorInfo,
2590 LateParsedAttrList &LateAttrs);
2591 void MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(Declarator &D,
2593 DeclGroupPtrTy ParseCXXClassMemberDeclaration(
2595 const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
2597 DeclGroupPtrTy ParseCXXClassMemberDeclarationWithPragmas(
2600 void ParseConstructorInitializer(
Decl *ConstructorDecl);
2602 void HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
2609 void ParseBaseClause(
Decl *ClassDecl);
2617 bool EnteringContext,
2620 bool AssumeTemplateId);
2621 bool ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2628 DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
2632 DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
2637 DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(
AccessSpecifier AS);
2640 void ParseOpenMPReductionInitializerForDecl(
VarDecl *OmpPrivParm);
2649 bool ParseOpenMPSimpleVarList(
2653 bool AllowScopeSpecifier);
2662 ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed);
2716 bool IsMapTypeImplicit =
false;
2725 bool AllowDestructorName,
2726 bool AllowConstructorName,
2727 bool AllowDeductionGuide,
2745 Decl *ParseSingleDeclarationAfterTemplate(
2747 const ParsedTemplateInfo &TemplateInfo,
2752 bool ParseTemplateParameters(
unsigned Depth,
2756 bool ParseTemplateParameterList(
unsigned Depth,
2758 bool isStartOfTemplateTypeParameter();
2759 NamedDecl *ParseTemplateParameter(
unsigned Depth,
unsigned Position);
2760 NamedDecl *ParseTypeParameter(
unsigned Depth,
unsigned Position);
2761 NamedDecl *ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position);
2762 NamedDecl *ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position);
2765 bool AlreadyHasEllipsis,
2766 bool IdentifierHasName);
2767 void DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
2773 bool ConsumeLastToken,
2774 bool ObjCGenericList);
2775 bool ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
2777 TemplateArgList &TemplateArgs,
2784 bool AllowTypeAnnotation =
true);
2785 void AnnotateTemplateIdTokenAsType(
bool IsClassName =
false);
2786 bool IsTemplateArgumentList(
unsigned Skip = 0);
2787 bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
2798 DeclGroupPtrTy ParseModuleDecl();
2800 bool parseMisplacedModuleImport();
2801 bool tryParseMisplacedModuleImport() {
2803 if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
2804 Kind == tok::annot_module_include)
2805 return parseMisplacedModuleImport();
2809 bool ParseModuleName(
2825 void CodeCompleteDirective(
bool InConditional)
override;
2826 void CodeCompleteInConditionalExclusion()
override;
2827 void CodeCompleteMacroName(
bool IsDefinition)
override;
2828 void CodeCompletePreprocessorExpression()
override;
2830 unsigned ArgumentIndex)
override;
2831 void CodeCompleteNaturalLanguage()
override;
Sema::FullExprArg FullExprArg
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the underscored keyword (_Nonnull, _Nullable) that corresponds to the given nullability kind...
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
ParseScope - Introduces a new scope for parsing.
Represents a version number in the form major[.minor[.subminor[.build]]].
DeclarationNameInfo ReductionId
SourceLocation getEndOfPreviousToken()
void Initialize()
Initialize - Warm up the parser.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Class to handle popping type parameters when leaving the scope.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
NullabilityKind
Describes the nullability of a particular type.
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)) {...
ActionResult< Expr * > ExprResult
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
Captures information about "declaration specifiers" specific to Objective-C.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
SourceLocation DepLinMapLoc
void setCodeCompletionReached()
Note that we hit the code-completion point.
void ActOnObjCReenterContainerContext(DeclContext *DC)
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Information about one declarator, including the parsed type information and the identifier.
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token...
TypeSpecifierType
Specifies the kind of type.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
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 ...
Information about a template-id annotation token.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
SourceLocation getAnnotationEndLoc() const
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
const TargetInfo & getTargetInfo() const
Token - This structure provides full information about a lexed token.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
Defines some OpenMP-specific enums and functions.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
void * getAsOpaquePtr() const
Represents a C++ unqualified-id that has been parsed.
friend constexpr SkipUntilFlags operator|(SkipUntilFlags L, SkipUntilFlags R)
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
bool TryConsumeToken(tok::TokenKind Expected, SourceLocation &Loc)
Decl * getObjCDeclContext() const
Concrete class used by the front-end to report problems and issues.
void incrementMSManglingNumber() const
void takeAllFrom(ParsedAttributes &attrs)
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
void CommitBacktrackedTokens()
Disable the last EnableBacktrackAtThisPos call.
Scope - A scope is a transient data structure that is used while parsing the program.
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
AttributeFactory & getAttrFactory()
void incrementMSManglingNumber() const
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
CompoundStmt - This represents a group of statements like { stmt stmt }.
A class for parsing a declarator.
void Backtrack()
Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously c...
Scope * getCurScope() const
Retrieve the parser's current scope.
Exposes information about the current target.
void setAnnotationValue(void *val)
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
Expr - This represents one expression.
const FunctionProtoType * T
void EnableBacktrackAtThisPos()
From the point that this method is called, and until CommitBacktrackedTokens() or Backtrack() is call...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Sema & getActions() const
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
const Token & getCurToken() const
OpaquePtr< TemplateName > TemplateTy
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
CXXScopeSpec ReductionIdScopeSpec
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
OpenMPClauseKind
OpenMP clauses.
Represents a C++ template name within the type system.
A class for parsing a field declarator.
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Preprocessor & getPreprocessor() const
Defines and computes precedence levels for binary/ternary operators.
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
const LangOptions & getLangOpts() const
A class for parsing a DeclSpec.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Represents the parsed form of a C++ template argument.
Encodes a location in the source.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
DiagnosticBuilder Diag(unsigned DiagID)
bool ParseOpenMPVarList(OpenMPDirectiveKind DKind, OpenMPClauseKind Kind, SmallVectorImpl< Expr *> &Vars, OpenMPVarListDataTy &Data)
Parses clauses with list.
TagDecl - Represents the declaration of a struct/union/class/enum.
void ExitScope()
ExitScope - Pop a scope off the scope stack.
IdentifierInfo * getIdentifierInfo() const
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
OpenMPDirectiveKind
OpenMP directives.
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
A tentative parsing action that can also revert token annotations.
void Lex(Token &Result)
Lex the next token for this preprocessor.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
This is a basic class for representing single OpenMP clause.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Represents a C++11 virt-specifier-seq.
Scope * getCurScope() const
ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc)
Parses simple expression in parens for single-expression clauses of OpenMP constructs.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
Defines various enumerations that describe declaration and type specifiers.
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
bool isNot(tok::TokenKind K) const
ParseScope(Parser *Self, unsigned ScopeFlags, bool EnteredScope=true, bool BeforeCompoundStmt=false)
static bool isInvalid(LocType Loc, bool *Invalid)
Dataflow Directional Tag Classes.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
SkipUntilFlags
Control flags for SkipUntil functions.
Data used for parsing list of variables in OpenMP clauses.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static const TST TST_unspecified
Encapsulates the data about a macro definition (e.g.
Syntax
The style used to specify an attribute.
const TargetInfo & getTargetInfo() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
bool isSet() const
Deprecated.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Decl * getObjCDeclContext() const
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Represents a complete lambda introducer.
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
Contains a late templated function.
Loop optimization hint for loop and unroll pragmas.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
Callback handler that receives notifications when performing code completion within the preprocessor...
void * getAnnotationValue() const
static OpaquePtr getFromOpaquePtr(void *P)
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
Attr - This represents one attribute.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result)
Parse the first top-level declaration in a translation unit.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
AttributeList - Represents a syntactic attribute.
Stop skipping at specified token, but don't skip the token itself.