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);
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,
107 void Parser::CheckForLParenAfterColonColon() {
108 if (!Tok.
is(tok::l_paren))
112 Token NextTok = GetLookAheadToken(1);
113 Token StarTok = NextTok;
115 Token IdentifierTok = StarTok.
is(tok::star) ? GetLookAheadToken(2) : StarTok;
116 if (IdentifierTok.
isNot(tok::identifier))
123 NextTok = StarTok.
is(tok::star) ? GetLookAheadToken(2) : GetLookAheadToken(1);
124 if (NextTok.
is(tok::r_paren)) {
127 if (StarTok.
is(tok::star))
134 if (StarTok.
is(tok::star))
187 bool Parser::ParseOptionalCXXScopeSpecifier(
CXXScopeSpec &SS,
189 bool EnteringContext,
190 bool *MayBePseudoDestructor,
194 "Call sites of this function should be guarded by checking for C++");
196 if (Tok.
is(tok::annot_cxxscope)) {
197 assert(!LastII &&
"want last identifier but have already annotated scope");
198 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
206 if (Tok.
is(tok::annot_template_id)) {
214 bool CheckForDestructor =
false;
215 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
216 CheckForDestructor =
true;
217 *MayBePseudoDestructor =
false;
223 bool HasScopeSpecifier =
false;
225 if (Tok.
is(tok::coloncolon)) {
228 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
231 if (NextKind == tok::l_brace) {
240 CheckForLParenAfterColonColon();
242 HasScopeSpecifier =
true;
246 if (Tok.
is(tok::kw___super)) {
248 if (!Tok.
is(tok::coloncolon)) {
256 if (!HasScopeSpecifier &&
257 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
264 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
271 HasScopeSpecifier =
true;
275 if (HasScopeSpecifier) {
288 if (Tok.
is(tok::code_completion)) {
307 if (Tok.
is(tok::kw_template)) {
311 if (!HasScopeSpecifier && !ObjectType)
314 TentativeParsingAction TPA(*
this);
318 if (Tok.
is(tok::identifier)) {
322 }
else if (Tok.
is(tok::kw_operator)) {
327 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
336 diag::err_id_after_template_in_nested_name_spec)
349 if (Tok.
isNot(tok::less)) {
359 SS, TemplateKWLoc, TemplateName,
360 ObjectType, EnteringContext,
362 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
363 TemplateName,
false))
371 if (Tok.
is(tok::annot_template_id) &&
NextToken().
is(tok::coloncolon)) {
380 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
381 *MayBePseudoDestructor =
true;
386 *LastII = TemplateId->
Name;
391 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
394 HasScopeSpecifier =
true;
420 if (Tok.
isNot(tok::identifier))
433 if (Next.
is(tok::colon) && !ColonIsSacred) {
442 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
449 if (Next.
is(tok::coloncolon) && GetLookAheadToken(2).
is(tok::l_brace)) {
452 Token Identifier = Tok;
456 UnconsumeToken(Identifier);
460 if (Next.
is(tok::coloncolon)) {
461 if (CheckForDestructor && GetLookAheadToken(2).
is(tok::tilde) &&
464 *MayBePseudoDestructor =
true;
469 const Token &Next2 = GetLookAheadToken(2);
470 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
471 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
472 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
477 ColonColon.setKind(tok::colon);
488 Token Identifier = Tok;
490 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
491 "NextToken() not working properly!");
492 Token ColonColon = Tok;
495 CheckForLParenAfterColonColon();
497 bool IsCorrectedToColon =
false;
498 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
500 ObjectType, EnteringContext, SS,
501 false, CorrectionFlagPtr)) {
504 if (CorrectionFlagPtr && IsCorrectedToColon) {
505 ColonColon.setKind(tok::colon);
513 HasScopeSpecifier =
true;
517 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
521 if (Next.
is(tok::less)) {
525 bool MemberOfUnknownSpecialization;
532 MemberOfUnknownSpecialization)) {
541 TemplateName,
false))
546 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
547 (IsTypename || IsTemplateArgumentList(1))) {
552 unsigned DiagID = diag::err_missing_dependent_template_keyword;
554 DiagID = diag::warn_missing_dependent_template_keyword;
563 TemplateName, ObjectType,
564 EnteringContext, Template)) {
568 TemplateName,
false))
586 if (CheckForDestructor && Tok.
is(tok::tilde))
587 *MayBePseudoDestructor =
true;
593 Token &Replacement) {
605 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
606 isAddressOfOperand =
false;
609 Tok.
is(tok::l_paren), isAddressOfOperand,
656 ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
662 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false);
666 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
670 UnconsumeToken(Replacement);
671 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
673 assert(!Result.
isUnset() &&
"Typo correction suggested a keyword replacement "
674 "for a previous keyword suggestion");
720 Optional<unsigned> DiagID = ParseLambdaIntroducer(Intro);
722 Diag(Tok, DiagID.getValue());
729 return ParseLambdaExpressionAfterIntroducer(Intro);
737 ExprResult Parser::TryParseLambdaExpression() {
739 && Tok.
is(tok::l_square)
740 &&
"Not at the start of a possible lambda expression.");
745 if (Next.is(tok::r_square) ||
746 Next.is(tok::equal) ||
747 (Next.is(tok::amp) &&
748 (
After.is(tok::r_square) ||
749 After.is(tok::comma))) ||
750 (Next.is(tok::identifier) &&
751 After.is(tok::r_square))) {
752 return ParseLambdaExpression();
757 if (Next.is(tok::identifier) &&
After.is(tok::identifier)) {
768 if (TryParseLambdaIntroducer(Intro))
771 return ParseLambdaExpressionAfterIntroducer(Intro);
784 bool *SkippedInits) {
785 typedef Optional<unsigned> DiagResult;
787 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
796 if (Tok.
is(tok::amp) &&
801 }
else if (Tok.
is(tok::equal)) {
807 while (Tok.
isNot(tok::r_square)) {
809 if (Tok.
isNot(tok::comma)) {
814 if (Tok.
is(tok::code_completion) &&
823 return DiagResult(diag::err_expected_comma_or_rsquare);
828 if (Tok.
is(tok::code_completion)) {
850 if (Tok.
is(tok::kw_this)) {
854 if (Tok.
is(tok::amp)) {
858 if (Tok.
is(tok::code_completion)) {
866 if (Tok.
is(tok::identifier)) {
869 }
else if (Tok.
is(tok::kw_this)) {
873 return DiagResult(diag::err_this_captured_by_reference);
875 return DiagResult(diag::err_expected_capture);
878 if (Tok.
is(tok::l_paren)) {
880 Parens.consumeOpen();
888 *SkippedInits =
true;
889 }
else if (ParseExpressionList(Exprs, Commas)) {
893 Parens.consumeClose();
895 Parens.getCloseLocation(),
898 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
911 Init = ParseInitializer();
912 }
else if (Tok.
is(tok::l_brace)) {
914 Braces.consumeOpen();
916 *SkippedInits =
true;
940 Init = ParseInitializer();
948 Tok.
setKind(tok::annot_primary_expr);
949 setExprAnnotation(Tok, Init);
1006 Loc, Kind ==
LCK_ByRef, Id, InitKind, InitExpr);
1009 Intro.
addCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
1015 return DiagResult();
1022 TentativeParsingAction PA(*
this);
1024 bool SkippedInits =
false;
1025 Optional<unsigned> DiagID(ParseLambdaIntroducer(Intro, &SkippedInits));
1036 DiagID = ParseLambdaIntroducer(Intro);
1037 assert(!DiagID &&
"parsing lambda-introducer failed on reparse");
1047 ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1050 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1053 "lambda expression parsing");
1063 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1067 if (Tok.
is(tok::l_paren)) {
1068 ParseScope PrototypeScope(
this,
1083 if (Tok.
isNot(tok::r_paren)) {
1085 ParseParameterDeclarationClause(D,
Attr, ParamInfo, EllipsisLoc);
1089 ++CurTemplateDepthTracker;
1093 DeclEndLoc = RParenLoc;
1097 MaybeParseGNUAttributes(
Attr, &DeclEndLoc);
1101 MaybeParseMicrosoftDeclSpecs(
Attr, &DeclEndLoc);
1106 DeclEndLoc = MutableLoc;
1115 ESpecType = tryParseExceptionSpecification(
false,
1118 DynamicExceptionRanges,
1120 ExceptionSpecTokens);
1123 DeclEndLoc = ESpecRange.
getEnd();
1126 MaybeParseCXX11Attributes(
Attr, &DeclEndLoc);
1131 if (Tok.
is(tok::arrow)) {
1134 TrailingReturnType = ParseTrailingReturnType(Range);
1136 DeclEndLoc = Range.
getEnd();
1139 PrototypeScope.Exit();
1145 ParamInfo.data(), ParamInfo.size(),
1146 EllipsisLoc, RParenLoc,
1147 DS.getTypeQualifiers(),
1154 ESpecType, ESpecRange,
1155 DynamicExceptions.data(),
1156 DynamicExceptionRanges.data(),
1157 DynamicExceptions.size(),
1159 NoexceptExpr.
get() :
nullptr,
1161 LParenLoc, FunLocalRangeEnd, D,
1162 TrailingReturnType),
1164 }
else if (Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute) ||
1168 unsigned TokKind = 0;
1170 case tok::kw_mutable: TokKind = 0;
break;
1171 case tok::arrow: TokKind = 1;
break;
1172 case tok::kw___attribute:
1173 case tok::l_square: TokKind = 2;
break;
1174 default: llvm_unreachable(
"Unknown token kind");
1177 Diag(Tok, diag::err_lambda_missing_parens)
1186 MaybeParseGNUAttributes(
Attr, &DeclEndLoc);
1190 if (Tok.
is(tok::kw_mutable)) {
1192 DeclEndLoc = MutableLoc;
1196 MaybeParseCXX11Attributes(
Attr, &DeclEndLoc);
1199 if (Tok.
is(tok::arrow)) {
1201 TrailingReturnType = ParseTrailingReturnType(Range);
1203 DeclEndLoc = Range.
getEnd();
1228 DeclLoc, DeclEndLoc, D,
1229 TrailingReturnType),
1237 ParseScope BodyScope(
this, ScopeFlags);
1242 if (!Tok.
is(tok::l_brace)) {
1243 Diag(Tok, diag::err_expected_lambda_body);
1269 const char *CastName =
nullptr;
1272 default: llvm_unreachable(
"Unknown C++ cast!");
1273 case tok::kw_const_cast: CastName =
"const_cast";
break;
1274 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1275 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1276 case tok::kw_static_cast: CastName =
"static_cast";
break;
1284 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1286 if (Next.
is(tok::colon) && areTokensAdjacent(Tok, Next))
1287 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1290 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1295 ParseSpecifierQualifierList(DS);
1299 ParseDeclarator(DeclaratorInfo);
1303 if (ExpectAndConsume(tok::greater))
1304 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1309 if (T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1317 if (!Result.
isInvalid() && !DeclaratorInfo.isInvalidType())
1319 LAngleBracketLoc, DeclaratorInfo,
1321 T.getOpenLocation(), Result.
get(),
1322 T.getCloseLocation());
1334 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1341 if (T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1343 LParenLoc = T.getOpenLocation();
1363 if (isTypeIdInParens()) {
1368 RParenLoc = T.getCloseLocation();
1373 Ty.
get().getAsOpaquePtr(), RParenLoc);
1382 RParenLoc = T.getCloseLocation();
1387 Result.
get(), RParenLoc);
1400 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1406 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1411 if (isTypeIdInParens()) {
1420 Result = Actions.
ActOnCXXUuidof(OpLoc, T.getOpenLocation(),
true,
1421 Ty.
get().getAsOpaquePtr(),
1422 T.getCloseLocation());
1435 Result.
get(), T.getCloseLocation());
1471 if (Tok.
is(tok::identifier)) {
1474 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1476 }
else if (Tok.
is(tok::annot_template_id)) {
1482 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1489 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1492 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid() && SS.
isEmpty()) {
1494 ParseDecltypeSpecifier(DS);
1501 if (!Tok.
is(tok::identifier)) {
1502 Diag(Tok, diag::err_destructor_tilde_identifier);
1514 if (Tok.
is(tok::less) &&
1517 false, ObjectType, SecondTypeName,
1522 SS, FirstTypeName, CCLoc, TildeLoc,
1541 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1567 ExprResult Parser::ParseCoyieldExpression() {
1568 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1584 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1602 Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1606 assert((Tok.
is(tok::l_paren) ||
1608 &&
"Expected '(' or '{'!");
1610 if (Tok.
is(tok::l_brace)) {
1614 Expr *InitList = Init.
get();
1623 CommaLocsTy CommaLocs;
1625 if (Tok.
isNot(tok::r_paren)) {
1626 if (ParseExpressionList(Exprs, CommaLocs, [&] {
1643 assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
1644 "Unexpected number of commas!");
1647 T.getCloseLocation());
1674 bool Parser::ParseCXXCondition(
ExprResult &ExprOut,
1677 bool ConvertToBoolean) {
1678 if (Tok.
is(tok::code_completion)) {
1684 ParsedAttributesWithRange attrs(AttrFactory);
1685 MaybeParseCXX11Attributes(attrs);
1687 if (!isCXXConditionDeclaration()) {
1688 ProhibitAttributes(attrs);
1697 if (ConvertToBoolean)
1706 ParseSpecifierQualifierList(DS,
AS_none, DSC_condition);
1710 ParseDeclarator(DeclaratorInfo);
1713 if (Tok.
is(tok::kw_asm)) {
1716 if (AsmLabel.isInvalid()) {
1720 DeclaratorInfo.setAsmLabel(AsmLabel.get());
1721 DeclaratorInfo.SetRangeEnd(Loc);
1725 MaybeParseGNUAttributes(DeclaratorInfo);
1730 DeclOut = Dcl.
get();
1735 bool CopyInitialization = isTokenEqualOrEqualTypo();
1736 if (CopyInitialization)
1742 diag::warn_cxx98_compat_generalized_initializer_lists);
1743 InitExpr = ParseBraceInitializer();
1744 }
else if (CopyInitialization) {
1746 }
else if (Tok.
is(tok::l_paren)) {
1750 RParen = ConsumeParen();
1752 diag::err_expected_init_in_condition_lparen)
1756 diag::err_expected_init_in_condition);
1799 void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
1801 const char *PrevSpec;
1808 case tok::identifier:
1809 case tok::coloncolon:
1810 llvm_unreachable(
"Annotation token should already be formed!");
1812 llvm_unreachable(
"Not a simple-type-specifier token!");
1815 case tok::annot_typename: {
1825 DS.
Finish(Actions, Policy);
1836 case tok::kw___int64:
1839 case tok::kw_signed:
1842 case tok::kw_unsigned:
1854 case tok::kw___int128:
1863 case tok::kw_double:
1866 case tok::kw_wchar_t:
1869 case tok::kw_char16_t:
1872 case tok::kw_char32_t:
1878 case tok::annot_decltype:
1879 case tok::kw_decltype:
1881 return DS.
Finish(Actions, Policy);
1884 case tok::kw_typeof:
1885 ParseTypeofSpecifier(DS);
1886 DS.
Finish(Actions, Policy);
1889 if (Tok.
is(tok::annot_typename))
1894 DS.
Finish(Actions, Policy);
1908 bool Parser::ParseCXXTypeSpecifierSeq(
DeclSpec &DS) {
1909 ParseSpecifierQualifierList(DS,
AS_none, DSC_type_specifier);
1946 bool Parser::ParseUnqualifiedIdTemplateId(
CXXScopeSpec &SS,
1950 bool EnteringContext,
1953 bool AssumeTemplateId) {
1954 assert((AssumeTemplateId || Tok.
is(tok::less)) &&
1955 "Expected '<' to finish parsing a template-id");
1963 if (AssumeTemplateId) {
1965 Id, ObjectType, EnteringContext,
1970 bool MemberOfUnknownSpecialization;
1973 ObjectType, EnteringContext, Template,
1974 MemberOfUnknownSpecialization);
1977 ObjectType && IsTemplateArgumentList()) {
1996 SS, TemplateKWLoc, Id,
1997 ObjectType, EnteringContext,
2007 bool MemberOfUnknownSpecialization;
2010 TemplateName, ObjectType,
2011 EnteringContext, Template,
2012 MemberOfUnknownSpecialization);
2018 bool MemberOfUnknownSpecialization;
2022 SS, TemplateKWLoc, TemplateName,
2023 ObjectType, EnteringContext,
2029 TemplateName, ObjectType,
2030 EnteringContext, Template,
2031 MemberOfUnknownSpecialization);
2034 Diag(NameLoc, diag::err_destructor_template_id)
2051 TemplateArgList TemplateArgs;
2052 if (Tok.
is(tok::less) &&
2053 ParseTemplateIdAfterTemplateName(Template, Id.
StartLocation,
2054 SS,
true, LAngleLoc,
2073 TemplateId->
Name =
nullptr;
2078 TemplateId->
SS = SS;
2081 TemplateId->
Kind = TNK;
2085 for (
unsigned Arg = 0, ArgEnd = TemplateArgs.size();
2086 Arg != ArgEnd; ++Arg)
2087 Args[Arg] = TemplateArgs[Arg];
2100 LAngleLoc, TemplateArgsPtr, RAngleLoc,
2153 bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2156 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2162 unsigned SymbolIdx = 0;
2167 case tok::kw_delete: {
2168 bool isNew = Tok.
getKind() == tok::kw_new;
2172 if (Tok.
is(tok::l_square) &&
2178 if (T.getCloseLocation().isInvalid())
2181 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2182 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2183 Op = isNew? OO_Array_New : OO_Array_Delete;
2185 Op = isNew? OO_New : OO_Delete;
2190 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2192 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2195 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2196 #include "clang/Basic/OperatorKinds.def"
2198 case tok::l_paren: {
2203 if (T.getCloseLocation().isInvalid())
2206 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2207 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2212 case tok::l_square: {
2217 if (T.getCloseLocation().isInvalid())
2220 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2221 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2226 case tok::code_completion: {
2254 unsigned DiagId = 0;
2260 while (isTokenStringLiteral()) {
2261 if (!Tok.
is(tok::string_literal) && !DiagId) {
2266 DiagId = diag::err_literal_operator_string_prefix;
2268 Toks.push_back(Tok);
2269 TokLocs.push_back(ConsumeStringToken());
2273 if (Literal.hadError)
2280 if (!Literal.getUDSuffix().empty()) {
2284 Literal.getUDSuffixOffset(),
2286 }
else if (Tok.
is(tok::identifier)) {
2289 TokLocs.push_back(SuffixLoc);
2296 if (!Literal.GetString().empty() || Literal.Pascal) {
2301 DiagLoc = TokLocs.front();
2302 DiagId = diag::err_literal_operator_string_not_empty;
2312 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2333 if (ParseCXXTypeSpecifierSeq(DS))
2339 ParseDeclaratorInternal(D,
nullptr);
2348 D.getSourceRange().getEnd());
2383 bool AllowDestructorName,
2384 bool AllowConstructorName,
2391 bool TemplateSpecified =
false;
2393 (ObjectType || SS.
isSet())) {
2394 TemplateSpecified =
true;
2401 if (Tok.
is(tok::identifier)) {
2413 if (AllowConstructorName &&
2428 if (TemplateSpecified || Tok.
is(tok::less))
2429 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc, Id, IdLoc,
2430 EnteringContext, ObjectType,
2431 Result, TemplateSpecified);
2438 if (Tok.
is(tok::annot_template_id)) {
2442 if (AllowConstructorName && TemplateId->
Name &&
2450 diag::err_out_of_line_constructor_template_id)
2483 if (Tok.
is(tok::kw_operator)) {
2484 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result))
2494 (TemplateSpecified || Tok.
is(tok::less)))
2495 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
2497 EnteringContext, ObjectType,
2498 Result, TemplateSpecified);
2504 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
2513 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
2524 if (Tok.
isNot(tok::identifier)) {
2525 Diag(Tok, diag::err_destructor_tilde_identifier);
2530 DeclaratorScopeObj DeclScopeObj(*
this, SS);
2531 if (!TemplateSpecified &&
NextToken().is(tok::coloncolon)) {
2538 AnnotateScopeToken(SS,
true);
2541 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
2547 Diag(TildeLoc, diag::err_destructor_tilde_scope);
2552 Diag(TildeLoc, diag::err_destructor_tilde_scope)
2558 DeclScopeObj.EnterDeclaratorScope();
2565 if (TemplateSpecified || Tok.
is(tok::less)) {
2567 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
2568 ClassName, ClassNameLoc,
2569 EnteringContext, ObjectType,
2570 Result, TemplateSpecified);
2585 Diag(Tok, diag::err_expected_unqualified_id)
2619 Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
2620 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
2626 ExprVector PlacementArgs;
2632 if (Tok.
is(tok::l_paren)) {
2636 PlacementLParen = T.getOpenLocation();
2637 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
2643 PlacementRParen = T.getCloseLocation();
2649 if (PlacementArgs.empty()) {
2651 TypeIdParens = T.getRange();
2655 if (Tok.
is(tok::l_paren)) {
2658 MaybeParseGNUAttributes(DeclaratorInfo);
2659 ParseSpecifierQualifierList(DS);
2661 ParseDeclarator(DeclaratorInfo);
2663 TypeIdParens = T.getRange();
2665 MaybeParseGNUAttributes(DeclaratorInfo);
2666 if (ParseCXXTypeSpecifierSeq(DS))
2667 DeclaratorInfo.setInvalidType(
true);
2670 ParseDeclaratorInternal(DeclaratorInfo,
2671 &Parser::ParseDirectNewDeclarator);
2678 MaybeParseGNUAttributes(DeclaratorInfo);
2679 if (ParseCXXTypeSpecifierSeq(DS))
2680 DeclaratorInfo.setInvalidType(
true);
2683 ParseDeclaratorInternal(DeclaratorInfo,
2684 &Parser::ParseDirectNewDeclarator);
2687 if (DeclaratorInfo.isInvalidType()) {
2694 if (Tok.
is(tok::l_paren)) {
2696 ExprVector ConstructorArgs;
2699 ConstructorLParen = T.getOpenLocation();
2700 if (Tok.
isNot(tok::r_paren)) {
2701 CommaLocsTy CommaLocs;
2702 if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
2704 DeclaratorInfo).
get();
2707 DeclaratorInfo.getLocEnd(),
2715 ConstructorRParen = T.getCloseLocation();
2723 }
else if (Tok.
is(tok::l_brace) &&
getLangOpts().CPlusPlus11) {
2725 diag::warn_cxx98_compat_generalized_initializer_lists);
2726 Initializer = ParseBraceInitializer();
2731 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
2732 PlacementArgs, PlacementRParen,
2733 TypeIdParens, DeclaratorInfo, Initializer.
get());
2743 void Parser::ParseDirectNewDeclarator(
Declarator &D) {
2746 while (Tok.
is(tok::l_square)) {
2748 if (CheckProhibitedCXX11Attribute())
2756 if (Size.isInvalid()) {
2767 MaybeParseCXX11Attributes(Attrs);
2772 T.getOpenLocation(),
2773 T.getCloseLocation()),
2774 Attrs, T.getCloseLocation());
2776 if (T.getCloseLocation().isInvalid())
2791 bool Parser::ParseExpressionListOrTypeId(
2795 if (isTypeIdInParens()) {
2804 CommaLocsTy CommaLocs;
2805 return ParseExpressionList(PlacementArgs, CommaLocs);
2820 Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
2821 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
2825 bool ArrayDelete =
false;
2826 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::r_square)) {
2840 if (T.getCloseLocation().isInvalid())
2844 ExprResult Operand(ParseCastExpression(
false));
2845 if (Operand.isInvalid())
2848 return Actions.
ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.get());
2853 default: llvm_unreachable(
"Not a known type trait");
2854 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2855 case tok::kw_ ## Spelling: return UTT_ ## Name;
2856 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2857 case tok::kw_ ## Spelling: return BTT_ ## Name;
2858 #include "clang/Basic/TokenKinds.def"
2859 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2860 case tok::kw_ ## Spelling: return TT_ ## Name;
2861 #include "clang/Basic/TokenKinds.def"
2867 default: llvm_unreachable(
"Not a known binary type trait");
2875 default: llvm_unreachable(
"Not a known unary expression trait.");
2883 default: llvm_unreachable(
"Not a known type trait");
2884 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N;
2885 #include "clang/Basic/TokenKinds.def"
2907 if (Parens.expectAndConsume())
2920 if (Tok.
is(tok::ellipsis)) {
2929 Args.push_back(Ty.
get());
2932 if (Parens.consumeClose())
2937 if (Arity && Args.size() != Arity) {
2938 Diag(EndLoc, diag::err_type_trait_arity)
2939 << Arity << 0 << (Arity > 1) << (
int)Args.size() <<
SourceRange(Loc);
2943 if (!Arity && Args.empty()) {
2944 Diag(EndLoc, diag::err_type_trait_arity)
2945 << 1 << 1 << 1 << (int)Args.size() <<
SourceRange(Loc);
2964 if (T.expectAndConsume())
2978 T.getCloseLocation());
2981 if (ExpectAndConsume(tok::comma)) {
2990 T.getCloseLocation());
2993 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3007 if (T.expectAndConsume())
3015 T.getCloseLocation());
3023 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
3028 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
3029 assert(isTypeIdInParens() &&
"Not a type-id!");
3053 ParenParseOption ParseAs;
3058 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3064 if (Tok.
is(tok::l_brace)) {
3065 ParseAs = CompoundLiteral;
3075 Result = ParseCastExpression(
false,
3084 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
3088 Toks.push_back(Tok);
3097 if (ParseAs >= CompoundLiteral) {
3103 ParseSpecifierQualifierList(DS);
3104 ParseDeclarator(DeclaratorInfo);
3111 if (ParseAs == CompoundLiteral) {
3112 ExprType = CompoundLiteral;
3113 if (DeclaratorInfo.isInvalidType())
3117 return ParseCompoundLiteralExpression(Ty.
get(),
3125 if (DeclaratorInfo.isInvalidType())
3131 DeclaratorInfo, CastTy,
3137 assert(ParseAs == SimpleExpr);
3139 ExprType = SimpleExpr;
SourceManager & getSourceManager() const
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind)
SourceLocation getCloseLocation() const
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the bianry type trait support pseudo-functions.
IdKind getKind() const
Determine what kind of name we have.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
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.
This is a scope that corresponds to the parameters within a function prototype.
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
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.
const LangOptions & getLangOpts() const
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.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
The current expression is potentially evaluated at run time, which means that code may be generated t...
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.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
Defines the C++ template declaration subclasses.
const char * getName() const
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
The base class of the type hierarchy.
This indicates that the scope corresponds to a function, which means that labels are set here...
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
TemplateNameKind Kind
The kind of template that Template refers to.
Parser - This implements a parser for the C family of languages.
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
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.
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)
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
Describes how types, statements, expressions, and declarations should be printed. ...
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
bool isEmpty() const
No scope specifier.
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)
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args)
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.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
LambdaCaptureKind
The different capture forms in a lambda introducer.
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
OverloadedOperatorKind Operator
The kind of overloaded operator.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false)
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)
void SetSourceRange(SourceRange R)
ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, Expr *SubExpr)
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
A location where the result (returned value) of evaluating a statement should be stored.
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Capturing by copy (a.k.a., by value)
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=ParsedType(), bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
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)
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...
ArrayTypeTrait
Names for the array type traits.
tok::TokenKind getKind() const
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
SourceRange getSourceRange() const LLVM_READONLY
QualType getCanonicalTypeInternal() const
SourceRange getRange() const
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword within the source.
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.
void * getAnnotationValue() const
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
static const TSW TSW_long
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void SetRangeStart(SourceLocation Loc)
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
SmallVector< LambdaCapture, 4 > Captures
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &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)
OpaquePtr< TemplateName > TemplateTy
Represents a C++ template name within the type system.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isNot(tok::TokenKind K) const
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.
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_half
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
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.
SourceLocation getAnnotationEndLoc() const
static const TSW TSW_short
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
const clang::PrintingPolicy & getPrintingPolicy() 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 ...
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
OpaquePtr< T > get() const
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)
static const TST TST_char32
ParsedType getDestructorType(const DeclSpec &DS, ParsedType ObjectType)
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
SourceLocation DefaultLoc
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.
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType)
Append a capture in a lambda introducer.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setLength(unsigned Len)
An overloaded operator name, e.g., operator+.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
Scope * getCurScope() const
void EnterTokenStream(const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens)
Add a "macro" context to the top of the include stack, which will cause the lexer to start returning ...
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.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
SourceLocation getBegin() const
SourceLocation getBeginLoc() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
ActOnCXXNew - Parsed a C++ 'new' expression.
MutableArrayRef< Expr * > MultiExprArg
static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken, Token &ColonToken, tok::TokenKind Kind, bool AtDigraph)
bool containsPlaceholderType() const
SourceLocation getOpenLocation() const
bool ActOnCXXNestedNameSpecifier(Scope *S, IdentifierInfo &Identifier, SourceLocation IdentifierLoc, SourceLocation CCLoc, ParsedType ObjectType, bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup=false, bool *IsCorrectedToColon=nullptr)
The parser has parsed a nested-name-specifier 'identifier::'.
The name does not refer to a template.
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...
LambdaCaptureDefault Default
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, IdentifierInfo &Identifier, SourceLocation IdentifierLoc, SourceLocation ColonLoc, ParsedType ObjectType, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
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.
SourceLocation getLocEnd() const LLVM_READONLY
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
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...
Not an overloaded operator.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, Scope *CurScope)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure...
OverloadedOperatorKind Operator
FIXME: Temporarily stores the overloaded operator kind.
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.
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
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
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.
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
Capturing the this pointer.
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)
static ParsedType getTypeAnnotation(Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template)
Form a dependent template name.
Captures information about "declaration specifiers".
void setEnd(SourceLocation e)
bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, SourceLocation IdLoc, IdentifierInfo &II, ParsedType ObjectType)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind)
A user-defined literal name, e.g., operator "" _i.
static TemplateIdAnnotation * Allocate(unsigned NumArgs, SmallVectorImpl< TemplateIdAnnotation * > &List)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List. ...
static int SelectDigraphErrorMessage(tok::TokenKind Kind)
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
bool isSet() const
Deprecated.
Code completion occurs within the condition of an if, while, switch, or for statement.
unsigned getLength() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
static unsigned TypeTraitArity(tok::TokenKind kind)
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isInvalidType() const
unsigned NumArgs
NumArgs - The number of template arguments.
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
void SetRangeEnd(SourceLocation Loc)
ParsedAttributes - A collection of parsed attributes.
This class handles loading and caching of source files into memory.
static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind)
Attr - This represents one attribute.
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.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
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.
IdentifierInfo * getIdentifierInfo() const