Mercurial > hg > CbC > CbC_llvm
comparison clang/lib/Parse/ParseExpr.cpp @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | dd44ba33042e c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
157 } | 157 } |
158 | 158 |
159 /// Parse an expr that doesn't include (top-level) commas. | 159 /// Parse an expr that doesn't include (top-level) commas. |
160 ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) { | 160 ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) { |
161 if (Tok.is(tok::code_completion)) { | 161 if (Tok.is(tok::code_completion)) { |
162 cutOffParsing(); | |
162 Actions.CodeCompleteExpression(getCurScope(), | 163 Actions.CodeCompleteExpression(getCurScope(), |
163 PreferredType.get(Tok.getLocation())); | 164 PreferredType.get(Tok.getLocation())); |
164 cutOffParsing(); | |
165 return ExprError(); | 165 return ExprError(); |
166 } | 166 } |
167 | 167 |
168 if (Tok.is(tok::kw_throw)) | 168 if (Tok.is(tok::kw_throw)) |
169 return ParseThrowExpression(); | 169 return ParseThrowExpression(); |
918 ExprResult Res; | 918 ExprResult Res; |
919 tok::TokenKind SavedKind = Tok.getKind(); | 919 tok::TokenKind SavedKind = Tok.getKind(); |
920 auto SavedType = PreferredType; | 920 auto SavedType = PreferredType; |
921 NotCastExpr = false; | 921 NotCastExpr = false; |
922 | 922 |
923 // Are postfix-expression suffix operators permitted after this | |
924 // cast-expression? If not, and we find some, we'll parse them anyway and | |
925 // diagnose them. | |
926 bool AllowSuffix = true; | |
927 | |
923 // This handles all of cast-expression, unary-expression, postfix-expression, | 928 // This handles all of cast-expression, unary-expression, postfix-expression, |
924 // and primary-expression. We handle them together like this for efficiency | 929 // and primary-expression. We handle them together like this for efficiency |
925 // and to simplify handling of an expression starting with a '(' token: which | 930 // and to simplify handling of an expression starting with a '(' token: which |
926 // may be one of a parenthesized expression, cast-expression, compound literal | 931 // may be one of a parenthesized expression, cast-expression, compound literal |
927 // expression, or statement expression. | 932 // expression, or statement expression. |
928 // | 933 // |
929 // If the parsed tokens consist of a primary-expression, the cases below | 934 // If the parsed tokens consist of a primary-expression, the cases below |
930 // break out of the switch; at the end we call ParsePostfixExpressionSuffix | 935 // break out of the switch; at the end we call ParsePostfixExpressionSuffix |
931 // to handle the postfix expression suffixes. Cases that cannot be followed | 936 // to handle the postfix expression suffixes. Cases that cannot be followed |
932 // by postfix exprs should return without invoking | 937 // by postfix exprs should set AllowSuffix to false. |
933 // ParsePostfixExpressionSuffix. | |
934 switch (SavedKind) { | 938 switch (SavedKind) { |
935 case tok::l_paren: { | 939 case tok::l_paren: { |
936 // If this expression is limited to being a unary-expression, the paren can | 940 // If this expression is limited to being a unary-expression, the paren can |
937 // not start a cast expression. | 941 // not start a cast expression. |
938 ParenParseOption ParenExprType; | 942 ParenParseOption ParenExprType; |
951 ParsedType CastTy; | 955 ParsedType CastTy; |
952 SourceLocation RParenLoc; | 956 SourceLocation RParenLoc; |
953 Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, | 957 Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, |
954 isTypeCast == IsTypeCast, CastTy, RParenLoc); | 958 isTypeCast == IsTypeCast, CastTy, RParenLoc); |
955 | 959 |
960 // FIXME: What should we do if a vector literal is followed by a | |
961 // postfix-expression suffix? Usually postfix operators are permitted on | |
962 // literals. | |
956 if (isVectorLiteral) | 963 if (isVectorLiteral) |
957 return Res; | 964 return Res; |
958 | 965 |
959 switch (ParenExprType) { | 966 switch (ParenExprType) { |
960 case SimpleExpr: break; // Nothing else to do. | 967 case SimpleExpr: break; // Nothing else to do. |
961 case CompoundStmt: break; // Nothing else to do. | 968 case CompoundStmt: break; // Nothing else to do. |
962 case CompoundLiteral: | 969 case CompoundLiteral: |
990 Res = ParseCXXBoolLiteral(); | 997 Res = ParseCXXBoolLiteral(); |
991 break; | 998 break; |
992 | 999 |
993 case tok::kw___objc_yes: | 1000 case tok::kw___objc_yes: |
994 case tok::kw___objc_no: | 1001 case tok::kw___objc_no: |
995 return ParseObjCBoolLiteral(); | 1002 Res = ParseObjCBoolLiteral(); |
1003 break; | |
996 | 1004 |
997 case tok::kw_nullptr: | 1005 case tok::kw_nullptr: |
998 Diag(Tok, diag::warn_cxx98_compat_nullptr); | 1006 Diag(Tok, diag::warn_cxx98_compat_nullptr); |
999 return Actions.ActOnCXXNullPtrLiteral(ConsumeToken()); | 1007 Res = Actions.ActOnCXXNullPtrLiteral(ConsumeToken()); |
1008 break; | |
1000 | 1009 |
1001 case tok::annot_primary_expr: | 1010 case tok::annot_primary_expr: |
1011 case tok::annot_overload_set: | |
1002 Res = getExprAnnotation(Tok); | 1012 Res = getExprAnnotation(Tok); |
1013 if (!Res.isInvalid() && Tok.getKind() == tok::annot_overload_set) | |
1014 Res = Actions.ActOnNameClassifiedAsOverloadSet(getCurScope(), Res.get()); | |
1003 ConsumeAnnotationToken(); | 1015 ConsumeAnnotationToken(); |
1004 if (!Res.isInvalid() && Tok.is(tok::less)) | 1016 if (!Res.isInvalid() && Tok.is(tok::less)) |
1005 checkPotentialAngleBracket(Res); | 1017 checkPotentialAngleBracket(Res); |
1006 break; | 1018 break; |
1007 | 1019 |
1142 // Allow the base to be 'super' if in an objc-method. | 1154 // Allow the base to be 'super' if in an objc-method. |
1143 (&II == Ident_super && getCurScope()->isInObjcMethodScope()))) { | 1155 (&II == Ident_super && getCurScope()->isInObjcMethodScope()))) { |
1144 ConsumeToken(); | 1156 ConsumeToken(); |
1145 | 1157 |
1146 if (Tok.is(tok::code_completion) && &II != Ident_super) { | 1158 if (Tok.is(tok::code_completion) && &II != Ident_super) { |
1159 cutOffParsing(); | |
1147 Actions.CodeCompleteObjCClassPropertyRefExpr( | 1160 Actions.CodeCompleteObjCClassPropertyRefExpr( |
1148 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc); | 1161 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc); |
1149 cutOffParsing(); | |
1150 return ExprError(); | 1162 return ExprError(); |
1151 } | 1163 } |
1152 // Allow either an identifier or the keyword 'class' (in C++). | 1164 // Allow either an identifier or the keyword 'class' (in C++). |
1153 if (Tok.isNot(tok::identifier) && | 1165 if (Tok.isNot(tok::identifier) && |
1154 !(getLangOpts().CPlusPlus && Tok.is(tok::kw_class))) { | 1166 !(getLangOpts().CPlusPlus && Tok.is(tok::kw_class))) { |
1197 const char *PrevSpec = nullptr; | 1209 const char *PrevSpec = nullptr; |
1198 unsigned DiagID; | 1210 unsigned DiagID; |
1199 DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, | 1211 DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, |
1200 Actions.getASTContext().getPrintingPolicy()); | 1212 Actions.getASTContext().getPrintingPolicy()); |
1201 | 1213 |
1202 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); | 1214 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); |
1203 TypeResult Ty = Actions.ActOnTypeName(getCurScope(), | 1215 TypeResult Ty = Actions.ActOnTypeName(getCurScope(), |
1204 DeclaratorInfo); | 1216 DeclaratorInfo); |
1205 if (Ty.isInvalid()) | 1217 if (Ty.isInvalid()) |
1206 break; | 1218 break; |
1207 | 1219 |
1278 break; | 1290 break; |
1279 case tok::kw__Generic: // primary-expression: generic-selection [C11 6.5.1] | 1291 case tok::kw__Generic: // primary-expression: generic-selection [C11 6.5.1] |
1280 Res = ParseGenericSelectionExpression(); | 1292 Res = ParseGenericSelectionExpression(); |
1281 break; | 1293 break; |
1282 case tok::kw___builtin_available: | 1294 case tok::kw___builtin_available: |
1283 return ParseAvailabilityCheckExpr(Tok.getLocation()); | 1295 Res = ParseAvailabilityCheckExpr(Tok.getLocation()); |
1296 break; | |
1284 case tok::kw___builtin_va_arg: | 1297 case tok::kw___builtin_va_arg: |
1285 case tok::kw___builtin_offsetof: | 1298 case tok::kw___builtin_offsetof: |
1286 case tok::kw___builtin_choose_expr: | 1299 case tok::kw___builtin_choose_expr: |
1287 case tok::kw___builtin_astype: // primary-expression: [OCL] as_type() | 1300 case tok::kw___builtin_astype: // primary-expression: [OCL] as_type() |
1288 case tok::kw___builtin_convertvector: | 1301 case tok::kw___builtin_convertvector: |
1290 case tok::kw___builtin_FILE: | 1303 case tok::kw___builtin_FILE: |
1291 case tok::kw___builtin_FUNCTION: | 1304 case tok::kw___builtin_FUNCTION: |
1292 case tok::kw___builtin_LINE: | 1305 case tok::kw___builtin_LINE: |
1293 if (NotPrimaryExpression) | 1306 if (NotPrimaryExpression) |
1294 *NotPrimaryExpression = true; | 1307 *NotPrimaryExpression = true; |
1308 // This parses the complete suffix; we can return early. | |
1295 return ParseBuiltinPrimaryExpression(); | 1309 return ParseBuiltinPrimaryExpression(); |
1296 case tok::kw___null: | 1310 case tok::kw___null: |
1297 return Actions.ActOnGNUNullExpr(ConsumeToken()); | 1311 Res = Actions.ActOnGNUNullExpr(ConsumeToken()); |
1312 break; | |
1298 | 1313 |
1299 case tok::plusplus: // unary-expression: '++' unary-expression [C99] | 1314 case tok::plusplus: // unary-expression: '++' unary-expression [C99] |
1300 case tok::minusminus: { // unary-expression: '--' unary-expression [C99] | 1315 case tok::minusminus: { // unary-expression: '--' unary-expression [C99] |
1301 if (NotPrimaryExpression) | 1316 if (NotPrimaryExpression) |
1302 *NotPrimaryExpression = true; | 1317 *NotPrimaryExpression = true; |
1404 case tok::kw_vec_step: // unary-expression: OpenCL 'vec_step' expression | 1419 case tok::kw_vec_step: // unary-expression: OpenCL 'vec_step' expression |
1405 // unary-expression: '__builtin_omp_required_simd_align' '(' type-name ')' | 1420 // unary-expression: '__builtin_omp_required_simd_align' '(' type-name ')' |
1406 case tok::kw___builtin_omp_required_simd_align: | 1421 case tok::kw___builtin_omp_required_simd_align: |
1407 if (NotPrimaryExpression) | 1422 if (NotPrimaryExpression) |
1408 *NotPrimaryExpression = true; | 1423 *NotPrimaryExpression = true; |
1409 return ParseUnaryExprOrTypeTraitExpression(); | 1424 AllowSuffix = false; |
1425 Res = ParseUnaryExprOrTypeTraitExpression(); | |
1426 break; | |
1410 case tok::ampamp: { // unary-expression: '&&' identifier | 1427 case tok::ampamp: { // unary-expression: '&&' identifier |
1411 if (NotPrimaryExpression) | 1428 if (NotPrimaryExpression) |
1412 *NotPrimaryExpression = true; | 1429 *NotPrimaryExpression = true; |
1413 SourceLocation AmpAmpLoc = ConsumeToken(); | 1430 SourceLocation AmpAmpLoc = ConsumeToken(); |
1414 if (Tok.isNot(tok::identifier)) | 1431 if (Tok.isNot(tok::identifier)) |
1420 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label); | 1437 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label); |
1421 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(), | 1438 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(), |
1422 Tok.getLocation()); | 1439 Tok.getLocation()); |
1423 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD); | 1440 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD); |
1424 ConsumeToken(); | 1441 ConsumeToken(); |
1425 return Res; | 1442 AllowSuffix = false; |
1443 break; | |
1426 } | 1444 } |
1427 case tok::kw_const_cast: | 1445 case tok::kw_const_cast: |
1428 case tok::kw_dynamic_cast: | 1446 case tok::kw_dynamic_cast: |
1429 case tok::kw_reinterpret_cast: | 1447 case tok::kw_reinterpret_cast: |
1430 case tok::kw_static_cast: | 1448 case tok::kw_static_cast: |
1449 Res = ParseCXXUuidof(); | 1467 Res = ParseCXXUuidof(); |
1450 break; | 1468 break; |
1451 case tok::kw_this: | 1469 case tok::kw_this: |
1452 Res = ParseCXXThis(); | 1470 Res = ParseCXXThis(); |
1453 break; | 1471 break; |
1454 case tok::kw___builtin_unique_stable_name: | 1472 case tok::kw___builtin_sycl_unique_stable_name: |
1455 Res = ParseUniqueStableNameExpression(); | 1473 Res = ParseSYCLUniqueStableNameExpression(); |
1456 break; | 1474 break; |
1475 | |
1457 case tok::annot_typename: | 1476 case tok::annot_typename: |
1458 if (isStartOfObjCClassMessageMissingOpenBracket()) { | 1477 if (isStartOfObjCClassMessageMissingOpenBracket()) { |
1459 TypeResult Type = getTypeAnnotation(Tok); | 1478 TypeResult Type = getTypeAnnotation(Tok); |
1460 | 1479 |
1461 // Fake up a Declarator to use with ActOnTypeName. | 1480 // Fake up a Declarator to use with ActOnTypeName. |
1467 unsigned DiagID; | 1486 unsigned DiagID; |
1468 DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(), | 1487 DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(), |
1469 PrevSpec, DiagID, Type, | 1488 PrevSpec, DiagID, Type, |
1470 Actions.getASTContext().getPrintingPolicy()); | 1489 Actions.getASTContext().getPrintingPolicy()); |
1471 | 1490 |
1472 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); | 1491 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); |
1473 TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); | 1492 TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); |
1474 if (Ty.isInvalid()) | 1493 if (Ty.isInvalid()) |
1475 break; | 1494 break; |
1476 | 1495 |
1477 ConsumeAnnotationToken(); | 1496 ConsumeAnnotationToken(); |
1497 case tok::kw_signed: | 1516 case tok::kw_signed: |
1498 case tok::kw_unsigned: | 1517 case tok::kw_unsigned: |
1499 case tok::kw_half: | 1518 case tok::kw_half: |
1500 case tok::kw_float: | 1519 case tok::kw_float: |
1501 case tok::kw_double: | 1520 case tok::kw_double: |
1521 case tok::kw___bf16: | |
1502 case tok::kw__Float16: | 1522 case tok::kw__Float16: |
1503 case tok::kw___float128: | 1523 case tok::kw___float128: |
1504 case tok::kw_void: | 1524 case tok::kw_void: |
1505 case tok::kw_typename: | 1525 case tok::kw_typename: |
1506 case tok::kw_typeof: | 1526 case tok::kw_typeof: |
1614 // ::delete -> [C++] delete-expression | 1634 // ::delete -> [C++] delete-expression |
1615 SourceLocation CCLoc = ConsumeToken(); | 1635 SourceLocation CCLoc = ConsumeToken(); |
1616 if (Tok.is(tok::kw_new)) { | 1636 if (Tok.is(tok::kw_new)) { |
1617 if (NotPrimaryExpression) | 1637 if (NotPrimaryExpression) |
1618 *NotPrimaryExpression = true; | 1638 *NotPrimaryExpression = true; |
1619 return ParseCXXNewExpression(true, CCLoc); | 1639 Res = ParseCXXNewExpression(true, CCLoc); |
1640 AllowSuffix = false; | |
1641 break; | |
1620 } | 1642 } |
1621 if (Tok.is(tok::kw_delete)) { | 1643 if (Tok.is(tok::kw_delete)) { |
1622 if (NotPrimaryExpression) | 1644 if (NotPrimaryExpression) |
1623 *NotPrimaryExpression = true; | 1645 *NotPrimaryExpression = true; |
1624 return ParseCXXDeleteExpression(true, CCLoc); | 1646 Res = ParseCXXDeleteExpression(true, CCLoc); |
1647 AllowSuffix = false; | |
1648 break; | |
1625 } | 1649 } |
1626 | 1650 |
1627 // This is not a type name or scope specifier, it is an invalid expression. | 1651 // This is not a type name or scope specifier, it is an invalid expression. |
1628 Diag(CCLoc, diag::err_expected_expression); | 1652 Diag(CCLoc, diag::err_expected_expression); |
1629 return ExprError(); | 1653 return ExprError(); |
1630 } | 1654 } |
1631 | 1655 |
1632 case tok::kw_new: // [C++] new-expression | 1656 case tok::kw_new: // [C++] new-expression |
1633 if (NotPrimaryExpression) | 1657 if (NotPrimaryExpression) |
1634 *NotPrimaryExpression = true; | 1658 *NotPrimaryExpression = true; |
1635 return ParseCXXNewExpression(false, Tok.getLocation()); | 1659 Res = ParseCXXNewExpression(false, Tok.getLocation()); |
1660 AllowSuffix = false; | |
1661 break; | |
1636 | 1662 |
1637 case tok::kw_delete: // [C++] delete-expression | 1663 case tok::kw_delete: // [C++] delete-expression |
1638 if (NotPrimaryExpression) | 1664 if (NotPrimaryExpression) |
1639 *NotPrimaryExpression = true; | 1665 *NotPrimaryExpression = true; |
1640 return ParseCXXDeleteExpression(false, Tok.getLocation()); | 1666 Res = ParseCXXDeleteExpression(false, Tok.getLocation()); |
1667 AllowSuffix = false; | |
1668 break; | |
1641 | 1669 |
1642 case tok::kw_requires: // [C++2a] requires-expression | 1670 case tok::kw_requires: // [C++2a] requires-expression |
1643 return ParseRequiresExpression(); | 1671 Res = ParseRequiresExpression(); |
1672 AllowSuffix = false; | |
1673 break; | |
1644 | 1674 |
1645 case tok::kw_noexcept: { // [C++0x] 'noexcept' '(' expression ')' | 1675 case tok::kw_noexcept: { // [C++0x] 'noexcept' '(' expression ')' |
1646 if (NotPrimaryExpression) | 1676 if (NotPrimaryExpression) |
1647 *NotPrimaryExpression = true; | 1677 *NotPrimaryExpression = true; |
1648 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr); | 1678 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr); |
1654 // C++11 [expr.unary.noexcept]p1: | 1684 // C++11 [expr.unary.noexcept]p1: |
1655 // The noexcept operator determines whether the evaluation of its operand, | 1685 // The noexcept operator determines whether the evaluation of its operand, |
1656 // which is an unevaluated operand, can throw an exception. | 1686 // which is an unevaluated operand, can throw an exception. |
1657 EnterExpressionEvaluationContext Unevaluated( | 1687 EnterExpressionEvaluationContext Unevaluated( |
1658 Actions, Sema::ExpressionEvaluationContext::Unevaluated); | 1688 Actions, Sema::ExpressionEvaluationContext::Unevaluated); |
1659 ExprResult Result = ParseExpression(); | 1689 Res = ParseExpression(); |
1660 | 1690 |
1661 T.consumeClose(); | 1691 T.consumeClose(); |
1662 | 1692 |
1663 if (!Result.isInvalid()) | 1693 if (!Res.isInvalid()) |
1664 Result = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), | 1694 Res = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Res.get(), |
1665 Result.get(), T.getCloseLocation()); | 1695 T.getCloseLocation()); |
1666 return Result; | 1696 AllowSuffix = false; |
1697 break; | |
1667 } | 1698 } |
1668 | 1699 |
1669 #define TYPE_TRAIT(N,Spelling,K) \ | 1700 #define TYPE_TRAIT(N,Spelling,K) \ |
1670 case tok::kw_##Spelling: | 1701 case tok::kw_##Spelling: |
1671 #include "clang/Basic/TokenKinds.def" | 1702 #include "clang/Basic/TokenKinds.def" |
1672 return ParseTypeTrait(); | 1703 Res = ParseTypeTrait(); |
1704 break; | |
1673 | 1705 |
1674 case tok::kw___array_rank: | 1706 case tok::kw___array_rank: |
1675 case tok::kw___array_extent: | 1707 case tok::kw___array_extent: |
1676 if (NotPrimaryExpression) | 1708 if (NotPrimaryExpression) |
1677 *NotPrimaryExpression = true; | 1709 *NotPrimaryExpression = true; |
1678 return ParseArrayTypeTrait(); | 1710 Res = ParseArrayTypeTrait(); |
1711 break; | |
1679 | 1712 |
1680 case tok::kw___is_lvalue_expr: | 1713 case tok::kw___is_lvalue_expr: |
1681 case tok::kw___is_rvalue_expr: | 1714 case tok::kw___is_rvalue_expr: |
1682 if (NotPrimaryExpression) | 1715 if (NotPrimaryExpression) |
1683 *NotPrimaryExpression = true; | 1716 *NotPrimaryExpression = true; |
1684 return ParseExpressionTrait(); | 1717 Res = ParseExpressionTrait(); |
1718 break; | |
1685 | 1719 |
1686 case tok::at: { | 1720 case tok::at: { |
1687 if (NotPrimaryExpression) | 1721 if (NotPrimaryExpression) |
1688 *NotPrimaryExpression = true; | 1722 *NotPrimaryExpression = true; |
1689 SourceLocation AtLoc = ConsumeToken(); | 1723 SourceLocation AtLoc = ConsumeToken(); |
1691 } | 1725 } |
1692 case tok::caret: | 1726 case tok::caret: |
1693 Res = ParseBlockLiteralExpression(); | 1727 Res = ParseBlockLiteralExpression(); |
1694 break; | 1728 break; |
1695 case tok::code_completion: { | 1729 case tok::code_completion: { |
1730 cutOffParsing(); | |
1696 Actions.CodeCompleteExpression(getCurScope(), | 1731 Actions.CodeCompleteExpression(getCurScope(), |
1697 PreferredType.get(Tok.getLocation())); | 1732 PreferredType.get(Tok.getLocation())); |
1698 cutOffParsing(); | |
1699 return ExprError(); | 1733 return ExprError(); |
1700 } | 1734 } |
1701 case tok::l_square: | 1735 case tok::l_square: |
1702 if (getLangOpts().CPlusPlus11) { | 1736 if (getLangOpts().CPlusPlus11) { |
1703 if (getLangOpts().ObjC) { | 1737 if (getLangOpts().ObjC) { |
1736 if (ParseKind == PrimaryExprOnly) | 1770 if (ParseKind == PrimaryExprOnly) |
1737 // This is strictly a primary-expression - no postfix-expr pieces should be | 1771 // This is strictly a primary-expression - no postfix-expr pieces should be |
1738 // parsed. | 1772 // parsed. |
1739 return Res; | 1773 return Res; |
1740 | 1774 |
1775 if (!AllowSuffix) { | |
1776 // FIXME: Don't parse a primary-expression suffix if we encountered a parse | |
1777 // error already. | |
1778 if (Res.isInvalid()) | |
1779 return Res; | |
1780 | |
1781 switch (Tok.getKind()) { | |
1782 case tok::l_square: | |
1783 case tok::l_paren: | |
1784 case tok::plusplus: | |
1785 case tok::minusminus: | |
1786 // "expected ';'" or similar is probably the right diagnostic here. Let | |
1787 // the caller decide what to do. | |
1788 if (Tok.isAtStartOfLine()) | |
1789 return Res; | |
1790 | |
1791 LLVM_FALLTHROUGH; | |
1792 case tok::period: | |
1793 case tok::arrow: | |
1794 break; | |
1795 | |
1796 default: | |
1797 return Res; | |
1798 } | |
1799 | |
1800 // This was a unary-expression for which a postfix-expression suffix is | |
1801 // not permitted by the grammar (eg, a sizeof expression or | |
1802 // new-expression or similar). Diagnose but parse the suffix anyway. | |
1803 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens) | |
1804 << Tok.getKind() << Res.get()->getSourceRange() | |
1805 << FixItHint::CreateInsertion(Res.get()->getBeginLoc(), "(") | |
1806 << FixItHint::CreateInsertion(PP.getLocForEndOfToken(PrevTokLocation), | |
1807 ")"); | |
1808 } | |
1809 | |
1741 // These can be followed by postfix-expr pieces. | 1810 // These can be followed by postfix-expr pieces. |
1742 PreferredType = SavedType; | 1811 PreferredType = SavedType; |
1743 Res = ParsePostfixExpressionSuffix(Res); | 1812 Res = ParsePostfixExpressionSuffix(Res); |
1744 if (getLangOpts().OpenCL) | 1813 if (getLangOpts().OpenCL && |
1814 !getActions().getOpenCLOptions().isAvailableOption( | |
1815 "__cl_clang_function_pointers", getLangOpts())) | |
1745 if (Expr *PostfixExpr = Res.get()) { | 1816 if (Expr *PostfixExpr = Res.get()) { |
1746 QualType Ty = PostfixExpr->getType(); | 1817 QualType Ty = PostfixExpr->getType(); |
1747 if (!Ty.isNull() && Ty->isFunctionType()) { | 1818 if (!Ty.isNull() && Ty->isFunctionType()) { |
1748 Diag(PostfixExpr->getExprLoc(), | 1819 Diag(PostfixExpr->getExprLoc(), |
1749 diag::err_opencl_taking_function_address_parser); | 1820 diag::err_opencl_taking_function_address_parser); |
1786 switch (Tok.getKind()) { | 1857 switch (Tok.getKind()) { |
1787 case tok::code_completion: | 1858 case tok::code_completion: |
1788 if (InMessageExpression) | 1859 if (InMessageExpression) |
1789 return LHS; | 1860 return LHS; |
1790 | 1861 |
1862 cutOffParsing(); | |
1791 Actions.CodeCompletePostfixExpression( | 1863 Actions.CodeCompletePostfixExpression( |
1792 getCurScope(), LHS, PreferredType.get(Tok.getLocation())); | 1864 getCurScope(), LHS, PreferredType.get(Tok.getLocation())); |
1793 cutOffParsing(); | |
1794 return ExprError(); | 1865 return ExprError(); |
1795 | 1866 |
1796 case tok::identifier: | 1867 case tok::identifier: |
1797 // If we see identifier: after an expression, and we're not already in a | 1868 // If we see identifier: after an expression, and we're not already in a |
1798 // message send, then this is probably a message send with a missing | 1869 // message send, then this is probably a message send with a missing |
1827 } | 1898 } |
1828 | 1899 |
1829 BalancedDelimiterTracker T(*this, tok::l_square); | 1900 BalancedDelimiterTracker T(*this, tok::l_square); |
1830 T.consumeOpen(); | 1901 T.consumeOpen(); |
1831 Loc = T.getOpenLocation(); | 1902 Loc = T.getOpenLocation(); |
1832 ExprResult Idx, Length; | 1903 ExprResult Idx, Length, Stride; |
1833 SourceLocation ColonLoc; | 1904 SourceLocation ColonLocFirst, ColonLocSecond; |
1834 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.get()); | 1905 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.get()); |
1835 if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) { | 1906 if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) { |
1836 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); | 1907 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); |
1837 Idx = ParseBraceInitializer(); | 1908 Idx = ParseBraceInitializer(); |
1838 } else if (getLangOpts().OpenMP) { | 1909 } else if (getLangOpts().OpenMP) { |
1842 // [ expr | 1913 // [ expr |
1843 Idx = ParseExpression(); | 1914 Idx = ParseExpression(); |
1844 } | 1915 } |
1845 if (Tok.is(tok::colon)) { | 1916 if (Tok.is(tok::colon)) { |
1846 // Consume ':' | 1917 // Consume ':' |
1847 ColonLoc = ConsumeToken(); | 1918 ColonLocFirst = ConsumeToken(); |
1848 if (Tok.isNot(tok::r_square)) | 1919 if (Tok.isNot(tok::r_square) && |
1920 (getLangOpts().OpenMP < 50 || | |
1921 ((Tok.isNot(tok::colon) && getLangOpts().OpenMP >= 50)))) | |
1849 Length = ParseExpression(); | 1922 Length = ParseExpression(); |
1923 } | |
1924 if (getLangOpts().OpenMP >= 50 && | |
1925 (OMPClauseKind == llvm::omp::Clause::OMPC_to || | |
1926 OMPClauseKind == llvm::omp::Clause::OMPC_from) && | |
1927 Tok.is(tok::colon)) { | |
1928 // Consume ':' | |
1929 ColonLocSecond = ConsumeToken(); | |
1930 if (Tok.isNot(tok::r_square)) { | |
1931 Stride = ParseExpression(); | |
1932 } | |
1850 } | 1933 } |
1851 } else | 1934 } else |
1852 Idx = ParseExpression(); | 1935 Idx = ParseExpression(); |
1853 | 1936 |
1854 SourceLocation RLoc = Tok.getLocation(); | 1937 SourceLocation RLoc = Tok.getLocation(); |
1855 | 1938 |
1856 LHS = Actions.CorrectDelayedTyposInExpr(LHS); | 1939 LHS = Actions.CorrectDelayedTyposInExpr(LHS); |
1857 Idx = Actions.CorrectDelayedTyposInExpr(Idx); | 1940 Idx = Actions.CorrectDelayedTyposInExpr(Idx); |
1858 Length = Actions.CorrectDelayedTyposInExpr(Length); | 1941 Length = Actions.CorrectDelayedTyposInExpr(Length); |
1859 if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() && | 1942 if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() && |
1860 Tok.is(tok::r_square)) { | 1943 !Stride.isInvalid() && Tok.is(tok::r_square)) { |
1861 if (ColonLoc.isValid()) { | 1944 if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) { |
1862 LHS = Actions.ActOnOMPArraySectionExpr(LHS.get(), Loc, Idx.get(), | 1945 LHS = Actions.ActOnOMPArraySectionExpr( |
1863 ColonLoc, Length.get(), RLoc); | 1946 LHS.get(), Loc, Idx.get(), ColonLocFirst, ColonLocSecond, |
1947 Length.get(), Stride.get(), RLoc); | |
1864 } else { | 1948 } else { |
1865 LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc, | 1949 LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc, |
1866 Idx.get(), RLoc); | 1950 Idx.get(), RLoc); |
1867 } | 1951 } |
1868 } else { | 1952 } else { |
2057 Expr *CorrectedBase = CorrectedLHS.get(); | 2141 Expr *CorrectedBase = CorrectedLHS.get(); |
2058 if (!CorrectedBase && !getLangOpts().CPlusPlus) | 2142 if (!CorrectedBase && !getLangOpts().CPlusPlus) |
2059 CorrectedBase = Base; | 2143 CorrectedBase = Base; |
2060 | 2144 |
2061 // Code completion for a member access expression. | 2145 // Code completion for a member access expression. |
2146 cutOffParsing(); | |
2062 Actions.CodeCompleteMemberReferenceExpr( | 2147 Actions.CodeCompleteMemberReferenceExpr( |
2063 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow, | 2148 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow, |
2064 Base && ExprStatementTokLoc == Base->getBeginLoc(), | 2149 Base && ExprStatementTokLoc == Base->getBeginLoc(), |
2065 PreferredType.get(Tok.getLocation())); | 2150 PreferredType.get(Tok.getLocation())); |
2066 | 2151 |
2067 cutOffParsing(); | |
2068 return ExprError(); | 2152 return ExprError(); |
2069 } | 2153 } |
2070 | 2154 |
2071 if (MayBePseudoDestructor && !LHS.isInvalid()) { | 2155 if (MayBePseudoDestructor && !LHS.isInvalid()) { |
2072 LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS, | 2156 LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS, |
2180 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof, | 2264 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof, |
2181 tok::kw__Alignof)) { | 2265 tok::kw__Alignof)) { |
2182 if (isTypeIdUnambiguously()) { | 2266 if (isTypeIdUnambiguously()) { |
2183 DeclSpec DS(AttrFactory); | 2267 DeclSpec DS(AttrFactory); |
2184 ParseSpecifierQualifierList(DS); | 2268 ParseSpecifierQualifierList(DS); |
2185 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); | 2269 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); |
2186 ParseDeclarator(DeclaratorInfo); | 2270 ParseDeclarator(DeclaratorInfo); |
2187 | 2271 |
2188 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation()); | 2272 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation()); |
2189 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation); | 2273 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation); |
2190 Diag(LParenLoc, diag::err_expected_parentheses_around_typename) | 2274 if (LParenLoc.isInvalid() || RParenLoc.isInvalid()) { |
2191 << OpTok.getName() | 2275 Diag(OpTok.getLocation(), |
2192 << FixItHint::CreateInsertion(LParenLoc, "(") | 2276 diag::err_expected_parentheses_around_typename) |
2193 << FixItHint::CreateInsertion(RParenLoc, ")"); | 2277 << OpTok.getName(); |
2278 } else { | |
2279 Diag(LParenLoc, diag::err_expected_parentheses_around_typename) | |
2280 << OpTok.getName() << FixItHint::CreateInsertion(LParenLoc, "(") | |
2281 << FixItHint::CreateInsertion(RParenLoc, ")"); | |
2282 } | |
2194 isCastExpr = true; | 2283 isCastExpr = true; |
2195 return ExprEmpty(); | 2284 return ExprEmpty(); |
2196 } | 2285 } |
2197 } | 2286 } |
2198 | 2287 |
2236 // If we get here, the operand to the typeof/sizeof/alignof was an expression. | 2325 // If we get here, the operand to the typeof/sizeof/alignof was an expression. |
2237 isCastExpr = false; | 2326 isCastExpr = false; |
2238 return Operand; | 2327 return Operand; |
2239 } | 2328 } |
2240 | 2329 |
2241 | 2330 /// Parse a __builtin_sycl_unique_stable_name expression. Accepts a type-id as |
2242 ExprResult Parser::ParseUniqueStableNameExpression() { | 2331 /// a parameter. |
2243 assert(Tok.is(tok::kw___builtin_unique_stable_name) && | 2332 ExprResult Parser::ParseSYCLUniqueStableNameExpression() { |
2244 "Not __bulitin_unique_stable_name"); | 2333 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) && |
2334 "Not __bulitin_sycl_unique_stable_name"); | |
2245 | 2335 |
2246 SourceLocation OpLoc = ConsumeToken(); | 2336 SourceLocation OpLoc = ConsumeToken(); |
2247 BalancedDelimiterTracker T(*this, tok::l_paren); | 2337 BalancedDelimiterTracker T(*this, tok::l_paren); |
2248 | 2338 |
2249 // typeid expressions are always parenthesized. | 2339 // __builtin_sycl_unique_stable_name expressions are always parenthesized. |
2250 if (T.expectAndConsume(diag::err_expected_lparen_after, | 2340 if (T.expectAndConsume(diag::err_expected_lparen_after, |
2251 "__builtin_unique_stable_name")) | 2341 "__builtin_sycl_unique_stable_name")) |
2252 return ExprError(); | 2342 return ExprError(); |
2253 | 2343 |
2254 if (isTypeIdInParens()) { | 2344 TypeResult Ty = ParseTypeName(); |
2255 TypeResult Ty = ParseTypeName(); | 2345 |
2256 T.consumeClose(); | 2346 if (Ty.isInvalid()) { |
2257 | 2347 T.skipToEnd(); |
2258 if (Ty.isInvalid()) | 2348 return ExprError(); |
2259 return ExprError(); | 2349 } |
2260 | 2350 |
2261 return Actions.ActOnUniqueStableNameExpr(OpLoc, T.getOpenLocation(), | 2351 if (T.consumeClose()) |
2262 T.getCloseLocation(), Ty.get()); | 2352 return ExprError(); |
2263 } | 2353 |
2264 | 2354 return Actions.ActOnSYCLUniqueStableNameExpr(OpLoc, T.getOpenLocation(), |
2265 EnterExpressionEvaluationContext Unevaluated( | 2355 T.getCloseLocation(), Ty.get()); |
2266 Actions, Sema::ExpressionEvaluationContext::Unevaluated); | |
2267 ExprResult Result = ParseExpression(); | |
2268 | |
2269 if (Result.isInvalid()) { | |
2270 SkipUntil(tok::r_paren, StopAtSemi); | |
2271 return Result; | |
2272 } | |
2273 | |
2274 T.consumeClose(); | |
2275 return Actions.ActOnUniqueStableNameExpr(OpLoc, T.getOpenLocation(), | |
2276 T.getCloseLocation(), Result.get()); | |
2277 } | 2356 } |
2278 | 2357 |
2279 /// Parse a sizeof or alignof expression. | 2358 /// Parse a sizeof or alignof expression. |
2280 /// | 2359 /// |
2281 /// \verbatim | 2360 /// \verbatim |
2727 ExprResult Result(true); | 2806 ExprResult Result(true); |
2728 bool isAmbiguousTypeId; | 2807 bool isAmbiguousTypeId; |
2729 CastTy = nullptr; | 2808 CastTy = nullptr; |
2730 | 2809 |
2731 if (Tok.is(tok::code_completion)) { | 2810 if (Tok.is(tok::code_completion)) { |
2811 cutOffParsing(); | |
2732 Actions.CodeCompleteExpression( | 2812 Actions.CodeCompleteExpression( |
2733 getCurScope(), PreferredType.get(Tok.getLocation()), | 2813 getCurScope(), PreferredType.get(Tok.getLocation()), |
2734 /*IsParenthesized=*/ExprType >= CompoundLiteral); | 2814 /*IsParenthesized=*/ExprType >= CompoundLiteral); |
2735 cutOffParsing(); | |
2736 return ExprError(); | 2815 return ExprError(); |
2737 } | 2816 } |
2738 | 2817 |
2739 // Diagnose use of bridge casts in non-arc mode. | 2818 // Diagnose use of bridge casts in non-arc mode. |
2740 bool BridgeCast = (getLangOpts().ObjC && | 2819 bool BridgeCast = (getLangOpts().ObjC && |
2756 | 2835 |
2757 // None of these cases should fall through with an invalid Result | 2836 // None of these cases should fall through with an invalid Result |
2758 // unless they've already reported an error. | 2837 // unless they've already reported an error. |
2759 if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { | 2838 if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { |
2760 Diag(Tok, diag::ext_gnu_statement_expr); | 2839 Diag(Tok, diag::ext_gnu_statement_expr); |
2840 | |
2841 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin); | |
2761 | 2842 |
2762 if (!getCurScope()->getFnParent() && !getCurScope()->getBlockParent()) { | 2843 if (!getCurScope()->getFnParent() && !getCurScope()->getBlockParent()) { |
2763 Result = ExprError(Diag(OpenLoc, diag::err_stmtexpr_file_scope)); | 2844 Result = ExprError(Diag(OpenLoc, diag::err_stmtexpr_file_scope)); |
2764 } else { | 2845 } else { |
2765 // Find the nearest non-record decl context. Variables declared in a | 2846 // Find the nearest non-record decl context. Variables declared in a |
2841 } | 2922 } |
2842 | 2923 |
2843 // Parse the type declarator. | 2924 // Parse the type declarator. |
2844 DeclSpec DS(AttrFactory); | 2925 DeclSpec DS(AttrFactory); |
2845 ParseSpecifierQualifierList(DS); | 2926 ParseSpecifierQualifierList(DS); |
2846 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); | 2927 Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); |
2847 ParseDeclarator(DeclaratorInfo); | 2928 ParseDeclarator(DeclaratorInfo); |
2848 | 2929 |
2849 // If our type is followed by an identifier and either ':' or ']', then | 2930 // If our type is followed by an identifier and either ':' or ']', then |
2850 // this is probably an Objective-C message send where the leading '[' is | 2931 // this is probably an Objective-C message send where the leading '[' is |
2851 // missing. Recover as if that were the case. | 2932 // missing. Recover as if that were the case. |
3065 SourceLocation LParenLoc, | 3146 SourceLocation LParenLoc, |
3066 SourceLocation RParenLoc) { | 3147 SourceLocation RParenLoc) { |
3067 assert(Tok.is(tok::l_brace) && "Not a compound literal!"); | 3148 assert(Tok.is(tok::l_brace) && "Not a compound literal!"); |
3068 if (!getLangOpts().C99) // Compound literals don't exist in C90. | 3149 if (!getLangOpts().C99) // Compound literals don't exist in C90. |
3069 Diag(LParenLoc, diag::ext_c99_compound_literal); | 3150 Diag(LParenLoc, diag::ext_c99_compound_literal); |
3151 PreferredType.enterTypeCast(Tok.getLocation(), Ty.get()); | |
3070 ExprResult Result = ParseInitializer(); | 3152 ExprResult Result = ParseInitializer(); |
3071 if (!Result.isInvalid() && Ty) | 3153 if (!Result.isInvalid() && Ty) |
3072 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.get()); | 3154 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.get()); |
3073 return Result; | 3155 return Result; |
3074 } | 3156 } |
3241 Diag(EllipsisLoc, getLangOpts().CPlusPlus17 | 3323 Diag(EllipsisLoc, getLangOpts().CPlusPlus17 |
3242 ? diag::warn_cxx14_compat_fold_expression | 3324 ? diag::warn_cxx14_compat_fold_expression |
3243 : diag::ext_fold_expression); | 3325 : diag::ext_fold_expression); |
3244 | 3326 |
3245 T.consumeClose(); | 3327 T.consumeClose(); |
3246 return Actions.ActOnCXXFoldExpr(T.getOpenLocation(), LHS.get(), Kind, | 3328 return Actions.ActOnCXXFoldExpr(getCurScope(), T.getOpenLocation(), LHS.get(), |
3247 EllipsisLoc, RHS.get(), T.getCloseLocation()); | 3329 Kind, EllipsisLoc, RHS.get(), |
3330 T.getCloseLocation()); | |
3248 } | 3331 } |
3249 | 3332 |
3250 /// ParseExpressionList - Used for C/C++ (argument-)expression-list. | 3333 /// ParseExpressionList - Used for C/C++ (argument-)expression-list. |
3251 /// | 3334 /// |
3252 /// \verbatim | 3335 /// \verbatim |
3357 /// [clang] block-id: | 3440 /// [clang] block-id: |
3358 /// [clang] specifier-qualifier-list block-declarator | 3441 /// [clang] specifier-qualifier-list block-declarator |
3359 /// \endverbatim | 3442 /// \endverbatim |
3360 void Parser::ParseBlockId(SourceLocation CaretLoc) { | 3443 void Parser::ParseBlockId(SourceLocation CaretLoc) { |
3361 if (Tok.is(tok::code_completion)) { | 3444 if (Tok.is(tok::code_completion)) { |
3445 cutOffParsing(); | |
3362 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type); | 3446 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type); |
3363 return cutOffParsing(); | 3447 return; |
3364 } | 3448 } |
3365 | 3449 |
3366 // Parse the specifier-qualifier-list piece. | 3450 // Parse the specifier-qualifier-list piece. |
3367 DeclSpec DS(AttrFactory); | 3451 DeclSpec DS(AttrFactory); |
3368 ParseSpecifierQualifierList(DS); | 3452 ParseSpecifierQualifierList(DS); |
3369 | 3453 |
3370 // Parse the block-declarator. | 3454 // Parse the block-declarator. |
3371 Declarator DeclaratorInfo(DS, DeclaratorContext::BlockLiteralContext); | 3455 Declarator DeclaratorInfo(DS, DeclaratorContext::BlockLiteral); |
3372 DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition); | 3456 DeclaratorInfo.setFunctionDefinitionKind(FunctionDefinitionKind::Definition); |
3373 ParseDeclarator(DeclaratorInfo); | 3457 ParseDeclarator(DeclaratorInfo); |
3374 | 3458 |
3375 MaybeParseGNUAttributes(DeclaratorInfo); | 3459 MaybeParseGNUAttributes(DeclaratorInfo); |
3376 | 3460 |
3377 // Inform sema that we are starting a block. | 3461 // Inform sema that we are starting a block. |
3405 // Inform sema that we are starting a block. | 3489 // Inform sema that we are starting a block. |
3406 Actions.ActOnBlockStart(CaretLoc, getCurScope()); | 3490 Actions.ActOnBlockStart(CaretLoc, getCurScope()); |
3407 | 3491 |
3408 // Parse the return type if present. | 3492 // Parse the return type if present. |
3409 DeclSpec DS(AttrFactory); | 3493 DeclSpec DS(AttrFactory); |
3410 Declarator ParamInfo(DS, DeclaratorContext::BlockLiteralContext); | 3494 Declarator ParamInfo(DS, DeclaratorContext::BlockLiteral); |
3411 ParamInfo.setFunctionDefinitionKind(FDK_Definition); | 3495 ParamInfo.setFunctionDefinitionKind(FunctionDefinitionKind::Definition); |
3412 // FIXME: Since the return type isn't actually parsed, it can't be used to | 3496 // FIXME: Since the return type isn't actually parsed, it can't be used to |
3413 // fill ParamInfo with an initial valid range, so do it manually. | 3497 // fill ParamInfo with an initial valid range, so do it manually. |
3414 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation())); | 3498 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation())); |
3415 | 3499 |
3416 // If this block has arguments, parse them. There is no ambiguity here with | 3500 // If this block has arguments, parse them. There is no ambiguity here with |
3543 if (Tok.is(tok::star)) { | 3627 if (Tok.is(tok::star)) { |
3544 return AvailabilitySpec(ConsumeToken()); | 3628 return AvailabilitySpec(ConsumeToken()); |
3545 } else { | 3629 } else { |
3546 // Parse the platform name. | 3630 // Parse the platform name. |
3547 if (Tok.is(tok::code_completion)) { | 3631 if (Tok.is(tok::code_completion)) { |
3632 cutOffParsing(); | |
3548 Actions.CodeCompleteAvailabilityPlatformName(); | 3633 Actions.CodeCompleteAvailabilityPlatformName(); |
3549 cutOffParsing(); | |
3550 return None; | 3634 return None; |
3551 } | 3635 } |
3552 if (Tok.isNot(tok::identifier)) { | 3636 if (Tok.isNot(tok::identifier)) { |
3553 Diag(Tok, diag::err_avail_query_expected_platform_name); | 3637 Diag(Tok, diag::err_avail_query_expected_platform_name); |
3554 return None; | 3638 return None; |