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,
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) {
248 ObjectType =
nullptr;
250 if (Tok.
is(tok::code_completion)) {
269 if (Tok.
is(tok::kw_template)) {
273 if (!HasScopeSpecifier && !ObjectType)
276 TentativeParsingAction TPA(*
this);
280 if (Tok.
is(tok::identifier)) {
284 }
else if (Tok.
is(tok::kw_operator)) {
289 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
298 diag::err_id_after_template_in_nested_name_spec)
311 if (Tok.
isNot(tok::less)) {
320 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
321 EnteringContext, Template,
true)) {
322 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
323 TemplateName,
false))
331 if (Tok.
is(tok::annot_template_id) &&
NextToken().
is(tok::coloncolon)) {
340 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
341 *MayBePseudoDestructor =
true;
346 *LastII = TemplateId->
Name;
349 ConsumeAnnotationToken();
351 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
354 HasScopeSpecifier =
true;
380 if (Tok.
isNot(tok::identifier))
395 if (Next.
is(tok::colon) && !ColonIsSacred) {
402 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
409 if (Next.
is(tok::coloncolon) && GetLookAheadToken(2).
is(tok::l_brace)) {
412 Token Identifier = Tok;
416 UnconsumeToken(Identifier);
420 if (Next.
is(tok::coloncolon)) {
421 if (CheckForDestructor && GetLookAheadToken(2).
is(tok::tilde) &&
423 *MayBePseudoDestructor =
true;
428 const Token &Next2 = GetLookAheadToken(2);
429 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
430 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
431 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
436 ColonColon.setKind(tok::colon);
447 Token Identifier = Tok;
449 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
450 "NextToken() not working properly!");
451 Token ColonColon = Tok;
454 bool IsCorrectedToColon =
false;
455 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
458 CorrectionFlagPtr, OnlyNamespace)) {
461 if (CorrectionFlagPtr && IsCorrectedToColon) {
462 ColonColon.setKind(tok::colon);
470 HasScopeSpecifier =
true;
474 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
478 if (Next.
is(tok::less)) {
482 bool MemberOfUnknownSpecialization;
489 MemberOfUnknownSpecialization)) {
498 TemplateName,
false))
503 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
504 (IsTypename || IsTemplateArgumentList(1))) {
509 unsigned DiagID = diag::err_missing_dependent_template_keyword;
511 DiagID = diag::warn_missing_dependent_template_keyword;
519 EnteringContext, Template,
true)) {
523 TemplateName,
false))
541 if (CheckForDestructor && Tok.
is(tok::tilde))
542 *MayBePseudoDestructor =
true;
556 nullptr, TemplateKWLoc, Name))
561 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
562 isAddressOfOperand =
false;
565 Tok.
is(tok::l_paren), isAddressOfOperand,
612 ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
618 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
622 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
626 UnconsumeToken(Replacement);
627 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
629 assert(!Result.
isUnset() &&
"Typo correction suggested a keyword replacement "
630 "for a previous keyword suggestion");
676 Optional<unsigned> DiagID = ParseLambdaIntroducer(Intro);
678 Diag(Tok, DiagID.getValue());
685 return ParseLambdaExpressionAfterIntroducer(Intro);
693 ExprResult Parser::TryParseLambdaExpression() {
695 && Tok.
is(tok::l_square)
696 &&
"Not at the start of a possible lambda expression.");
704 if (Next.is(tok::r_square) ||
705 Next.is(tok::equal) ||
706 (Next.is(tok::amp) &&
707 (After.
is(tok::r_square) ||
708 After.
is(tok::comma))) ||
709 (Next.is(tok::identifier) &&
710 After.
is(tok::r_square))) {
711 return ParseLambdaExpression();
716 if (Next.is(tok::identifier) && After.
is(tok::identifier)) {
727 if (TryParseLambdaIntroducer(Intro))
730 return ParseLambdaExpressionAfterIntroducer(Intro);
743 bool *SkippedInits) {
744 typedef Optional<unsigned> DiagResult;
746 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
755 if (Tok.
is(tok::amp) &&
760 }
else if (Tok.
is(tok::equal)) {
766 while (Tok.
isNot(tok::r_square)) {
768 if (Tok.
isNot(tok::comma)) {
773 if (Tok.
is(tok::code_completion) &&
782 return DiagResult(diag::err_expected_comma_or_rsquare);
787 if (Tok.
is(tok::code_completion)) {
809 if (Tok.
is(tok::star)) {
811 if (Tok.
is(tok::kw_this)) {
815 return DiagResult(diag::err_expected_star_this_capture);
817 }
else if (Tok.
is(tok::kw_this)) {
821 if (Tok.
is(tok::amp)) {
825 if (Tok.
is(tok::code_completion)) {
833 if (Tok.
is(tok::identifier)) {
836 }
else if (Tok.
is(tok::kw_this)) {
840 return DiagResult(diag::err_this_captured_by_reference);
842 return DiagResult(diag::err_expected_capture);
845 if (Tok.
is(tok::l_paren)) {
847 Parens.consumeOpen();
855 *SkippedInits =
true;
856 }
else if (ParseExpressionList(Exprs, Commas)) {
860 Parens.consumeClose();
862 Parens.getCloseLocation(),
865 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
878 Init = ParseInitializer();
879 }
else if (Tok.
is(tok::l_brace)) {
881 Braces.consumeOpen();
883 *SkippedInits =
true;
907 Init = ParseInitializer();
917 Tok.
setKind(tok::annot_primary_expr);
918 setExprAnnotation(Tok, Init);
923 ConsumeAnnotationToken();
976 Loc, Kind ==
LCK_ByRef, Id, InitKind, InitExpr);
979 Intro.
addCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
992 TentativeParsingAction PA(*
this);
994 bool SkippedInits =
false;
995 Optional<unsigned> DiagID(ParseLambdaIntroducer(Intro, &SkippedInits));
1006 DiagID = ParseLambdaIntroducer(Intro);
1007 assert(!DiagID &&
"parsing lambda-introducer failed on reparse");
1027 case tok::kw_mutable: {
1030 diag::err_lambda_decl_specifier_repeated)
1034 DeclEndLoc = MutableLoc;
1037 case tok::kw_constexpr:
1040 diag::err_lambda_decl_specifier_repeated)
1044 DeclEndLoc = ConstexprLoc;
1057 ? diag::ext_constexpr_on_lambda_cxx1z
1058 : diag::warn_cxx14_compat_constexpr_on_lambda);
1059 const char *PrevSpec =
nullptr;
1060 unsigned DiagID = 0;
1062 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1063 "Constexpr cannot have been set previously!");
1069 ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1072 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1075 "lambda expression parsing");
1085 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1093 MaybeParseGNUAttributes(D);
1098 auto WarnIfHasCUDATargetAttr = [&] {
1100 for (
auto *A =
Attr.getList(); A !=
nullptr; A = A->getNext())
1101 if (A->getKind() == AttributeList::AT_CUDADevice ||
1102 A->getKind() == AttributeList::AT_CUDAHost ||
1103 A->getKind() == AttributeList::AT_CUDAGlobal)
1104 Diag(A->getLoc(), diag::warn_cuda_attr_lambda_position)
1105 << A->getName()->getName();
1109 if (Tok.
is(tok::l_paren)) {
1110 ParseScope PrototypeScope(
this,
1123 if (Tok.
isNot(tok::r_paren)) {
1125 ParseParameterDeclarationClause(D,
Attr, ParamInfo, EllipsisLoc);
1129 ++CurTemplateDepthTracker;
1137 MaybeParseGNUAttributes(
Attr, &DeclEndLoc);
1141 MaybeParseMicrosoftDeclSpecs(
Attr, &DeclEndLoc);
1158 ESpecType = tryParseExceptionSpecification(
false,
1161 DynamicExceptionRanges,
1163 ExceptionSpecTokens);
1166 DeclEndLoc = ESpecRange.
getEnd();
1169 MaybeParseCXX11Attributes(
Attr, &DeclEndLoc);
1174 if (Tok.
is(tok::arrow)) {
1177 TrailingReturnType = ParseTrailingReturnType(Range);
1179 DeclEndLoc = Range.
getEnd();
1182 PrototypeScope.Exit();
1184 WarnIfHasCUDATargetAttr();
1190 ParamInfo.data(), ParamInfo.size(),
1191 EllipsisLoc, RParenLoc,
1192 DS.getTypeQualifiers(),
1199 ESpecType, ESpecRange,
1200 DynamicExceptions.data(),
1201 DynamicExceptionRanges.data(),
1202 DynamicExceptions.size(),
1204 NoexceptExpr.
get() :
nullptr,
1207 LParenLoc, FunLocalRangeEnd, D,
1208 TrailingReturnType),
1210 }
else if (Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1211 tok::kw_constexpr) ||
1215 unsigned TokKind = 0;
1217 case tok::kw_mutable: TokKind = 0;
break;
1218 case tok::arrow: TokKind = 1;
break;
1219 case tok::kw___attribute:
1220 case tok::l_square: TokKind = 2;
break;
1221 case tok::kw_constexpr: TokKind = 3;
break;
1222 default: llvm_unreachable(
"Unknown token kind");
1225 Diag(Tok, diag::err_lambda_missing_parens)
1232 MaybeParseGNUAttributes(
Attr, &DeclEndLoc);
1236 if (Tok.
is(tok::kw_mutable)) {
1238 DeclEndLoc = MutableLoc;
1242 MaybeParseCXX11Attributes(
Attr, &DeclEndLoc);
1245 if (Tok.
is(tok::arrow)) {
1247 TrailingReturnType = ParseTrailingReturnType(Range);
1249 DeclEndLoc = Range.
getEnd();
1252 WarnIfHasCUDATargetAttr();
1277 DeclLoc, DeclEndLoc, D,
1278 TrailingReturnType),
1285 ParseScope BodyScope(
this, ScopeFlags);
1290 if (!Tok.
is(tok::l_brace)) {
1291 Diag(Tok, diag::err_expected_lambda_body);
1317 const char *CastName =
nullptr;
1320 default: llvm_unreachable(
"Unknown C++ cast!");
1321 case tok::kw_const_cast: CastName =
"const_cast";
break;
1322 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1323 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1324 case tok::kw_static_cast: CastName =
"static_cast";
break;
1332 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1334 if (Next.
is(tok::colon) && areTokensAdjacent(Tok, Next))
1335 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1338 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1343 ParseSpecifierQualifierList(DS);
1347 ParseDeclarator(DeclaratorInfo);
1351 if (ExpectAndConsume(tok::greater))
1352 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1357 if (T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1365 if (!Result.
isInvalid() && !DeclaratorInfo.isInvalidType())
1367 LAngleBracketLoc, DeclaratorInfo,
1369 T.getOpenLocation(), Result.
get(),
1370 T.getCloseLocation());
1382 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1389 if (T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1391 LParenLoc = T.getOpenLocation();
1412 if (isTypeIdInParens()) {
1417 RParenLoc = T.getCloseLocation();
1422 Ty.
get().getAsOpaquePtr(), RParenLoc);
1431 RParenLoc = T.getCloseLocation();
1436 Result.
get(), RParenLoc);
1449 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1455 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1460 if (isTypeIdInParens()) {
1469 Result = Actions.
ActOnCXXUuidof(OpLoc, T.getOpenLocation(),
true,
1470 Ty.
get().getAsOpaquePtr(),
1471 T.getCloseLocation());
1485 Result.
get(), T.getCloseLocation());
1521 if (Tok.
is(tok::identifier)) {
1524 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1526 }
else if (Tok.
is(tok::annot_template_id)) {
1531 ConsumeAnnotationToken();
1532 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1539 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1542 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid() && SS.
isEmpty()) {
1544 ParseDecltypeSpecifier(DS);
1551 if (!Tok.
is(tok::identifier)) {
1552 Diag(Tok, diag::err_destructor_tilde_identifier);
1564 if (Tok.
is(tok::less) &&
1567 false, ObjectType, SecondTypeName,
1572 SS, FirstTypeName, CCLoc, TildeLoc,
1591 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1617 ExprResult Parser::ParseCoyieldExpression() {
1618 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1634 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1653 Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1657 assert((Tok.
is(tok::l_paren) ||
1659 &&
"Expected '(' or '{'!");
1661 if (Tok.
is(tok::l_brace)) {
1665 Expr *InitList = Init.
get();
1674 CommaLocsTy CommaLocs;
1676 if (Tok.
isNot(tok::r_paren)) {
1677 if (ParseExpressionList(Exprs, CommaLocs, [&] {
1694 assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
1695 "Unexpected number of commas!");
1698 T.getCloseLocation());
1725 if (Tok.
is(tok::code_completion)) {
1731 ParsedAttributesWithRange attrs(AttrFactory);
1732 MaybeParseCXX11Attributes(attrs);
1735 switch (isCXXConditionDeclarationOrInitStatement(InitStmt)) {
1737 ProhibitAttributes(attrs);
1744 if (InitStmt && Tok.
is(tok::semi)) {
1747 return ParseCXXCondition(
nullptr, Loc, CK);
1755 ? diag::warn_cxx14_compat_init_statement
1756 : diag::ext_init_statement)
1762 return ParseCXXCondition(
nullptr, Loc, CK);
1773 ParseSpecifierQualifierList(DS,
AS_none, DSC_condition);
1777 ParseDeclarator(DeclaratorInfo);
1780 if (Tok.
is(tok::kw_asm)) {
1783 if (AsmLabel.isInvalid()) {
1787 DeclaratorInfo.setAsmLabel(AsmLabel.get());
1788 DeclaratorInfo.SetRangeEnd(Loc);
1792 MaybeParseGNUAttributes(DeclaratorInfo);
1803 bool CopyInitialization = isTokenEqualOrEqualTypo();
1804 if (CopyInitialization)
1810 diag::warn_cxx98_compat_generalized_initializer_lists);
1811 InitExpr = ParseBraceInitializer();
1812 }
else if (CopyInitialization) {
1814 }
else if (Tok.
is(tok::l_paren)) {
1818 RParen = ConsumeParen();
1820 diag::err_expected_init_in_condition_lparen)
1861 void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
1863 const char *PrevSpec;
1870 case tok::identifier:
1871 case tok::coloncolon:
1872 llvm_unreachable(
"Annotation token should already be formed!");
1874 llvm_unreachable(
"Not a simple-type-specifier token!");
1877 case tok::annot_typename: {
1885 ConsumeAnnotationToken();
1887 DS.
Finish(Actions, Policy);
1898 case tok::kw___int64:
1901 case tok::kw_signed:
1904 case tok::kw_unsigned:
1916 case tok::kw___int128:
1925 case tok::kw_double:
1928 case tok::kw___float128:
1931 case tok::kw_wchar_t:
1934 case tok::kw_char16_t:
1937 case tok::kw_char32_t:
1943 case tok::annot_decltype:
1944 case tok::kw_decltype:
1946 return DS.
Finish(Actions, Policy);
1949 case tok::kw_typeof:
1950 ParseTypeofSpecifier(DS);
1951 DS.
Finish(Actions, Policy);
1956 DS.
Finish(Actions, Policy);
1970 bool Parser::ParseCXXTypeSpecifierSeq(
DeclSpec &DS) {
1971 ParseSpecifierQualifierList(DS,
AS_none, DSC_type_specifier);
2008 bool Parser::ParseUnqualifiedIdTemplateId(
CXXScopeSpec &SS,
2012 bool EnteringContext,
2015 bool AssumeTemplateId) {
2016 assert((AssumeTemplateId || Tok.
is(tok::less)) &&
2017 "Expected '<' to finish parsing a template-id");
2025 if (AssumeTemplateId) {
2029 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2034 bool MemberOfUnknownSpecialization;
2037 ObjectType, EnteringContext, Template,
2038 MemberOfUnknownSpecialization);
2041 ObjectType && IsTemplateArgumentList()) {
2060 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2070 bool MemberOfUnknownSpecialization;
2073 TemplateName, ObjectType,
2074 EnteringContext, Template,
2075 MemberOfUnknownSpecialization);
2081 bool MemberOfUnknownSpecialization;
2085 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
2086 EnteringContext, Template,
true);
2091 TemplateName, ObjectType,
2092 EnteringContext, Template,
2093 MemberOfUnknownSpecialization);
2096 Diag(NameLoc, diag::err_destructor_template_id)
2113 TemplateArgList TemplateArgs;
2114 if (Tok.
is(tok::less) && ParseTemplateIdAfterTemplateName(
2115 true, LAngleLoc, TemplateArgs, RAngleLoc))
2132 SS, TemplateKWLoc, Id.
StartLocation, TemplateII, OpKind, Template, TNK,
2133 LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
2145 Template, Name, NameLoc,
2146 LAngleLoc, TemplateArgsPtr, RAngleLoc,
2199 bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2202 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2208 unsigned SymbolIdx = 0;
2213 case tok::kw_delete: {
2214 bool isNew = Tok.
getKind() == tok::kw_new;
2218 if (Tok.
is(tok::l_square) &&
2224 if (T.getCloseLocation().isInvalid())
2227 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2228 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2229 Op = isNew? OO_Array_New : OO_Array_Delete;
2231 Op = isNew? OO_New : OO_Delete;
2236 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2238 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2241 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2242 #include "clang/Basic/OperatorKinds.def"
2244 case tok::l_paren: {
2249 if (T.getCloseLocation().isInvalid())
2252 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2253 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2258 case tok::l_square: {
2263 if (T.getCloseLocation().isInvalid())
2266 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2267 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2272 case tok::code_completion: {
2300 unsigned DiagId = 0;
2306 while (isTokenStringLiteral()) {
2307 if (!Tok.
is(tok::string_literal) && !DiagId) {
2312 DiagId = diag::err_literal_operator_string_prefix;
2314 Toks.push_back(Tok);
2315 TokLocs.push_back(ConsumeStringToken());
2319 if (Literal.hadError)
2326 if (!Literal.getUDSuffix().empty()) {
2330 Literal.getUDSuffixOffset(),
2332 }
else if (Tok.
is(tok::identifier)) {
2335 TokLocs.push_back(SuffixLoc);
2342 if (!Literal.GetString().empty() || Literal.Pascal) {
2347 DiagLoc = TokLocs.front();
2348 DiagId = diag::err_literal_operator_string_not_empty;
2358 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2379 if (ParseCXXTypeSpecifierSeq(DS))
2385 ParseDeclaratorInternal(D,
nullptr);
2394 D.getSourceRange().getEnd());
2431 bool AllowDestructorName,
2432 bool AllowConstructorName,
2433 bool AllowDeductionGuide,
2440 bool TemplateSpecified =
false;
2442 (ObjectType || SS.
isSet())) {
2443 TemplateSpecified =
true;
2450 if (Tok.
is(tok::identifier)) {
2463 if (AllowConstructorName &&
2472 AllowDeductionGuide && SS.
isEmpty() &&
2483 if (TemplateSpecified || Tok.
is(tok::less))
2484 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc, Id, IdLoc,
2485 EnteringContext, ObjectType,
2486 Result, TemplateSpecified);
2493 if (Tok.
is(tok::annot_template_id)) {
2497 if (AllowConstructorName && TemplateId->
Name &&
2505 diag::err_out_of_line_constructor_template_id)
2516 ConsumeAnnotationToken();
2521 ConsumeAnnotationToken();
2529 ConsumeAnnotationToken();
2536 if (Tok.
is(tok::kw_operator)) {
2537 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result))
2547 (TemplateSpecified || Tok.
is(tok::less)))
2548 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
2550 EnteringContext, ObjectType,
2551 Result, TemplateSpecified);
2557 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
2566 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
2578 if (Tok.
isNot(tok::identifier)) {
2579 Diag(Tok, diag::err_destructor_tilde_identifier);
2584 DeclaratorScopeObj DeclScopeObj(*
this, SS);
2585 if (!TemplateSpecified &&
NextToken().is(tok::coloncolon)) {
2592 AnnotateScopeToken(SS,
true);
2595 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
2598 ObjectType =
nullptr;
2601 Diag(TildeLoc, diag::err_destructor_tilde_scope);
2606 Diag(TildeLoc, diag::err_destructor_tilde_scope)
2612 DeclScopeObj.EnterDeclaratorScope();
2619 if (TemplateSpecified || Tok.
is(tok::less)) {
2621 return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc,
2622 ClassName, ClassNameLoc,
2623 EnteringContext, ObjectType,
2624 Result, TemplateSpecified);
2639 Diag(Tok, diag::err_expected_unqualified_id)
2673 Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
2674 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
2680 ExprVector PlacementArgs;
2686 if (Tok.
is(tok::l_paren)) {
2690 PlacementLParen = T.getOpenLocation();
2691 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
2697 PlacementRParen = T.getCloseLocation();
2703 if (PlacementArgs.empty()) {
2705 TypeIdParens = T.getRange();
2709 if (Tok.
is(tok::l_paren)) {
2712 MaybeParseGNUAttributes(DeclaratorInfo);
2713 ParseSpecifierQualifierList(DS);
2715 ParseDeclarator(DeclaratorInfo);
2717 TypeIdParens = T.getRange();
2719 MaybeParseGNUAttributes(DeclaratorInfo);
2720 if (ParseCXXTypeSpecifierSeq(DS))
2721 DeclaratorInfo.setInvalidType(
true);
2724 ParseDeclaratorInternal(DeclaratorInfo,
2725 &Parser::ParseDirectNewDeclarator);
2732 MaybeParseGNUAttributes(DeclaratorInfo);
2733 if (ParseCXXTypeSpecifierSeq(DS))
2734 DeclaratorInfo.setInvalidType(
true);
2737 ParseDeclaratorInternal(DeclaratorInfo,
2738 &Parser::ParseDirectNewDeclarator);
2741 if (DeclaratorInfo.isInvalidType()) {
2748 if (Tok.
is(tok::l_paren)) {
2750 ExprVector ConstructorArgs;
2753 ConstructorLParen = T.getOpenLocation();
2754 if (Tok.
isNot(tok::r_paren)) {
2755 CommaLocsTy CommaLocs;
2756 if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
2758 DeclaratorInfo).
get();
2761 DeclaratorInfo.getLocEnd(),
2769 ConstructorRParen = T.getCloseLocation();
2777 }
else if (Tok.
is(tok::l_brace) &&
getLangOpts().CPlusPlus11) {
2779 diag::warn_cxx98_compat_generalized_initializer_lists);
2780 Initializer = ParseBraceInitializer();
2785 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
2786 PlacementArgs, PlacementRParen,
2787 TypeIdParens, DeclaratorInfo, Initializer.
get());
2797 void Parser::ParseDirectNewDeclarator(
Declarator &D) {
2800 while (Tok.
is(tok::l_square)) {
2802 if (CheckProhibitedCXX11Attribute())
2810 if (Size.isInvalid()) {
2821 MaybeParseCXX11Attributes(Attrs);
2826 T.getOpenLocation(),
2827 T.getCloseLocation()),
2828 Attrs, T.getCloseLocation());
2830 if (T.getCloseLocation().isInvalid())
2845 bool Parser::ParseExpressionListOrTypeId(
2849 if (isTypeIdInParens()) {
2858 CommaLocsTy CommaLocs;
2859 return ParseExpressionList(PlacementArgs, CommaLocs);
2874 Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
2875 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
2879 bool ArrayDelete =
false;
2880 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::r_square)) {
2894 if (T.getCloseLocation().isInvalid())
2898 ExprResult Operand(ParseCastExpression(
false));
2899 if (Operand.isInvalid())
2902 return Actions.
ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.get());
2907 default: llvm_unreachable(
"Not a known type trait");
2908 #define TYPE_TRAIT_1(Spelling, Name, Key) \
2909 case tok::kw_ ## Spelling: return UTT_ ## Name;
2910 #define TYPE_TRAIT_2(Spelling, Name, Key) \
2911 case tok::kw_ ## Spelling: return BTT_ ## Name;
2912 #include "clang/Basic/TokenKinds.def"
2913 #define TYPE_TRAIT_N(Spelling, Name, Key) \
2914 case tok::kw_ ## Spelling: return TT_ ## Name;
2915 #include "clang/Basic/TokenKinds.def"
2921 default: llvm_unreachable(
"Not a known binary type trait");
2929 default: llvm_unreachable(
"Not a known unary expression trait.");
2937 default: llvm_unreachable(
"Not a known type trait");
2938 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N;
2939 #include "clang/Basic/TokenKinds.def"
2961 if (Parens.expectAndConsume())
2974 if (Tok.
is(tok::ellipsis)) {
2983 Args.push_back(Ty.
get());
2986 if (Parens.consumeClose())
2991 if (Arity && Args.size() != Arity) {
2992 Diag(EndLoc, diag::err_type_trait_arity)
2993 << Arity << 0 << (Arity > 1) << (
int)Args.size() <<
SourceRange(Loc);
2997 if (!Arity && Args.empty()) {
2998 Diag(EndLoc, diag::err_type_trait_arity)
2999 << 1 << 1 << 1 << (int)Args.size() <<
SourceRange(Loc);
3018 if (T.expectAndConsume())
3032 T.getCloseLocation());
3035 if (ExpectAndConsume(tok::comma)) {
3044 T.getCloseLocation());
3047 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3061 if (T.expectAndConsume())
3069 T.getCloseLocation());
3077 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
3082 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
3083 assert(isTypeIdInParens() &&
"Not a type-id!");
3107 ParenParseOption ParseAs;
3112 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3118 if (Tok.
is(tok::l_brace)) {
3119 ParseAs = CompoundLiteral;
3129 Result = ParseCastExpression(
false,
3138 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
3147 Toks.push_back(AttrEnd);
3150 Toks.push_back(Tok);
3153 PP.EnterTokenStream(Toks,
true );
3158 if (ParseAs >= CompoundLiteral) {
3164 ParseSpecifierQualifierList(DS);
3165 ParseDeclarator(DeclaratorInfo);
3176 if (ParseAs == CompoundLiteral) {
3177 ExprType = CompoundLiteral;
3178 if (DeclaratorInfo.isInvalidType())
3182 return ParseCompoundLiteralExpression(Ty.
get(),
3190 if (DeclaratorInfo.isInvalidType())
3196 DeclaratorInfo, CastTy,
3202 assert(ParseAs == SimpleExpr);
3204 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.
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.
IdKind getKind() const
Determine what kind of name we have.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Disambiguated as an expression (either kind).
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.
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::'.
const Token & getCurToken() const
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.
static ConditionResult ConditionError()
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. ...
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
StmtResult ActOnExprStmt(ExprResult Arg)
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...
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Defines the C++ template declaration subclasses.
const char * getName() const
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)
Parser - This implements a parser for the C family of languages.
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.
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. ...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
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.
Disambiguated as a simple-declaration init-statement.
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)
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. ...
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.
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.
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.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
void SetSourceRange(SourceRange R)
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
< Capturing the *this object by copy
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
bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo)
SourceRange getRange() const
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.
void * getAnnotationValue() const
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
static const TSW TSW_long
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
const void * getEofData() const
void SetRangeStart(SourceLocation Loc)
Disambiguated as the declaration form of condition.
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 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)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
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)
OpaquePtr< TemplateName > TemplateTy
Represents a C++ template name within the type system.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
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.
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Can't be any of the above!
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...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
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
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...
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)
static void addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc, DeclSpec &DS)
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.
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...
ASTContext & getASTContext() 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, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
Scope * getCurScope() const
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.
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)
SourceLocation getOpenLocation() const
static const TST TST_decltype_auto
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
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.
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...
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)
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.
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
ActionResult< Stmt * > StmtResult
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 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)
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
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)
A user-defined literal name, e.g., operator "" _i.
static int SelectDigraphErrorMessage(tok::TokenKind Kind)
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...
static const TST TST_float128
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
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.
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.
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