23 #include "llvm/Support/ErrorHandling.h" 26 using namespace clang;
31 case tok::unknown:
return 0;
33 case tok::kw_const_cast:
return 1;
34 case tok::kw_dynamic_cast:
return 2;
35 case tok::kw_reinterpret_cast:
return 3;
36 case tok::kw_static_cast:
return 4;
38 llvm_unreachable(
"Unknown type for digraph error message.");
43 bool Parser::areTokensAdjacent(
const Token &
First,
const Token &Second) {
61 P.
Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
66 ColonToken.
setKind(tok::coloncolon);
69 DigraphToken.
setKind(tok::less);
80 void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
83 if (!Next.
is(tok::l_square) || Next.
getLength() != 2)
86 Token SecondToken = GetLookAheadToken(2);
87 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
93 bool MemberOfUnknownSpecialization;
95 TemplateName, ObjectType, EnteringContext,
96 Template, MemberOfUnknownSpecialization))
99 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
147 bool Parser::ParseOptionalCXXScopeSpecifier(
CXXScopeSpec &SS,
149 bool EnteringContext,
150 bool *MayBePseudoDestructor,
153 bool OnlyNamespace) {
155 "Call sites of this function should be guarded by checking for C++");
157 if (Tok.
is(tok::annot_cxxscope)) {
158 assert(!LastII &&
"want last identifier but have already annotated scope");
159 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
163 ConsumeAnnotationToken();
167 if (Tok.
is(tok::annot_template_id)) {
175 bool CheckForDestructor =
false;
176 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
177 CheckForDestructor =
true;
178 *MayBePseudoDestructor =
false;
184 bool HasScopeSpecifier =
false;
186 if (Tok.
is(tok::coloncolon)) {
189 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
192 if (NextKind == tok::l_brace) {
201 HasScopeSpecifier =
true;
205 if (Tok.
is(tok::kw___super)) {
207 if (!Tok.
is(tok::coloncolon)) {
215 if (!HasScopeSpecifier &&
216 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
226 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
233 HasScopeSpecifier =
true;
237 if (HasScopeSpecifier) {
238 if (Tok.
is(tok::code_completion)) {
262 ObjectType =
nullptr;
270 if (Tok.
is(tok::kw_template)) {
274 if (!HasScopeSpecifier && !ObjectType)
277 TentativeParsingAction TPA(*
this);
281 if (Tok.
is(tok::identifier)) {
285 }
else if (Tok.
is(tok::kw_operator)) {
290 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
299 diag::err_id_after_template_in_nested_name_spec)
312 if (Tok.
isNot(tok::less)) {
321 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
322 EnteringContext, Template,
true)) {
323 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
324 TemplateName,
false))
332 if (Tok.
is(tok::annot_template_id) &&
NextToken().
is(tok::coloncolon)) {
341 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
342 *MayBePseudoDestructor =
true;
347 *LastII = TemplateId->
Name;
350 ConsumeAnnotationToken();
352 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
355 HasScopeSpecifier =
true;
381 if (Tok.
isNot(tok::identifier))
396 if (Next.
is(tok::colon) && !ColonIsSacred) {
403 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
410 if (Next.
is(tok::coloncolon) && GetLookAheadToken(2).
is(tok::l_brace)) {
417 UnconsumeToken(Identifier);
421 if (Next.
is(tok::coloncolon)) {
422 if (CheckForDestructor && GetLookAheadToken(2).
is(tok::tilde) &&
424 *MayBePseudoDestructor =
true;
429 const Token &Next2 = GetLookAheadToken(2);
430 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
431 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
432 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
437 ColonColon.setKind(tok::colon);
450 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
451 "NextToken() not working properly!");
452 Token ColonColon = Tok;
455 bool IsCorrectedToColon =
false;
456 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
459 CorrectionFlagPtr, OnlyNamespace)) {
462 if (CorrectionFlagPtr && IsCorrectedToColon) {
463 ColonColon.setKind(tok::colon);
471 HasScopeSpecifier =
true;
475 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
479 if (Next.
is(tok::less)) {
483 bool MemberOfUnknownSpecialization;
490 MemberOfUnknownSpecialization)) {
499 TemplateName,
false))
504 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
505 (IsTypename || IsTemplateArgumentList(1))) {
510 unsigned DiagID = diag::err_missing_dependent_template_keyword;
512 DiagID = diag::warn_missing_dependent_template_keyword;
520 EnteringContext, Template,
true)) {
524 TemplateName,
false))
542 if (CheckForDestructor && Tok.
is(tok::tilde))
543 *MayBePseudoDestructor =
true;
549 Token &Replacement) {
557 nullptr, &TemplateKWLoc, Name))
562 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
563 isAddressOfOperand =
false;
566 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
567 isAddressOfOperand,
nullptr,
false,
570 checkPotentialAngleBracket(E);
616 ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
622 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
626 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
630 UnconsumeToken(Replacement);
631 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
633 assert(!Result.
isUnset() &&
"Typo correction suggested a keyword replacement " 634 "for a previous keyword suggestion");
680 Optional<unsigned> DiagID = ParseLambdaIntroducer(Intro);
682 Diag(Tok, DiagID.getValue());
689 return ParseLambdaExpressionAfterIntroducer(Intro);
697 ExprResult Parser::TryParseLambdaExpression() {
699 && Tok.
is(tok::l_square)
700 &&
"Not at the start of a possible lambda expression.");
708 if (Next.is(tok::r_square) ||
709 Next.is(tok::equal) ||
710 (Next.is(tok::amp) &&
711 (After.
is(tok::r_square) ||
712 After.
is(tok::comma))) ||
713 (Next.is(tok::identifier) &&
714 After.
is(tok::r_square))) {
715 return ParseLambdaExpression();
720 if (Next.is(tok::identifier) && After.
is(tok::identifier)) {
731 if (TryParseLambdaIntroducer(Intro))
734 return ParseLambdaExpressionAfterIntroducer(Intro);
747 bool *SkippedInits) {
748 typedef Optional<unsigned> DiagResult;
750 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
759 if (Tok.
is(tok::amp) &&
764 }
else if (Tok.
is(tok::equal)) {
770 while (Tok.
isNot(tok::r_square)) {
772 if (Tok.
isNot(tok::comma)) {
777 if (Tok.
is(tok::code_completion) &&
786 return DiagResult(diag::err_expected_comma_or_rsquare);
791 if (Tok.
is(tok::code_completion)) {
814 if (Tok.
is(tok::star)) {
816 if (Tok.
is(tok::kw_this)) {
820 return DiagResult(diag::err_expected_star_this_capture);
822 }
else if (Tok.
is(tok::kw_this)) {
826 if (Tok.
is(tok::amp)) {
830 if (Tok.
is(tok::code_completion)) {
838 if (Tok.
is(tok::identifier)) {
841 }
else if (Tok.
is(tok::kw_this)) {
845 return DiagResult(diag::err_this_captured_by_reference);
847 return DiagResult(diag::err_expected_capture);
850 if (Tok.
is(tok::l_paren)) {
860 *SkippedInits =
true;
861 }
else if (ParseExpressionList(Exprs, Commas)) {
870 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
883 Init = ParseInitializer();
884 }
else if (Tok.
is(tok::l_brace)) {
888 *SkippedInits =
true;
912 Init = ParseInitializer();
922 Tok.
setKind(tok::annot_primary_expr);
923 setExprAnnotation(Tok, Init);
928 ConsumeAnnotationToken();
983 Loc, Kind ==
LCK_ByRef, Id, InitKind, InitExpr);
989 Intro.
addCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
1003 bool SkippedInits =
false;
1004 TentativeParsingAction PA1(*
this);
1006 if (ParseLambdaIntroducer(Intro, &SkippedInits)) {
1011 if (!SkippedInits) {
1021 TentativeParsingAction PA2(*
this);
1023 if (!ParseLambdaIntroducer(Intro)) {
1044 case tok::kw_mutable: {
1047 diag::err_lambda_decl_specifier_repeated)
1051 DeclEndLoc = MutableLoc;
1054 case tok::kw_constexpr:
1057 diag::err_lambda_decl_specifier_repeated)
1061 DeclEndLoc = ConstexprLoc;
1074 ? diag::ext_constexpr_on_lambda_cxx17
1075 : diag::warn_cxx14_compat_constexpr_on_lambda);
1076 const char *PrevSpec =
nullptr;
1077 unsigned DiagID = 0;
1079 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1080 "Constexpr cannot have been set previously!");
1086 ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1089 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1092 "lambda expression parsing");
1102 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1110 MaybeParseGNUAttributes(D);
1115 auto WarnIfHasCUDATargetAttr = [&] {
1118 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1119 A.getKind() == ParsedAttr::AT_CUDAHost ||
1120 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1121 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1122 << A.getName()->getName();
1126 if (Tok.
is(tok::l_paren)) {
1127 ParseScope PrototypeScope(
this,
1140 if (Tok.
isNot(tok::r_paren)) {
1142 ParseParameterDeclarationClause(D, Attr, ParamInfo, EllipsisLoc);
1146 ++CurTemplateDepthTracker;
1154 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
1158 MaybeParseMicrosoftDeclSpecs(Attr, &DeclEndLoc);
1175 ESpecType = tryParseExceptionSpecification(
false,
1178 DynamicExceptionRanges,
1180 ExceptionSpecTokens);
1183 DeclEndLoc = ESpecRange.
getEnd();
1186 MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
1191 if (Tok.
is(tok::arrow)) {
1194 TrailingReturnType =
1195 ParseTrailingReturnType(Range,
false);
1197 DeclEndLoc = Range.
getEnd();
1200 PrototypeScope.Exit();
1202 WarnIfHasCUDATargetAttr();
1207 false, LParenLoc, ParamInfo.data(),
1208 ParamInfo.size(), EllipsisLoc, RParenLoc,
1210 NoLoc, MutableLoc, ESpecType,
1211 ESpecRange, DynamicExceptions.data(),
1212 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1213 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1215 None, LParenLoc, FunLocalRangeEnd, D,
1216 TrailingReturnType),
1217 std::move(Attr), DeclEndLoc);
1218 }
else if (Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1219 tok::kw_constexpr) ||
1223 unsigned TokKind = 0;
1225 case tok::kw_mutable: TokKind = 0;
break;
1226 case tok::arrow: TokKind = 1;
break;
1227 case tok::kw___attribute:
1228 case tok::l_square: TokKind = 2;
break;
1229 case tok::kw_constexpr: TokKind = 3;
break;
1230 default: llvm_unreachable(
"Unknown token kind");
1233 Diag(Tok, diag::err_lambda_missing_parens)
1240 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
1244 if (Tok.
is(tok::kw_mutable)) {
1246 DeclEndLoc = MutableLoc;
1250 MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
1253 if (Tok.
is(tok::arrow)) {
1255 TrailingReturnType =
1256 ParseTrailingReturnType(Range,
false);
1258 DeclEndLoc = Range.
getEnd();
1261 WarnIfHasCUDATargetAttr();
1280 None, DeclLoc, DeclEndLoc, D,
1281 TrailingReturnType),
1282 std::move(Attr), DeclEndLoc);
1289 ParseScope BodyScope(
this, ScopeFlags);
1294 if (!Tok.
is(tok::l_brace)) {
1295 Diag(Tok, diag::err_expected_lambda_body);
1303 if (!Stmt.isInvalid() && !TrailingReturnType.
isInvalid())
1321 const char *CastName =
nullptr;
1324 default: llvm_unreachable(
"Unknown C++ cast!");
1325 case tok::kw_const_cast: CastName =
"const_cast";
break;
1326 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1327 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1328 case tok::kw_static_cast: CastName =
"static_cast";
break;
1336 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1338 if (Next.
is(tok::colon) && areTokensAdjacent(Tok, Next))
1339 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1342 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1347 ParseSpecifierQualifierList(DS);
1351 ParseDeclarator(DeclaratorInfo);
1355 if (ExpectAndConsume(tok::greater))
1356 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1370 LAngleBracketLoc, DeclaratorInfo,
1385 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1415 if (isTypeIdInParens()) {
1425 Ty.
get().getAsOpaquePtr(), RParenLoc);
1439 Result.
get(), RParenLoc);
1452 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1463 if (isTypeIdInParens()) {
1473 Ty.
get().getAsOpaquePtr(),
1524 if (Tok.
is(tok::identifier)) {
1527 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1529 }
else if (Tok.
is(tok::annot_template_id)) {
1534 ConsumeAnnotationToken();
1535 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1542 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1545 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid() && SS.
isEmpty()) {
1547 ParseDecltypeSpecifier(DS);
1554 if (!Tok.
is(tok::identifier)) {
1555 Diag(Tok, diag::err_destructor_tilde_identifier);
1567 if (Tok.
is(tok::less) &&
1570 false, ObjectType, SecondTypeName,
1575 SS, FirstTypeName, CCLoc, TildeLoc,
1594 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1620 ExprResult Parser::ParseCoyieldExpression() {
1621 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1637 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1656 Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1660 assert((Tok.
is(tok::l_paren) ||
1662 &&
"Expected '(' or '{'!");
1664 if (Tok.
is(tok::l_brace)) {
1677 CommaLocsTy CommaLocs;
1679 if (Tok.
isNot(tok::r_paren)) {
1680 if (ParseExpressionList(Exprs, CommaLocs, [&] {
1684 CalledSignatureHelp =
true;
1691 CalledSignatureHelp =
true;
1705 assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
1706 "Unexpected number of commas!");
1741 ForRangeInfo *FRI) {
1744 if (Tok.
is(tok::code_completion)) {
1750 ParsedAttributesWithRange attrs(AttrFactory);
1751 MaybeParseCXX11Attributes(attrs);
1753 const auto WarnOnInit = [
this, &CK] {
1755 ? diag::warn_cxx14_compat_init_statement
1756 : diag::ext_init_statement)
1761 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
1762 case ConditionOrInitStatement::Expression: {
1763 ProhibitAttributes(attrs);
1767 if (InitStmt && Tok.
is(tok::semi)) {
1771 Diag(SemiLoc, diag::warn_empty_init_statement)
1777 return ParseCXXCondition(
nullptr, Loc, CK);
1785 if (InitStmt && Tok.
is(tok::semi)) {
1789 return ParseCXXCondition(
nullptr, Loc, CK);
1795 case ConditionOrInitStatement::InitStmtDecl: {
1802 return ParseCXXCondition(
nullptr, Loc, CK);
1805 case ConditionOrInitStatement::ForRangeDecl: {
1806 assert(FRI &&
"should not parse a for range declaration here");
1814 case ConditionOrInitStatement::ConditionDecl:
1815 case ConditionOrInitStatement::Error:
1822 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
1826 ParseDeclarator(DeclaratorInfo);
1829 if (Tok.
is(tok::kw_asm)) {
1841 MaybeParseGNUAttributes(DeclaratorInfo);
1852 bool CopyInitialization = isTokenEqualOrEqualTypo();
1853 if (CopyInitialization)
1859 diag::warn_cxx98_compat_generalized_initializer_lists);
1860 InitExpr = ParseBraceInitializer();
1861 }
else if (CopyInitialization) {
1863 }
else if (Tok.
is(tok::l_paren)) {
1867 RParen = ConsumeParen();
1869 diag::err_expected_init_in_condition_lparen)
1910 void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
1912 const char *PrevSpec;
1919 case tok::identifier:
1920 case tok::coloncolon:
1921 llvm_unreachable(
"Annotation token should already be formed!");
1923 llvm_unreachable(
"Not a simple-type-specifier token!");
1926 case tok::annot_typename: {
1934 ConsumeAnnotationToken();
1936 DS.
Finish(Actions, Policy);
1947 case tok::kw___int64:
1950 case tok::kw_signed:
1953 case tok::kw_unsigned:
1965 case tok::kw___int128:
1974 case tok::kw_double:
1977 case tok::kw__Float16:
1980 case tok::kw___float128:
1983 case tok::kw_wchar_t:
1986 case tok::kw_char8_t:
1989 case tok::kw_char16_t:
1992 case tok::kw_char32_t:
1998 case tok::annot_decltype:
1999 case tok::kw_decltype:
2001 return DS.
Finish(Actions, Policy);
2004 case tok::kw_typeof:
2005 ParseTypeofSpecifier(DS);
2006 DS.
Finish(Actions, Policy);
2011 DS.
Finish(Actions, Policy);
2025 bool Parser::ParseCXXTypeSpecifierSeq(
DeclSpec &DS) {
2026 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_type_specifier);
2063 bool Parser::ParseUnqualifiedIdTemplateId(
CXXScopeSpec &SS,
2067 bool EnteringContext,
2070 bool AssumeTemplateId) {
2071 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2079 if (AssumeTemplateId) {
2083 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2088 bool MemberOfUnknownSpecialization;
2091 ObjectType, EnteringContext, Template,
2092 MemberOfUnknownSpecialization);
2095 ObjectType && IsTemplateArgumentList()) {
2114 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2124 bool MemberOfUnknownSpecialization;
2127 TemplateName, ObjectType,
2128 EnteringContext, Template,
2129 MemberOfUnknownSpecialization);
2135 bool MemberOfUnknownSpecialization;
2139 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
2140 EnteringContext, Template,
true);
2145 TemplateName, ObjectType,
2146 EnteringContext, Template,
2147 MemberOfUnknownSpecialization);
2150 Diag(NameLoc, diag::err_destructor_template_id)
2167 TemplateArgList TemplateArgs;
2168 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
2188 SS, TemplateKWLoc, Id.
StartLocation, TemplateII, OpKind, Template, TNK,
2189 LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
2201 Template, Name, NameLoc,
2202 LAngleLoc, TemplateArgsPtr, RAngleLoc,
2255 bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2258 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2264 unsigned SymbolIdx = 0;
2269 case tok::kw_delete: {
2270 bool isNew = Tok.
getKind() == tok::kw_new;
2274 if (Tok.
is(tok::l_square) &&
2285 Op = isNew? OO_Array_New : OO_Array_Delete;
2287 Op = isNew? OO_New : OO_Delete;
2292 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 2294 SymbolLocations[SymbolIdx++] = ConsumeToken(); \ 2297 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) 2298 #include "clang/Basic/OperatorKinds.def" 2300 case tok::l_paren: {
2314 case tok::l_square: {
2328 case tok::code_completion: {
2356 unsigned DiagId = 0;
2362 while (isTokenStringLiteral()) {
2363 if (!Tok.
is(tok::string_literal) && !DiagId) {
2368 DiagId = diag::err_literal_operator_string_prefix;
2370 Toks.push_back(Tok);
2371 TokLocs.push_back(ConsumeStringToken());
2388 }
else if (Tok.
is(tok::identifier)) {
2391 TokLocs.push_back(SuffixLoc);
2403 DiagLoc = TokLocs.front();
2404 DiagId = diag::err_literal_operator_string_not_empty;
2414 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2435 if (ParseCXXTypeSpecifierSeq(DS))
2441 ParseDeclaratorInternal(D,
nullptr);
2487 bool AllowDestructorName,
2488 bool AllowConstructorName,
2489 bool AllowDeductionGuide,
2498 bool TemplateSpecified =
false;
2499 if (Tok.
is(tok::kw_template)) {
2500 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2501 TemplateSpecified =
true;
2505 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2513 if (Tok.
is(tok::identifier)) {
2526 if (AllowConstructorName &&
2535 AllowDeductionGuide && SS.
isEmpty() &&
2547 if (Tok.
is(tok::less))
2548 return ParseUnqualifiedIdTemplateId(
2550 EnteringContext, ObjectType,
Result, TemplateSpecified);
2551 else if (TemplateSpecified &&
2553 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2554 EnteringContext, Template,
2563 if (Tok.
is(tok::annot_template_id)) {
2567 if (AllowConstructorName && TemplateId->
Name &&
2575 diag::err_out_of_line_constructor_template_id)
2586 ConsumeAnnotationToken();
2591 ConsumeAnnotationToken();
2600 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
2601 *TemplateKWLoc = TemplateLoc;
2603 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2606 ConsumeAnnotationToken();
2613 if (Tok.
is(tok::kw_operator)) {
2614 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result))
2626 return ParseUnqualifiedIdTemplateId(
2630 else if (TemplateSpecified &&
2632 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2633 EnteringContext, Template,
2641 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
2650 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
2662 if (Tok.
isNot(tok::identifier)) {
2663 Diag(Tok, diag::err_destructor_tilde_identifier);
2668 DeclaratorScopeObj DeclScopeObj(*
this, SS);
2669 if (!TemplateSpecified &&
NextToken().is(tok::coloncolon)) {
2676 AnnotateScopeToken(SS,
true);
2679 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
2682 ObjectType =
nullptr;
2685 Diag(TildeLoc, diag::err_destructor_tilde_scope);
2690 Diag(TildeLoc, diag::err_destructor_tilde_scope)
2696 DeclScopeObj.EnterDeclaratorScope();
2703 if (Tok.
is(tok::less)) {
2705 return ParseUnqualifiedIdTemplateId(
2706 SS, TemplateKWLoc ? *TemplateKWLoc :
SourceLocation(), ClassName,
2707 ClassNameLoc, EnteringContext, ObjectType, Result, TemplateSpecified);
2722 Diag(Tok, diag::err_expected_unqualified_id)
2756 Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
2757 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
2769 if (Tok.
is(tok::l_paren)) {
2774 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
2786 if (PlacementArgs.empty()) {
2792 if (Tok.
is(tok::l_paren)) {
2795 MaybeParseGNUAttributes(DeclaratorInfo);
2796 ParseSpecifierQualifierList(DS);
2798 ParseDeclarator(DeclaratorInfo);
2802 MaybeParseGNUAttributes(DeclaratorInfo);
2803 if (ParseCXXTypeSpecifierSeq(DS))
2807 ParseDeclaratorInternal(DeclaratorInfo,
2808 &Parser::ParseDirectNewDeclarator);
2815 MaybeParseGNUAttributes(DeclaratorInfo);
2816 if (ParseCXXTypeSpecifierSeq(DS))
2820 ParseDeclaratorInternal(DeclaratorInfo,
2821 &Parser::ParseDirectNewDeclarator);
2831 if (Tok.
is(tok::l_paren)) {
2837 if (Tok.
isNot(tok::r_paren)) {
2839 if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
2844 DeclaratorInfo.
getEndLoc(), ConstructorArgs, ConstructorLParen);
2845 CalledSignatureHelp =
true;
2853 DeclaratorInfo.
getEndLoc(), ConstructorArgs, ConstructorLParen);
2854 CalledSignatureHelp =
true;
2869 }
else if (Tok.
is(tok::l_brace) &&
getLangOpts().CPlusPlus11) {
2871 diag::warn_cxx98_compat_generalized_initializer_lists);
2872 Initializer = ParseBraceInitializer();
2877 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
2878 PlacementArgs, PlacementRParen,
2879 TypeIdParens, DeclaratorInfo, Initializer.
get());
2889 void Parser::ParseDirectNewDeclarator(
Declarator &D) {
2892 while (Tok.
is(tok::l_square)) {
2894 if (CheckProhibitedCXX11Attribute())
2913 MaybeParseCXX11Attributes(Attrs);
2936 bool Parser::ParseExpressionListOrTypeId(
2940 if (isTypeIdInParens()) {
2950 return ParseExpressionList(PlacementArgs, CommaLocs);
2965 Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
2966 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
2970 bool ArrayDelete =
false;
2971 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::r_square)) {
2989 ExprResult Operand(ParseCastExpression(
false));
2998 default: llvm_unreachable(
"Not a known type trait");
2999 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 3000 case tok::kw_ ## Spelling: return UTT_ ## Name; 3001 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 3002 case tok::kw_ ## Spelling: return BTT_ ## Name; 3003 #include "clang/Basic/TokenKinds.def" 3004 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 3005 case tok::kw_ ## Spelling: return TT_ ## Name; 3006 #include "clang/Basic/TokenKinds.def" 3012 default: llvm_unreachable(
"Not a known binary type trait");
3020 default: llvm_unreachable(
"Not a known unary expression trait.");
3028 default: llvm_unreachable(
"Not a known type trait");
3029 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N; 3030 #include "clang/Basic/TokenKinds.def" 3065 if (Tok.
is(tok::ellipsis)) {
3074 Args.push_back(Ty.
get());
3082 if (Arity && Args.size() != Arity) {
3083 Diag(EndLoc, diag::err_type_trait_arity)
3084 << Arity << 0 << (Arity > 1) << (
int)Args.size() <<
SourceRange(Loc);
3088 if (!Arity && Args.empty()) {
3089 Diag(EndLoc, diag::err_type_trait_arity)
3090 << 1 << 1 << 1 << (int)Args.size() <<
SourceRange(Loc);
3126 if (ExpectAndConsume(tok::comma)) {
3138 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3168 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
3173 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
3174 assert(isTypeIdInParens() &&
"Not a type-id!");
3198 ParenParseOption ParseAs;
3203 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3209 if (Tok.
is(tok::l_brace)) {
3210 ParseAs = CompoundLiteral;
3220 Result = ParseCastExpression(
false,
3229 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
3238 Toks.push_back(AttrEnd);
3241 Toks.push_back(Tok);
3244 PP.EnterTokenStream(Toks,
true );
3249 if (ParseAs >= CompoundLiteral) {
3255 ParseSpecifierQualifierList(DS);
3256 ParseDeclarator(DeclaratorInfo);
3267 if (ParseAs == CompoundLiteral) {
3268 ExprType = CompoundLiteral;
3273 return ParseCompoundLiteralExpression(Ty.
get(),
3287 DeclaratorInfo, CastTy,
3293 assert(ParseAs == SimpleExpr);
3295 ExprType = SimpleExpr;
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind)
Defines the clang::ASTContext interface.
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the binary type trait support pseudo-functions.
StringRef getUDSuffix() const
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
void restore()
restore - This can be used to restore the state early, before the dtor is run.
A (possibly-)qualified type.
Keeps information about an identifier in a nested-name-spec.
This is a scope that corresponds to the parameters within a function prototype.
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id)
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static const TSS TSS_unsigned
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup=false, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
static const TST TST_wchar
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static ConditionResult ConditionError()
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
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)) {...
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void setEndLoc(SourceLocation Loc)
static const TST TST_char16
Decl - This represents one declaration (or definition), e.g.
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
Defines the C++ template declaration subclasses.
The base class of the type hierarchy.
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
SourceLocation getEndLoc() const LLVM_READONLY
Parser - This implements a parser for the C family of languages.
An overloaded operator name, e.g., operator+.
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
static TemplateIdAnnotation * Create(CXXScopeSpec SS, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, IdentifierInfo *Name, OverloadedOperatorKind OperatorKind, ParsedTemplateTy OpaqueTemplateName, TemplateNameKind TemplateKind, SourceLocation LAngleLoc, SourceLocation RAngleLoc, ArrayRef< ParsedTemplateArgument > TemplateArgs, SmallVectorImpl< TemplateIdAnnotation *> &CleanupList)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List. ...
void CodeCompleteObjCMessageReceiver(Scope *S)
RAII object that enters a new expression evaluation context.
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
ActionResult< Stmt * > StmtResult
Information about one declarator, including the parsed type information and the identifier.
static const TST TST_char
Like System, but searched after the system directories.
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
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.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
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)
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
One of these records is kept for each identifier that is lexed.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
SourceLocation getAnnotationEndLoc() const
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
static const TST TST_char8
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
SourceLocation getBeginLoc() const LLVM_READONLY
LambdaCaptureKind
The different capture forms in a lambda introducer.
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
OverloadedOperatorKind Operator
The kind of overloaded operator.
static const TST TST_double
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
A user-defined literal name, e.g., operator "" _i.
void SetSourceRange(SourceRange R)
bool isInvalidType() const
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
This is a scope that corresponds to a block/closure object.
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
Represents a C++ unqualified-id that has been parsed.
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
< Capturing the *this object by copy
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
SourceRange getRange() const
QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr *> Args, SourceLocation OpenParLoc)
const clang::PrintingPolicy & getPrintingPolicy() const
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
ExprResult ActOnCXXThis(SourceLocation loc)
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
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 getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
ArrayTypeTrait
Names for the array type traits.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
SourceRange getSourceRange() const LLVM_READONLY
const char * getName() const
bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo)
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
static const TST TST_float
TypeTrait
Names for traits that operate specifically on types.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
static const TSW TSW_long
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl *> DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
void SetRangeStart(SourceLocation Loc)
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
Append a capture in a lambda introducer.
SourceRange getRange() const
SmallVector< LambdaCapture, 4 > Captures
TST getTypeSpecType() const
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed...
This represents one expression.
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
void setDeductionGuideName(ParsedTemplateTy Template, SourceLocation TemplateLoc)
Specify that this unqualified-id was parsed as a template-name for a deduction-guide.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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.
TypeResult ActOnTypeName(Scope *S, Declarator &D)
OpaquePtr< T > get() const
void setEofData(const void *D)
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
const Token & getCurToken() const
OpaquePtr< TemplateName > TemplateTy
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
void setAsmLabel(Expr *E)
SourceLocation getBeginLoc() const
Represents a C++ template name within the type system.
This is a compound statement scope.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
SourceLocation getEnd() const
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getOpenLocation() const
static const TST TST_half
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
static const TSW TSW_short
StringRef GetString() const
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
SourceLocation getEndLoc() const LLVM_READONLY
const LangOptions & getLangOpts() const
bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
This is a scope that corresponds to the parameters within a function prototype for a function declara...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
SourceManager & getSourceManager() const
static const TST TST_char32
unsigned getUDSuffixOffset() const
Get the spelling offset of the first byte of the ud-suffix.
SourceLocation DefaultLoc
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
unsigned getUDSuffixToken() const
Get the index of a token containing a ud-suffix.
ASTContext & getASTContext() const
static const TST TST_float16
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setLength(unsigned Len)
static void addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc, DeclSpec &DS)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
MutableArrayRef< Expr * > MultiExprArg
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
SourceLocation getEndLoc() const LLVM_READONLY
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
static const TSS TSS_signed
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
void CodeCompleteOperatorName(Scope *S)
void Lex(Token &Result)
Lex the next token for this preprocessor.
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
const void * getEofData() const
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Scope * getCurScope() const
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
ActOnCXXNew - Parsed a C++ 'new' expression.
static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken, Token &ColonToken, tok::TokenKind Kind, bool AtDigraph)
StringRef getName() const
Return the actual identifier string.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isNot(tok::TokenKind K) const
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, QualType BaseType)
static const TST TST_decltype_auto
The name does not refer to a template.
Dataflow Directional Tag Classes.
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
bool isValid() const
Return true if this is a valid SourceLocation object.
LambdaCaptureDefault Default
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_void
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static const TST TST_int128
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
unsigned getLength() const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
Not an overloaded operator.
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, Scope *CurScope)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
QualType getCanonicalTypeInternal() const
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
static void tryConsumeMutableOrConstexprToken(Parser &P, SourceLocation &MutableLoc, SourceLocation &ConstexprLoc, SourceLocation &DeclEndLoc)
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure...
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
static const TST TST_typename
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
Capturing the *this object by reference.
This is a scope that can contain a declaration.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool isSet() const
Deprecated.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
void setInvalidType(bool Val=true)
An integral condition for a 'switch' statement.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
Captures information about "declaration specifiers".
void setEnd(SourceLocation e)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind)
static int SelectDigraphErrorMessage(tok::TokenKind Kind)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
static const TST TST_float128
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static const TST TST_bool
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Represents a complete lambda introducer.
static const TSW TSW_longlong
Code completion occurs within the condition of an if, while, switch, or for statement.
static unsigned TypeTraitArity(tok::TokenKind kind)
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
unsigned NumArgs
NumArgs - The number of template arguments.
void * getAnnotationValue() const
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
void SetRangeEnd(SourceLocation Loc)
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
This class handles loading and caching of source files into memory.
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].
static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind)
Attr - This represents one attribute.
SourceLocation getLocation() const
void startToken()
Reset all flags to cleared.
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init)
Perform initialization analysis of the init-capture and perform any implicit conversions such as an l...
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Stop skipping at specified token, but don't skip the token itself.