clang: lib/Parse/ParseExpr.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

42#include "llvm/ADT/SmallVector.h"

43#include

44using namespace clang;

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

136 return ParseRHSOfBinaryExpression(LHS, prec::Comma);

137}

138

139

140

141

142

143

145Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {

146 ExprResult LHS(ParseObjCAtExpression(AtLoc));

147 return ParseRHSOfBinaryExpression(LHS, prec::Comma);

148}

149

150

151

152

154Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {

156 {

157

159

160 LHS = ParseCastExpression(AnyCastExpr);

161 }

162

163 if (!LHS.isInvalid())

165 LHS.get());

166

167 return ParseRHSOfBinaryExpression(LHS, prec::Comma);

168}

169

170

172 if (Tok.is(tok::code_completion)) {

173 cutOffParsing();

177 }

178

179 if (Tok.is(tok::kw_throw))

180 return ParseThrowExpression();

181 if (Tok.is(tok::kw_co_yield))

182 return ParseCoyieldExpression();

183

184 ExprResult LHS = ParseCastExpression(AnyCastExpr,

185 false,

186 isTypeCast);

188}

189

191 if (Tok.is(tok::code_completion)) {

192 cutOffParsing();

196 }

197

198 ExprResult LHS = ParseCastExpression(

199 AnyCastExpr, false, NotTypeCast);

201}

202

203

204

205

206

207

208

209

210

211

213Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,

216 Expr *ReceiverExpr) {

218 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,

219 ReceiverType, ReceiverExpr);

220 R = ParsePostfixExpressionSuffix(R);

222}

223

228 "Call this function only if your ExpressionEvaluationContext is "

229 "already ConstantEvaluated");

230 ExprResult LHS(ParseCastExpression(AnyCastExpr, false, isTypeCast));

233}

234

236

237

238

239

243}

244

248

249

250 Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;

252}

253

260}

261

262

263

264

265

266

267

271 ExprResult LHS(ParseCastExpression(AnyCastExpr));

276 }

277 return Res;

278}

279

280

281

282

283

284

285

286

287

288

293 bool NotPrimaryExpression = false;

294 auto ParsePrimary = [&] () {

295 ExprResult E = ParseCastExpression(PrimaryExprOnly,

296 false,

298 false,

299 &NotPrimaryExpression);

300 if (E.isInvalid())

302 auto RecoverFromNonPrimary = [&] (ExprResult E, bool Note) {

303 E = ParsePostfixExpressionSuffix(E);

304

305

307 if (E.isInvalid())

310 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause

311 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)

316 return E;

317 };

318

319 if (NotPrimaryExpression ||

320

321

324

325

326 Tok.isOneOf(tok::period, tok::plusplus, tok::minusminus) ||

327 (Tok.is(tok::l_square) && NextToken().is(tok::l_square))) {

328 E = RecoverFromNonPrimary(E, false);

329 if (E.isInvalid())

331 NotPrimaryExpression = false;

332 }

333 bool PossibleNonPrimary;

334 bool IsConstraintExpr =

336 IsTrailingRequiresClause);

337 if (!IsConstraintExpr || PossibleNonPrimary) {

338

339

340

341

342 if (PossibleNonPrimary)

343 E = RecoverFromNonPrimary(E, !IsConstraintExpr);

346 }

347 return E;

348 };

352 while (Tok.is(tok::ampamp)) {

358 }

360 tok::ampamp, LHS.get(), RHS.get());

365 }

366 LHS = Op;

367 }

368 return LHS;

369}

370

371

372

373

374

375

376

377

378

379

380

386 while (Tok.is(tok::pipepipe)) {

393 }

395 tok::pipepipe, LHS.get(), RHS.get());

400 }

401 LHS = Op;

402 }

403 return LHS;

404}

405

406bool Parser::isNotExpressionStart() {

408 if (K == tok::l_brace || K == tok::r_brace ||

409 K == tok::kw_for || K == tok::kw_while ||

410 K == tok::kw_if || K == tok::kw_else ||

411 K == tok::kw_goto || K == tok::kw_try)

412 return true;

413

414 return isKnownToBeDeclarationSpecifier();

415}

416

417bool Parser::isFoldOperator(prec::Level Level) const {

420}

421

422bool Parser::isFoldOperator(tok::TokenKind Kind) const {

423 return isFoldOperator(getBinOpPrecedence(Kind, GreaterThanIsOperator, true));

424}

425

426

427

431 GreaterThanIsOperator,

434

435 auto SavedType = PreferredType;

436 while (true) {

437

438 PreferredType = SavedType;

439

440

441

442 if (NextTokPrec < MinPrec)

443 return LHS;

444

445

446 Token OpToken = Tok;

448

449

450

451 if (OpToken.isOneOf(tok::comma, tok::greater, tok::greatergreater,

452 tok::greatergreatergreater) &&

453 checkPotentialAngleBracketDelimiter(OpToken))

455

456

457

458

459

460

461 if (OpToken.is(tok::comma) && isNotExpressionStart()) {

462 PP.EnterToken(Tok, true);

463 Tok = OpToken;

464 return LHS;

465 }

466

467

468

469 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {

470

471

472 PP.EnterToken(Tok, true);

473 Tok = OpToken;

474 return LHS;

475 }

476

477

478

479

480

481

483 Tok.isOneOf(tok::colon, tok::r_square) &&

485 PP.EnterToken(Tok, true);

486 Tok = OpToken;

487 return LHS;

488 }

489

490

494

496 TernaryMiddle = ParseBraceInitializer();

497 if (!TernaryMiddle.isInvalid()) {

498 Diag(BraceLoc, diag::err_init_list_bin_op)

500 << Actions.getExprRange(TernaryMiddle.get());

502 }

503 } else if (Tok.isNot(tok::colon)) {

504

506

507

508

509

510

512 } else {

513

514

515 TernaryMiddle = nullptr;

516 Diag(Tok, diag::ext_gnu_conditional_expr);

517 }

518

519 if (TernaryMiddle.isInvalid()) {

522 TernaryMiddle = nullptr;

523 }

524

526

527

528

529

531 const char *FIText = ": ";

535 bool IsInvalid = false;

536 const char *SourcePtr =

538 if (!IsInvalid && *SourcePtr == ' ') {

539 SourcePtr =

541 if (!IsInvalid && *SourcePtr == ' ') {

543 FIText = ":";

544 }

545 }

546 }

547

548 Diag(Tok, diag::err_expected)

550 Diag(OpToken, diag::note_matching) << tok::question;

552 }

553 }

554

557

558

559

560

561

562

563

564

565

566

568 bool RHSIsInitList = false;

570 RHS = ParseBraceInitializer();

571 RHSIsInitList = true;

574 else

575 RHS = ParseCastExpression(AnyCastExpr);

576

578

579

581 if (TernaryMiddle.isUsable())

584 }

585

586

587

591

592

595

596

597

598 if (ThisPrec < NextTokPrec ||

599 (ThisPrec == NextTokPrec && isRightAssoc)) {

600 if (!RHS.isInvalid() && RHSIsInitList) {

601 Diag(Tok, diag::err_init_list_bin_op)

604 }

605

606

607

608

609

610 RHS = ParseRHSOfBinaryExpression(RHS,

611 static_cast<prec::Level>(ThisPrec + !isRightAssoc));

612 RHSIsInitList = false;

613

615

616

618 if (TernaryMiddle.isUsable())

621 }

622

625 }

626

627 if (!RHS.isInvalid() && RHSIsInitList) {

629 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)

631 } else if (ColonLoc.isValid()) {

632 Diag(ColonLoc, diag::err_init_list_bin_op)

633 << 1 << ":"

636 } else {

637 Diag(OpToken, diag::err_init_list_bin_op)

641 }

642 }

643

646

647 if (TernaryMiddle.isInvalid()) {

648

649

650

651 if (!GreaterThanIsOperator && OpToken.is(tok::greatergreater))

652 SuggestParentheses(OpToken.getLocation(),

653 diag::warn_cxx11_right_shift_in_template_arg,

656

663 {LHS.get(), RHS.get()});

664

665 LHS = BinOp;

666 } else {

668 OpToken.getLocation(), ColonLoc, LHS.get(), TernaryMiddle.get(),

669 RHS.get());

671 std::vector<clang::Expr *> Args;

672

673 if (TernaryMiddle.get())

674 Args = {LHS.get(), TernaryMiddle.get(), RHS.get()};

675 else

676 Args = {LHS.get(), RHS.get()};

679 }

680

681 LHS = CondOp;

682 }

683

684

686 continue;

687 }

688

689

694 }

695 }

696}

697

698

699

700

701

702

703

704ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,

705 bool isAddressOfOperand,

706 TypeCastState isTypeCast,

707 bool isVectorLiteral,

708 bool *NotPrimaryExpression) {

709 bool NotCastExpr;

710 ExprResult Res = ParseCastExpression(ParseKind,

711 isAddressOfOperand,

712 NotCastExpr,

713 isTypeCast,

714 isVectorLiteral,

715 NotPrimaryExpression);

716 if (NotCastExpr)

717 Diag(Tok, diag::err_expected_expression);

718 return Res;

719}

720

721namespace {

723 public:

724 CastExpressionIdValidator(Token Next, bool AllowTypes, bool AllowNonTypes)

725 : NextToken(Next), AllowNonTypes(AllowNonTypes) {

726 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;

727 }

728

729 bool ValidateCandidate(const TypoCorrection &candidate) override {

731 if (!ND)

733

734 if (isa(ND))

735 return WantTypeSpecifiers;

736

738 return false;

739

740 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))

741 return true;

742

743 for (auto *C : candidate) {

744 NamedDecl *ND = C->getUnderlyingDecl();

745 if (isa(ND) && !isa(ND))

746 return true;

747 }

748 return false;

749 }

750

751 std::unique_ptr clone() override {

752 return std::make_unique(*this);

753 }

754

755 private:

757 bool AllowNonTypes;

758};

759}

760

761bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,

763 if (RevertibleTypeTraits.empty()) {

764

765

766

767#define RTT_JOIN(X, Y) X##Y

768#define REVERTIBLE_TYPE_TRAIT(Name) \

769 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)

770

827#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \

828 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));

829#include "clang/Basic/TransformTypeTraits.def"

830#undef REVERTIBLE_TYPE_TRAIT

831#undef RTT_JOIN

832 }

833 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =

834 RevertibleTypeTraits.find(II);

835 if (Known != RevertibleTypeTraits.end()) {

836 if (Kind)

837 *Kind = Known->second;

838 return true;

839 }

840 return false;

841}

842

843ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {

845

847 if (T.expectAndConsume())

849

854 }

855

857 T.consumeClose();

859 Loc, UETT_PtrAuthTypeDiscriminator,

860 true, Ty.get().getAsOpaquePtr(), SourceRange(Loc, EndLoc));

861}

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,

1047 bool isAddressOfOperand,

1048 bool &NotCastExpr,

1049 TypeCastState isTypeCast,

1050 bool isVectorLiteral,

1051 bool *NotPrimaryExpression) {

1054 auto SavedType = PreferredType;

1055 NotCastExpr = false;

1056

1057

1058

1059

1060 bool AllowSuffix = true;

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072 switch (SavedKind) {

1073 case tok::l_paren: {

1074

1075

1076 ParenParseOption ParenExprType;

1077 switch (ParseKind) {

1078 case CastParseKind::UnaryExprOnly:

1080 [[fallthrough]];

1081 case CastParseKind::AnyCastExpr:

1082 ParenExprType = ParenParseOption::CastExpr;

1083 break;

1084 case CastParseKind::PrimaryExprOnly:

1085 ParenExprType = FoldExpr;

1086 break;

1087 }

1090 Res = ParseParenExpression(ParenExprType, false,

1091 isTypeCast == IsTypeCast, CastTy, RParenLoc);

1092

1093

1094

1095

1096 if (isVectorLiteral)

1097 return Res;

1098

1099 switch (ParenExprType) {

1100 case SimpleExpr: break;

1101 case CompoundStmt: break;

1102 case CompoundLiteral:

1103

1104

1105 break;

1107

1108

1109 return Res;

1110 case FoldExpr:

1111

1112

1113 break;

1114 }

1115

1116 break;

1117 }

1118

1119

1120 case tok::numeric_constant:

1121 case tok::binary_data:

1122

1123

1124

1127 break;

1128

1129 case tok::kw_true:

1130 case tok::kw_false:

1131 Res = ParseCXXBoolLiteral();

1132 break;

1133

1134 case tok::kw___objc_yes:

1135 case tok::kw___objc_no:

1136 Res = ParseObjCBoolLiteral();

1137 break;

1138

1139 case tok::kw_nullptr:

1141 Diag(Tok, diag::warn_cxx98_compat_nullptr);

1142 else

1144 : diag::ext_c_nullptr) << Tok.getName();

1145

1147 break;

1148

1149 case tok::annot_primary_expr:

1150 case tok::annot_overload_set:

1151 Res = getExprAnnotation(Tok);

1152 if (!Res.isInvalid() && Tok.getKind() == tok::annot_overload_set)

1154 ConsumeAnnotationToken();

1155 if (!Res.isInvalid() && Tok.is(tok::less))

1156 checkPotentialAngleBracket(Res);

1157 break;

1158

1159 case tok::annot_non_type:

1160 case tok::annot_non_type_dependent:

1161 case tok::annot_non_type_undeclared: {

1163 Token Replacement;

1164 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);

1165 assert(!Res.isUnset() &&

1166 "should not perform typo correction on annotation token");

1167 break;

1168 }

1169

1170 case tok::annot_embed: {

1171 injectEmbedTokens();

1172 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,

1173 isVectorLiteral, NotPrimaryExpression);

1174 }

1175

1176 case tok::kw___super:

1177 case tok::kw_decltype:

1178

1181 assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super));

1182 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,

1183 isVectorLiteral, NotPrimaryExpression);

1184

1185 case tok::identifier:

1186 ParseIdentifier: {

1187

1188

1189

1190

1192

1193

1195

1196 if (Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&

1197 GetLookAheadToken(2).is(tok::l_square)) {

1198

1199

1200

1202 Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))

1203 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,

1204 isVectorLiteral, NotPrimaryExpression);

1205 }

1206

1207

1208

1209

1210 else if (Next.is(tok::l_paren) && Tok.is(tok::identifier) &&

1214 if (isRevertibleTypeTrait(II, &Kind)) {

1216 return ParseCastExpression(ParseKind, isAddressOfOperand,

1217 NotCastExpr, isTypeCast,

1218 isVectorLiteral, NotPrimaryExpression);

1219 }

1220 }

1221

1222 else if ((!ColonIsSacred && Next.is(tok::colon)) ||

1223 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,

1224 tok::l_brace)) {

1225

1228 if (!Tok.is(tok::identifier))

1229 return ParseCastExpression(ParseKind, isAddressOfOperand,

1230 NotCastExpr, isTypeCast,

1231 isVectorLiteral,

1232 NotPrimaryExpression);

1233 }

1234 }

1235

1236

1237

1240

1241

1244

1245 (&II == Ident_super && getCurScope()->isInObjcMethodScope()))) {

1247

1248 if (Tok.is(tok::code_completion) && &II != Ident_super) {

1249 cutOffParsing();

1251 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);

1253 }

1254

1255 if (Tok.isNot(tok::identifier) &&

1257 Diag(Tok, diag::err_expected_property_name);

1259 }

1262

1264 PropertyLoc);

1265 break;

1266 }

1267

1268

1269

1270

1271

1272 if (getLangOpts().ObjC && &II == Ident_super && !InMessageExpression &&

1274 ((Tok.is(tok::identifier) &&

1276 Tok.is(tok::code_completion))) {

1277 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, nullptr,

1278 nullptr);

1279 break;

1280 }

1281

1282

1283

1284

1285

1286

1288 ((Tok.is(tok::identifier) && !InMessageExpression) ||

1289 Tok.is(tok::code_completion))) {

1291 if (Tok.is(tok::code_completion) ||

1292 Next.is(tok::colon) || Next.is(tok::r_square))

1294 if (Typ.get()->isObjCObjectOrInterfaceType()) {

1295

1297 DS.SetRangeStart(ILoc);

1298 DS.SetRangeEnd(ILoc);

1299 const char *PrevSpec = nullptr;

1300 unsigned DiagID;

1301 DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ,

1303

1308 break;

1309

1310 Res = ParseObjCMessageExpressionBody(SourceLocation(),

1312 Ty.get(), nullptr);

1313 break;

1314 }

1315 }

1316

1317

1318 if (isAddressOfOperand && isPostfixExpressionSuffixStart())

1319 isAddressOfOperand = false;

1320

1321

1322

1323

1327 Token Replacement;

1328 CastExpressionIdValidator Validator(

1329 Tok,

1330 isTypeCast != NotTypeCast,

1331 isTypeCast != IsTypeCast);

1332 Validator.IsAddressOfOperand = isAddressOfOperand;

1333 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {

1334 Validator.WantExpressionKeywords = false;

1335 Validator.WantRemainingKeywords = false;

1336 } else {

1337 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);

1338 }

1339 Name.setIdentifier(&II, ILoc);

1341 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),

1342 isAddressOfOperand, &Validator,

1343 false,

1344 Tok.is(tok::r_paren) ? nullptr : &Replacement);

1346 UnconsumeToken(Replacement);

1347 return ParseCastExpression(ParseKind, isAddressOfOperand,

1348 NotCastExpr, isTypeCast,

1349 false,

1350 NotPrimaryExpression);

1351 }

1352 Res = tryParseCXXPackIndexingExpression(Res);

1353 if (!Res.isInvalid() && Tok.is(tok::less))

1354 checkPotentialAngleBracket(Res);

1355 break;

1356 }

1357 case tok::char_constant:

1358 case tok::wide_char_constant:

1359 case tok::utf8_char_constant:

1360 case tok::utf16_char_constant:

1361 case tok::utf32_char_constant:

1364 break;

1365 case tok::kw___func__:

1366 case tok::kw___FUNCTION__:

1367 case tok::kw___FUNCDNAME__:

1368 case tok::kw___FUNCSIG__:

1369 case tok::kw_L__FUNCTION__:

1370 case tok::kw_L__FUNCSIG__:

1371 case tok::kw___PRETTY_FUNCTION__:

1372

1373

1374

1380 break;

1381 }

1382 [[fallthrough]];

1383 case tok::string_literal:

1384 case tok::wide_string_literal:

1385 case tok::utf8_string_literal:

1386 case tok::utf16_string_literal:

1387 case tok::utf32_string_literal:

1389 break;

1390 case tok::kw__Generic:

1391 Res = ParseGenericSelectionExpression();

1392 break;

1393 case tok::kw___builtin_available:

1394 Res = ParseAvailabilityCheckExpr(Tok.getLocation());

1395 break;

1396 case tok::kw___builtin_va_arg:

1397 case tok::kw___builtin_offsetof:

1398 case tok::kw___builtin_choose_expr:

1399 case tok::kw___builtin_astype:

1400 case tok::kw___builtin_convertvector:

1401 case tok::kw___builtin_COLUMN:

1402 case tok::kw___builtin_FILE:

1403 case tok::kw___builtin_FILE_NAME:

1404 case tok::kw___builtin_FUNCTION:

1405 case tok::kw___builtin_FUNCSIG:

1406 case tok::kw___builtin_LINE:

1407 case tok::kw___builtin_source_location:

1408 if (NotPrimaryExpression)

1409 *NotPrimaryExpression = true;

1410

1411 return ParseBuiltinPrimaryExpression();

1412 case tok::kw___null:

1414 break;

1415

1416 case tok::plusplus:

1417 case tok::minusminus: {

1418 if (NotPrimaryExpression)

1419 *NotPrimaryExpression = true;

1420

1421

1422

1423

1424 Token SavedTok = Tok;

1426

1429

1430

1431

1433 UnaryExprOnly : AnyCastExpr,

1434 false, NotCastExpr,

1436 if (NotCastExpr) {

1437

1438

1440 UnconsumeToken(SavedTok);

1442 }

1446 SavedKind, Arg);

1450 }

1451 return Res;

1452 }

1453 case tok::amp: {

1454 if (NotPrimaryExpression)

1455 *NotPrimaryExpression = true;

1456

1459

1460 Res = ParseCastExpression(AnyCastExpr, true);

1466 Arg);

1467 }

1468 return Res;

1469 }

1470

1471 case tok:⭐

1472 case tok:➕

1473 case tok:➖

1474 case tok::tilde:

1475 case tok::exclaim:

1476 case tok::kw___real:

1477 case tok::kw___imag: {

1478 if (NotPrimaryExpression)

1479 *NotPrimaryExpression = true;

1482 Res = ParseCastExpression(AnyCastExpr);

1486 isAddressOfOperand);

1489 }

1490 return Res;

1491 }

1492

1493 case tok::kw_co_await: {

1494 if (NotPrimaryExpression)

1495 *NotPrimaryExpression = true;

1497 Res = ParseCastExpression(AnyCastExpr);

1500 return Res;

1501 }

1502

1503 case tok::kw___extension__:{

1504

1505 if (NotPrimaryExpression)

1506 *NotPrimaryExpression = true;

1509 Res = ParseCastExpression(AnyCastExpr);

1512 return Res;

1513 }

1514 case tok::kw__Alignof:

1515 diagnoseUseOfC11Keyword(Tok);

1516 [[fallthrough]];

1517 case tok::kw_alignof:

1518 case tok::kw___alignof:

1519

1520 case tok::kw_sizeof:

1521

1522

1523

1524 case tok::kw___datasizeof:

1525 case tok::kw_vec_step:

1526

1527 case tok::kw___builtin_omp_required_simd_align:

1528 case tok::kw___builtin_vectorelements:

1529 if (NotPrimaryExpression)

1530 *NotPrimaryExpression = true;

1531 AllowSuffix = false;

1532 Res = ParseUnaryExprOrTypeTraitExpression();

1533 break;

1534 case tok::ampamp: {

1535 if (NotPrimaryExpression)

1536 *NotPrimaryExpression = true;

1538 if (Tok.isNot(tok::identifier))

1539 return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);

1540

1541 if (getCurScope()->getFnParent() == nullptr)

1542 return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn));

1543

1544 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);

1549 AllowSuffix = false;

1550 break;

1551 }

1552 case tok::kw_const_cast:

1553 case tok::kw_dynamic_cast:

1554 case tok::kw_reinterpret_cast:

1555 case tok::kw_static_cast:

1556 case tok::kw_addrspace_cast:

1557 if (NotPrimaryExpression)

1558 *NotPrimaryExpression = true;

1559 Res = ParseCXXCasts();

1560 break;

1561 case tok::kw___builtin_bit_cast:

1562 if (NotPrimaryExpression)

1563 *NotPrimaryExpression = true;

1564 Res = ParseBuiltinBitCast();

1565 break;

1566 case tok::kw_typeid:

1567 if (NotPrimaryExpression)

1568 *NotPrimaryExpression = true;

1569 Res = ParseCXXTypeid();

1570 break;

1571 case tok::kw___uuidof:

1572 if (NotPrimaryExpression)

1573 *NotPrimaryExpression = true;

1574 Res = ParseCXXUuidof();

1575 break;

1576 case tok::kw_this:

1577 Res = ParseCXXThis();

1578 break;

1579 case tok::kw___builtin_sycl_unique_stable_name:

1580 Res = ParseSYCLUniqueStableNameExpression();

1581 break;

1582

1583 case tok::annot_typename:

1584 if (isStartOfObjCClassMessageMissingOpenBracket()) {

1586

1587

1591

1592 const char *PrevSpec = nullptr;

1593 unsigned DiagID;

1595 PrevSpec, DiagID, Type,

1597

1602 break;

1603

1604 ConsumeAnnotationToken();

1606 Ty.get(), nullptr);

1607 break;

1608 }

1609 [[fallthrough]];

1610

1611 case tok::annot_decltype:

1612 case tok::annot_pack_indexing_type:

1613 case tok::kw_char:

1614 case tok::kw_wchar_t:

1615 case tok::kw_char8_t:

1616 case tok::kw_char16_t:

1617 case tok::kw_char32_t:

1618 case tok::kw_bool:

1619 case tok::kw_short:

1620 case tok::kw_int:

1621 case tok::kw_long:

1622 case tok::kw___int64:

1623 case tok::kw___int128:

1624 case tok::kw__ExtInt:

1625 case tok::kw__BitInt:

1626 case tok::kw_signed:

1627 case tok::kw_unsigned:

1628 case tok::kw_half:

1629 case tok::kw_float:

1630 case tok::kw_double:

1631 case tok::kw___bf16:

1632 case tok::kw__Float16:

1633 case tok::kw___float128:

1634 case tok::kw___ibm128:

1635 case tok::kw_void:

1636 case tok::kw_auto:

1637 case tok::kw_typename:

1638 case tok::kw_typeof:

1639 case tok::kw___vector:

1640 case tok::kw__Accum:

1641 case tok::kw__Fract:

1642 case tok::kw__Sat:

1643#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:

1644#include "clang/Basic/OpenCLImageTypes.def"

1645#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:

1646#include "clang/Basic/HLSLIntangibleTypes.def"

1647 {

1649 Diag(Tok, diag::err_expected_expression);

1651 }

1652

1653

1654 if (NotPrimaryExpression)

1655 *NotPrimaryExpression = true;

1656

1657 if (SavedKind == tok::kw_typename) {

1658

1659

1662

1664

1665

1667 }

1668

1669

1670

1671

1673

1674 ParseCXXSimpleTypeSpecifier(DS);

1675 if (Tok.isNot(tok::l_paren) &&

1677 return ExprError(Diag(Tok, diag::err_expected_lparen_after_type)

1678 << DS.getSourceRange());

1679

1680 if (Tok.is(tok::l_brace))

1681 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);

1682

1683 Res = ParseCXXTypeConstructExpression(DS);

1684 break;

1685 }

1686

1687 case tok::annot_cxxscope: {

1688

1689

1692 if (!Tok.is(tok::annot_cxxscope))

1693 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,

1694 isTypeCast, isVectorLiteral,

1695 NotPrimaryExpression);

1696

1698 if (Next.is(tok::annot_template_id)) {

1701

1702

1703

1705 ParseOptionalCXXScopeSpecifier(SS, nullptr,

1706 false,

1707 false);

1709 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,

1710 isTypeCast, isVectorLiteral,

1711 NotPrimaryExpression);

1712 }

1713 }

1714

1715

1716 Res = ParseCXXIdExpression(isAddressOfOperand);

1717 break;

1718 }

1719

1720 case tok::annot_template_id: {

1723

1724

1725

1728 return ParseCastExpression(ParseKind, isAddressOfOperand,

1729 NotCastExpr, isTypeCast, isVectorLiteral,

1730 NotPrimaryExpression);

1731 }

1732

1733

1734 [[fallthrough]];

1735 }

1736

1737 case tok::kw_operator:

1738 Res = ParseCXXIdExpression(isAddressOfOperand);

1739 break;

1740

1741 case tok::coloncolon: {

1742

1743

1746 if (!Tok.is(tok::coloncolon))

1747 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,

1748 isVectorLiteral, NotPrimaryExpression);

1749

1750

1751

1753 if (Tok.is(tok::kw_new)) {

1754 if (NotPrimaryExpression)

1755 *NotPrimaryExpression = true;

1756 Res = ParseCXXNewExpression(true, CCLoc);

1757 AllowSuffix = false;

1758 break;

1759 }

1760 if (Tok.is(tok::kw_delete)) {

1761 if (NotPrimaryExpression)

1762 *NotPrimaryExpression = true;

1763 Res = ParseCXXDeleteExpression(true, CCLoc);

1764 AllowSuffix = false;

1765 break;

1766 }

1767

1768

1769 Diag(CCLoc, diag::err_expected_expression);

1771 }

1772

1773 case tok::kw_new:

1774 if (NotPrimaryExpression)

1775 *NotPrimaryExpression = true;

1776 Res = ParseCXXNewExpression(false, Tok.getLocation());

1777 AllowSuffix = false;

1778 break;

1779

1780 case tok::kw_delete:

1781 if (NotPrimaryExpression)

1782 *NotPrimaryExpression = true;

1783 Res = ParseCXXDeleteExpression(false, Tok.getLocation());

1784 AllowSuffix = false;

1785 break;

1786

1787 case tok::kw_requires:

1788 Res = ParseRequiresExpression();

1789 AllowSuffix = false;

1790 break;

1791

1792 case tok::kw_noexcept: {

1793 if (NotPrimaryExpression)

1794 *NotPrimaryExpression = true;

1795 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);

1798

1799 if (T.expectAndConsume(diag::err_expected_lparen_after, "noexcept"))

1801

1802

1803

1807

1808 T.consumeClose();

1809

1812 T.getCloseLocation());

1813 AllowSuffix = false;

1814 break;

1815 }

1816

1817#define TYPE_TRAIT(N,Spelling,K) \

1818 case tok::kw_##Spelling:

1819#include "clang/Basic/TokenKinds.def"

1820 Res = ParseTypeTrait();

1821 break;

1822

1823 case tok::kw___array_rank:

1824 case tok::kw___array_extent:

1825 if (NotPrimaryExpression)

1826 *NotPrimaryExpression = true;

1827 Res = ParseArrayTypeTrait();

1828 break;

1829

1830 case tok::kw___builtin_ptrauth_type_discriminator:

1831 return ParseBuiltinPtrauthTypeDiscriminator();

1832

1833 case tok::kw___is_lvalue_expr:

1834 case tok::kw___is_rvalue_expr:

1835 if (NotPrimaryExpression)

1836 *NotPrimaryExpression = true;

1837 Res = ParseExpressionTrait();

1838 break;

1839

1840 case tok::at: {

1841 if (NotPrimaryExpression)

1842 *NotPrimaryExpression = true;

1844 return ParseObjCAtExpression(AtLoc);

1845 }

1846 case tok::caret:

1847 Res = ParseBlockLiteralExpression();

1848 break;

1849 case tok::code_completion: {

1850 cutOffParsing();

1854 }

1855#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:

1856#include "clang/Basic/TransformTypeTraits.def"

1857

1858

1859 if (NextToken().is(tok::l_paren)) {

1860 Tok.setKind(tok::identifier);

1861 Diag(Tok, diag::ext_keyword_as_ident)

1863 goto ParseIdentifier;

1864 }

1865 goto ExpectedExpression;

1866 case tok::l_square:

1869

1870

1871

1872

1873

1874 Res = TryParseLambdaExpression();

1876

1877

1878 if (NotPrimaryExpression)

1879 *NotPrimaryExpression = true;

1880 Res = ParseObjCMessageExpression();

1881 }

1882 break;

1883 }

1884 Res = ParseLambdaExpression();

1885 break;

1886 }

1888 Res = ParseObjCMessageExpression();

1889 break;

1890 }

1891 [[fallthrough]];

1892 default:

1893 ExpectedExpression:

1894 NotCastExpr = true;

1896 }

1897

1898

1899

1900

1901

1902 if (ParseKind == PrimaryExprOnly)

1903

1904

1905 return Res;

1906

1907 if (!AllowSuffix) {

1908

1909

1911 return Res;

1912

1913 switch (Tok.getKind()) {

1914 case tok::l_square:

1915 case tok::l_paren:

1916 case tok::plusplus:

1917 case tok::minusminus:

1918

1919

1921 return Res;

1922

1923 [[fallthrough]];

1924 case tok::period:

1925 case tok::arrow:

1926 break;

1927

1928 default:

1929 return Res;

1930 }

1931

1932

1933

1934

1935 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)

1939 ")");

1940 }

1941

1942

1943 PreferredType = SavedType;

1944 Res = ParsePostfixExpressionSuffix(Res);

1946 getActions().getOpenCLOptions().isAvailableOption(

1947 "__cl_clang_function_pointers", getLangOpts()))

1948 if (Expr *PostfixExpr = Res.get()) {

1949 QualType Ty = PostfixExpr->getType();

1951 Diag(PostfixExpr->getExprLoc(),

1952 diag::err_opencl_taking_function_address_parser);

1954 }

1955 }

1956

1957 return Res;

1958}

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1982Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {

1983

1984

1986 auto SavedType = PreferredType;

1987 while (true) {

1988

1989 PreferredType = SavedType;

1990 switch (Tok.getKind()) {

1991 case tok::code_completion:

1992 if (InMessageExpression)

1993 return LHS;

1994

1995 cutOffParsing();

1999

2000 case tok::identifier:

2001

2002

2003

2007 nullptr, LHS.get());

2008 break;

2009 }

2010

2011 [[fallthrough]];

2012

2013 default:

2014 return LHS;

2015 case tok::l_square: {

2016

2017

2018

2019

2020

2021

2023 isSimpleObjCMessageExpression())

2024 return LHS;

2025

2026

2027

2028 if (CheckProhibitedCXX11Attribute()) {

2031 }

2033 T.consumeOpen();

2034 Loc = T.getOpenLocation();

2037 ExprVector ArgExprs;

2038 bool HasError = false;

2040

2041

2042

2043

2044

2045 if ((getLangOpts().OpenMP && !AllowOpenACCArraySections) ||

2046 Tok.isNot(tok::colon)) {

2050 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);

2051 Idx = ParseBraceInitializer();

2052 } else {

2054 }

2058 HasError = true;

2059 } else {

2060 ArgExprs.push_back(Idx.get());

2061 }

2062 } else if (Tok.isNot(tok::r_square)) {

2063 if (ParseExpressionList(ArgExprs)) {

2065 HasError = true;

2066 }

2067 }

2068 }

2069

2070

2071

2072

2073

2074 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {

2076 if (Tok.is(tok::colon)) {

2077

2079 if (Tok.isNot(tok::r_square))

2081 }

2082 } else if (ArgExprs.size() <= 1 && getLangOpts().OpenMP) {

2084 if (Tok.is(tok::colon)) {

2085

2087 if (Tok.isNot(tok::r_square) &&

2092 }

2093 }

2095 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||

2096 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&

2097 Tok.is(tok::colon)) {

2098

2100 if (Tok.isNot(tok::r_square)) {

2102 }

2103 }

2104 }

2105

2108

2109 if (!LHS.isInvalid() && !HasError && !Length.isInvalid() &&

2110 !Stride.isInvalid() && Tok.is(tok::r_square)) {

2111 if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) {

2112

2113

2114

2115

2116 if (AllowOpenACCArraySections) {

2117 assert(!Stride.isUsable() && !ColonLocSecond.isValid() &&

2118 "Stride/second colon not allowed for OpenACC");

2120 LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],

2121 ColonLocFirst, Length.get(), RLoc);

2122 } else {

2124 LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],

2125 ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(),

2126 RLoc);

2127 }

2128 } else {

2130 ArgExprs, RLoc);

2131 }

2132 } else {

2134 }

2135

2136

2137 T.consumeClose();

2138 break;

2139 }

2140

2141 case tok::l_paren:

2142 case tok::lesslessless: {

2143

2146

2147 Expr *ExecConfig = nullptr;

2148

2150

2151 if (OpKind == tok::lesslessless) {

2152 ExprVector ExecConfigExprs;

2154

2155 if (ParseSimpleExpressionList(ExecConfigExprs)) {

2158 }

2159

2161 if (TryConsumeToken(tok::greatergreatergreater, CloseLoc)) {

2164 } else {

2165

2166 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;

2167 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;

2170 }

2171

2173 if (ExpectAndConsume(tok::l_paren))

2175 else

2176 Loc = PrevTokLocation;

2177 }

2178

2181 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);

2184 else

2185 ExecConfig = ECResult.get();

2186 }

2187 } else {

2188 PT.consumeOpen();

2189 Loc = PT.getOpenLocation();

2190 }

2191

2192 ExprVector ArgExprs;

2193 auto RunSignatureHelp = [&]() -> QualType {

2196 LHS.get(), ArgExprs, PT.getOpenLocation());

2197 CalledSignatureHelp = true;

2198 return PreferredType;

2199 };

2200 if (OpKind == tok::l_paren || !LHS.isInvalid()) {

2201 if (Tok.isNot(tok::r_paren)) {

2202 bool HasTrailingComma = false;

2203 bool HasError = ParseExpressionList(

2204 ArgExprs,

2205 [&] {

2206 PreferredType.enterFunctionArgument(Tok.getLocation(),

2207 RunSignatureHelp);

2208 },

2209 false,

2210 false, &HasTrailingComma);

2211

2212 if (HasError && !HasTrailingComma) {

2214

2215

2216

2217

2219 RunSignatureHelp();

2222 for (auto &E : ArgExprs)

2224 }

2225 }

2226 }

2227

2228

2231 } else if (Tok.isNot(tok::r_paren)) {

2232 bool HadDelayedTypo = false;

2234 HadDelayedTypo = true;

2235 for (auto &E : ArgExprs)

2237 HadDelayedTypo = true;

2238

2239

2240

2241 if (HadDelayedTypo)

2243 else

2244 PT.consumeClose();

2246 } else {

2250 ExecConfig);

2252 ArgExprs.insert(ArgExprs.begin(), Fn);

2253 LHS =

2255 }

2256 PT.consumeClose();

2257 }

2258

2259 break;

2260 }

2261 case tok::arrow:

2262 case tok::period: {

2263

2264

2267

2270 bool MayBePseudoDestructor = false;

2272

2273 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);

2274

2277 const Type* BaseType = Base->getType().getTypePtrOrNull();

2278 if (BaseType && Tok.is(tok::l_paren) &&

2281 Diag(OpLoc, diag::err_function_is_not_record)

2282 << OpKind << Base->getSourceRange()

2284 return ParsePostfixExpressionSuffix(Base);

2285 }

2286

2288 OpKind, ObjectType,

2289 MayBePseudoDestructor);

2291

2292

2293

2294 if (Tok.is(tok::code_completion)) {

2295 cutOffParsing();

2297 }

2298 break;

2299 }

2300 ParseOptionalCXXScopeSpecifier(

2302 false, &MayBePseudoDestructor);

2304 ObjectType = nullptr;

2305 }

2306

2307 if (Tok.is(tok::code_completion)) {

2309 OpKind == tok::arrow ? tok::period : tok::arrow;

2310 ExprResult CorrectedLHS(true);

2312

2313

2316 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,

2317 MayBePseudoDestructor);

2318 }

2319

2321 Expr *CorrectedBase = CorrectedLHS.get();

2323 CorrectedBase = Base;

2324

2325

2326 cutOffParsing();

2328 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,

2329 Base && ExprStatementTokLoc == Base->getBeginLoc(),

2331

2333 }

2334

2335 if (MayBePseudoDestructor && !LHS.isInvalid()) {

2336 LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS,

2337 ObjectType);

2338 break;

2339 }

2340

2341

2342

2343

2344

2345

2346

2347

2351 Tok.is(tok::kw_class)) {

2352

2353

2354

2355

2356

2357

2358

2361 Name.setIdentifier(Id, Loc);

2364 false,

2365 true,

2366

2368 false, &TemplateKWLoc, Name)) {

2371 }

2372

2375 OpKind, SS, TemplateKWLoc, Name,

2376 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl

2377 : nullptr);

2379 if (Tok.is(tok::less))

2380 checkPotentialAngleBracket(LHS);

2381 } else if (OrigLHS && Name.isValid()) {

2382

2384 Name.getEndLoc(), {OrigLHS});

2385 }

2386 break;

2387 }

2388 case tok::plusplus:

2389 case tok::minusminus:

2397 }

2399 break;

2400 }

2401 }

2402}

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2437Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,

2438 bool &isCastExpr,

2441

2442 assert(OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,

2443 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,

2444 tok::kw__Alignof, tok::kw_vec_step,

2445 tok::kw___builtin_omp_required_simd_align,

2446 tok::kw___builtin_vectorelements) &&

2447 "Not a typeof/sizeof/alignof/vec_step expression!");

2448

2450

2451

2452 if (Tok.isNot(tok::l_paren)) {

2453

2454

2455 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,

2456 tok::kw_alignof, tok::kw__Alignof)) {

2457 if (isTypeIdUnambiguously()) {

2459 ParseSpecifierQualifierList(DS);

2462 ParseDeclarator(DeclaratorInfo);

2463

2468 diag::err_expected_parentheses_around_typename)

2470 } else {

2471 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)

2474 }

2475 isCastExpr = true;

2477 }

2478 }

2479

2480 isCastExpr = false;

2481 if (OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&

2484 << tok::l_paren;

2486 }

2487

2488

2489

2490

2491

2492 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,

2493 tok::kw_alignof, tok::kw__Alignof) &&

2494 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,

2495 tok::kw_alignof, tok::kw__Alignof))

2497 Operand = ParseCastExpression(UnaryExprOnly);

2498 });

2499 else

2500 Operand = ParseCastExpression(UnaryExprOnly);

2501 } else {

2502

2503

2504

2505

2506 ParenParseOption ExprType = CastExpr;

2508

2509 Operand = ParseParenExpression(ExprType, true,

2510 false, CastTy, RParenLoc);

2511 CastRange = SourceRange(LParenLoc, RParenLoc);

2512

2513

2514

2516 isCastExpr = true;

2518 }

2519

2521 !OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {

2522

2523

2524

2525

2526 if (Operand.isInvalid())

2527 Operand = ParsePostfixExpressionSuffix(Operand.get());

2528 }

2529 }

2530

2531

2532 isCastExpr = false;

2534}

2535

2536

2537

2538ExprResult Parser::ParseSYCLUniqueStableNameExpression() {

2539 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&

2540 "Not __builtin_sycl_unique_stable_name");

2541

2544

2545

2546 if (T.expectAndConsume(diag::err_expected_lparen_after,

2547 "__builtin_sycl_unique_stable_name"))

2549

2551

2553 T.skipToEnd();

2555 }

2556

2557 if (T.consumeClose())

2559

2561 OpLoc, T.getOpenLocation(), T.getCloseLocation(), Ty.get());

2562}

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {

2579 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,

2580 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,

2581 tok::kw___builtin_omp_required_simd_align,

2582 tok::kw___builtin_vectorelements) &&

2583 "Not a sizeof/alignof/vec_step expression!");

2584 Token OpTok = Tok;

2586

2587

2588 if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {

2593 if (Tok.is(tok::l_paren)) {

2595 T.consumeOpen();

2596 LParenLoc = T.getOpenLocation();

2597 if (Tok.is(tok::identifier)) {

2600 T.consumeClose();

2601 RParenLoc = T.getCloseLocation();

2604 } else {

2605 Diag(Tok, diag::err_expected_parameter_pack);

2607 }

2608 } else if (Tok.is(tok::identifier)) {

2613 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)

2614 << Name

2617 } else {

2618 Diag(Tok, diag::err_sizeof_parameter_pack);

2619 }

2620

2621 if (!Name)

2623

2627

2630 *Name, NameLoc,

2631 RParenLoc);

2632 }

2633

2635 OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))

2636 Diag(OpTok, diag::warn_cxx98_compat_alignof);

2638 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.getName();

2639

2643

2644 bool isCastExpr;

2648 isCastExpr,

2649 CastTy,

2650 CastRange);

2651

2653 switch (OpTok.getKind()) {

2654 case tok::kw_alignof:

2655 case tok::kw__Alignof:

2656 ExprKind = UETT_AlignOf;

2657 break;

2658 case tok::kw___alignof:

2659 ExprKind = UETT_PreferredAlignOf;

2660 break;

2661 case tok::kw_vec_step:

2662 ExprKind = UETT_VecStep;

2663 break;

2664 case tok::kw___builtin_omp_required_simd_align:

2665 ExprKind = UETT_OpenMPRequiredSimdAlign;

2666 break;

2667 case tok::kw___datasizeof:

2668 ExprKind = UETT_DataSizeOf;

2669 break;

2670 case tok::kw___builtin_vectorelements:

2671 ExprKind = UETT_VectorElements;

2672 break;

2673 default:

2674 break;

2675 }

2676

2677 if (isCastExpr)

2679 ExprKind,

2680 true,

2682 CastRange);

2683

2684 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))

2686

2687

2688 if (Operand.isInvalid())

2690 ExprKind,

2691 false,

2693 CastRange);

2695}

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720ExprResult Parser::ParseBuiltinPrimaryExpression() {

2723

2726

2727

2728 if (Tok.isNot(tok::l_paren))

2729 return ExprError(Diag(Tok, diag::err_expected_after) << BuiltinII

2730 << tok::l_paren);

2731

2733 PT.consumeOpen();

2734

2735

2736

2737 switch (T) {

2738 default: llvm_unreachable("Not a builtin primary expression!");

2739 case tok::kw___builtin_va_arg: {

2741

2742 if (ExpectAndConsume(tok::comma)) {

2745 }

2746

2748

2749 if (Tok.isNot(tok::r_paren)) {

2750 Diag(Tok, diag::err_expected) << tok::r_paren;

2752 }

2753

2756 else

2757 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.get(), ConsumeParen());

2758 break;

2759 }

2760 case tok::kw___builtin_offsetof: {

2766 if (MacroName == "offsetof")

2768 }

2770 {

2776 }

2777 }

2778

2779 if (ExpectAndConsume(tok::comma)) {

2782 }

2783

2784

2785 if (Tok.isNot(tok::identifier)) {

2786 Diag(Tok, diag::err_expected) << tok::identifier;

2789 }

2790

2791

2793

2795 Comps.back().isBrackets = false;

2797 Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken();

2798

2799

2800 while (true) {

2801 if (Tok.is(tok::period)) {

2802

2804 Comps.back().isBrackets = false;

2806

2807 if (Tok.isNot(tok::identifier)) {

2808 Diag(Tok, diag::err_expected) << tok::identifier;

2811 }

2814 } else if (Tok.is(tok::l_square)) {

2815 if (CheckProhibitedCXX11Attribute())

2817

2818

2820 Comps.back().isBrackets = true;

2822 ST.consumeOpen();

2823 Comps.back().LocStart = ST.getOpenLocation();

2827 return Res;

2828 }

2829 Comps.back().U.E = Res.get();

2830

2831 ST.consumeClose();

2832 Comps.back().LocEnd = ST.getCloseLocation();

2833 } else {

2834 if (Tok.isNot(tok::r_paren)) {

2835 PT.consumeClose();

2839 } else {

2840 PT.consumeClose();

2842 Ty.get(), Comps,

2843 PT.getCloseLocation());

2844 }

2845 break;

2846 }

2847 }

2848 break;

2849 }

2850 case tok::kw___builtin_choose_expr: {

2852 if (Cond.isInvalid()) {

2854 return Cond;

2855 }

2856 if (ExpectAndConsume(tok::comma)) {

2859 }

2860

2862 if (Expr1.isInvalid()) {

2864 return Expr1;

2865 }

2866 if (ExpectAndConsume(tok::comma)) {

2869 }

2870

2872 if (Expr2.isInvalid()) {

2874 return Expr2;

2875 }

2876 if (Tok.isNot(tok::r_paren)) {

2877 Diag(Tok, diag::err_expected) << tok::r_paren;

2879 }

2880 Res = Actions.ActOnChooseExpr(StartLoc, Cond.get(), Expr1.get(),

2881 Expr2.get(), ConsumeParen());

2882 break;

2883 }

2884 case tok::kw___builtin_astype: {

2885

2887 if (Expr.isInvalid()) {

2890 }

2891

2892 if (ExpectAndConsume(tok::comma)) {

2895 }

2896

2897

2901

2902

2903 if (Tok.isNot(tok::r_paren)) {

2904 Diag(Tok, diag::err_expected) << tok::r_paren;

2907 }

2908

2910 ConsumeParen());

2911 break;

2912 }

2913 case tok::kw___builtin_convertvector: {

2914

2916 if (Expr.isInvalid()) {

2919 }

2920

2921 if (ExpectAndConsume(tok::comma)) {

2924 }

2925

2926

2930

2931

2932 if (Tok.isNot(tok::r_paren)) {

2933 Diag(Tok, diag::err_expected) << tok::r_paren;

2936 }

2937

2939 ConsumeParen());

2940 break;

2941 }

2942 case tok::kw___builtin_COLUMN:

2943 case tok::kw___builtin_FILE:

2944 case tok::kw___builtin_FILE_NAME:

2945 case tok::kw___builtin_FUNCTION:

2946 case tok::kw___builtin_FUNCSIG:

2947 case tok::kw___builtin_LINE:

2948 case tok::kw___builtin_source_location: {

2949

2950 if (Tok.isNot(tok::r_paren)) {

2951 Diag(Tok, diag::err_expected) << tok::r_paren;

2954 }

2956 switch (T) {

2957 case tok::kw___builtin_FILE:

2959 case tok::kw___builtin_FILE_NAME:

2961 case tok::kw___builtin_FUNCTION:

2963 case tok::kw___builtin_FUNCSIG:

2965 case tok::kw___builtin_LINE:

2967 case tok::kw___builtin_COLUMN:

2969 case tok::kw___builtin_source_location:

2971 default:

2972 llvm_unreachable("invalid keyword");

2973 }

2974 }();

2976 break;

2977 }

2978 }

2979

2982

2983

2984

2985 return ParsePostfixExpressionSuffix(Res.get());

2986}

2987

2988bool Parser::tryParseOpenMPArrayShapingCastPart() {

2989 assert(Tok.is(tok::l_square) && "Expected open bracket");

2990 bool ErrorFound = true;

2991 TentativeParsingAction TPA(*this);

2992 do {

2993 if (Tok.isNot(tok::l_square))

2994 break;

2995

2996 ConsumeBracket();

2997

2998 while (SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,

3000 ;

3001 if (Tok.isNot(tok::r_square))

3002 break;

3003

3004 ConsumeBracket();

3005

3006 if (Tok.is(tok::r_paren)) {

3007 ErrorFound = false;

3008 break;

3009 }

3010 } while (Tok.isNot(tok::annot_pragma_openmp_end));

3011 TPA.Revert();

3012 return !ErrorFound;

3013}

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3043Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,

3044 bool isTypeCast, ParsedType &CastTy,

3046 assert(Tok.is(tok::l_paren) && "Not a paren expr!");

3049 if (T.consumeOpen())

3052

3053 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);

3054

3056 bool isAmbiguousTypeId;

3057 CastTy = nullptr;

3058

3059 if (Tok.is(tok::code_completion)) {

3060 cutOffParsing();

3063 ExprType >= CompoundLiteral);

3065 }

3066

3067

3068 bool BridgeCast = (getLangOpts().ObjC &&

3069 Tok.isOneOf(tok::kw___bridge,

3070 tok::kw___bridge_transfer,

3071 tok::kw___bridge_retained,

3072 tok::kw___bridge_retain));

3073 if (BridgeCast && getLangOpts().ObjCAutoRefCount) {

3075 StringRef BridgeCastName = Tok.getName();

3078 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)

3079 << BridgeCastName

3081 }

3082 BridgeCast = false;

3083 }

3084

3085

3086

3087 if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {

3088 Diag(Tok, OpenLoc.isMacroID() ? diag::ext_gnu_statement_expr_macro

3089 : diag::ext_gnu_statement_expr);

3090

3091 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);

3092

3095 } else {

3096

3097

3098

3100 while (CodeDC->isRecord() || isa(CodeDC)) {

3103 "statement expr not in code context");

3104 }

3105 Sema::ContextRAII SavedContext(Actions, CodeDC, false);

3106

3108

3111

3112

3113 if (Stmt.isInvalid()) {

3116 } else {

3118 }

3119 }

3120 } else if (ExprType >= CompoundLiteral && BridgeCast) {

3123

3124

3126 if (tokenKind == tok::kw___bridge)

3128 else if (tokenKind == tok::kw___bridge_transfer)

3130 else if (tokenKind == tok::kw___bridge_retained)

3132 else {

3133

3134

3135 assert(tokenKind == tok::kw___bridge_retain);

3138 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)

3140 "__bridge_retained");

3141 }

3142

3144 T.consumeClose();

3145 ColonProtection.restore();

3146 RParenLoc = T.getCloseLocation();

3147

3148 PreferredType.enterTypeCast(Tok.getLocation(), Ty.get().get());

3149 ExprResult SubExpr = ParseCastExpression(AnyCastExpr);

3150

3153

3155 BridgeKeywordLoc, Ty.get(),

3156 RParenLoc, SubExpr.get());

3157 } else if (ExprType >= CompoundLiteral &&

3158 isTypeIdInParens(isAmbiguousTypeId)) {

3159

3160

3161

3162

3163

3164

3165

3166

3167 if (isAmbiguousTypeId && !stopIfCastExpr) {

3168 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,

3169 ColonProtection);

3170 RParenLoc = T.getCloseLocation();

3171 return res;

3172 }

3173

3174

3176 ParseSpecifierQualifierList(DS);

3179 ParseDeclarator(DeclaratorInfo);

3180

3181

3182

3183

3184 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&

3188 {

3191 }

3194 Ty.get(), nullptr);

3195 } else {

3196

3197 T.consumeClose();

3198 ColonProtection.restore();

3199 RParenLoc = T.getCloseLocation();

3200 if (Tok.is(tok::l_brace)) {

3201 ExprType = CompoundLiteral;

3203 {

3206 }

3207 return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);

3208 }

3209

3210 if (Tok.is(tok::l_paren)) {

3211

3213 {

3215 {

3218 }

3220 {

3222 }

3223 QualType QT = Ty.get().get().getCanonicalType();

3225 {

3226

3227

3228

3229

3230

3231 Result = ParseCastExpression(AnyCastExpr,

3232 false,

3234 true);

3235

3236 if (Result.isInvalid()) {

3238 DeclaratorInfo, CastTy,

3239 RParenLoc, Result.get());

3240 }

3241

3242

3243 if (Result.isInvalid()) {

3244 Result = ParsePostfixExpressionSuffix(Result);

3245 }

3246

3248 }

3249 }

3250 }

3251

3253

3254

3255 if (DeclaratorInfo.isInvalidType())

3257

3258

3259

3260 if (stopIfCastExpr) {

3262 {

3265 }

3266 CastTy = Ty.get();

3268 }

3269

3270

3274 GetLookAheadToken(1).isNot(tok::period)) {

3278 }

3279

3280 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.get());

3281

3282

3283 Result = ParseCastExpression(AnyCastExpr,

3284 false,

3286 if (Result.isInvalid()) {

3288 DeclaratorInfo, CastTy,

3289 RParenLoc, Result.get());

3290 }

3292 }

3293

3294 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);

3296 }

3297 } else if (ExprType >= FoldExpr && Tok.is(tok::ellipsis) &&

3299 ExprType = FoldExpr;

3300 return ParseFoldExpression(ExprResult(), T);

3301 } else if (isTypeCast) {

3302

3304 ExprVector ArgExprs;

3305

3306 if (!ParseSimpleExpressionList(ArgExprs)) {

3307

3308

3309 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&

3310 isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) {

3311 ExprType = FoldExpr;

3312 return ParseFoldExpression(ArgExprs[0], T);

3313 }

3314

3315 ExprType = SimpleExpr;

3317 ArgExprs);

3318 }

3319 } else if (getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&

3320 ExprType == CastExpr && Tok.is(tok::l_square) &&

3321 tryParseOpenMPArrayShapingCastPart()) {

3322 bool ErrorFound = false;

3325 do {

3327 TS.consumeOpen();

3330 if (!NumElements.isUsable()) {

3331 ErrorFound = true;

3332 while (SkipUntil(tok::r_square, tok::r_paren,

3334 ;

3335 }

3336 TS.consumeClose();

3337 OMPDimensions.push_back(NumElements.get());

3338 OMPBracketsRanges.push_back(TS.getRange());

3339 } while (Tok.isNot(tok::r_paren));

3340

3341 T.consumeClose();

3342 RParenLoc = T.getCloseLocation();

3344 if (ErrorFound) {

3346 } else if (Result.isInvalid()) {

3348 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);

3349 }

3351 } else {

3353

3356

3357

3359 }

3360

3361 if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) &&

3362 NextToken().is(tok::ellipsis)) {

3363 ExprType = FoldExpr;

3364 return ParseFoldExpression(Result, T);

3365 }

3366 ExprType = SimpleExpr;

3367

3368

3369 if (Result.isInvalid() && Tok.is(tok::r_paren))

3372 }

3373

3374

3375 if (Result.isInvalid()) {

3378 }

3379

3380 T.consumeClose();

3381 RParenLoc = T.getCloseLocation();

3383}

3384

3385

3386

3387

3388

3389

3390

3391

3392

3394Parser::ParseCompoundLiteralExpression(ParsedType Ty,

3397 assert(Tok.is(tok::l_brace) && "Not a compound literal!");

3398 if (getLangOpts().C99)

3399 Diag(LParenLoc, diag::ext_c99_compound_literal);

3400 PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());

3402 if (Result.isInvalid() && Ty)

3405}

3406

3407

3408

3409

3410

3411

3412

3413

3414

3417 false);

3418}

3419

3422 true);

3423}

3424

3428 "Not a string-literal-like token!");

3429

3430

3431

3432

3434

3435 do {

3436 StringToks.push_back(Tok);

3439

3441 assert(!AllowUserDefinedLiteral && "UDL are always evaluated");

3443 }

3444

3445

3448 : nullptr);

3449}

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470ExprResult Parser::ParseGenericSelectionExpression() {

3471 assert(Tok.is(tok::kw__Generic) && "_Generic keyword expected");

3472

3473 diagnoseUseOfC11Keyword(Tok);

3474

3477 if (T.expectAndConsume())

3479

3480

3481

3484 if (isTypeIdForGenericSelection()) {

3486 if (ControllingType.isInvalid()) {

3489 }

3490 const auto *LIT = cast(ControllingType.get().get());

3491 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();

3493 : diag::ext_c2y_generic_with_type_arg);

3494 } else {

3495

3496

3499 ControllingExpr =

3501 if (ControllingExpr.isInvalid()) {

3504 }

3505 }

3506

3507 if (ExpectAndConsume(tok::comma)) {

3510 }

3511

3514 ExprVector Exprs;

3515 do {

3517 if (Tok.is(tok::kw_default)) {

3518

3519

3521 Diag(Tok, diag::err_duplicate_default_assoc);

3522 Diag(DefaultLoc, diag::note_previous_default_assoc);

3525 }

3527 Ty = nullptr;

3528 } else {

3534 }

3535 Ty = TR.get();

3536 }

3537 Types.push_back(Ty);

3538

3539 if (ExpectAndConsume(tok::colon)) {

3542 }

3543

3544

3545

3548 if (ER.isInvalid()) {

3551 }

3552 Exprs.push_back(ER.get());

3554

3555 T.consumeClose();

3556 if (T.getCloseLocation().isInvalid())

3558

3559 void *ExprOrTy = ControllingExpr.isUsable()

3560 ? ControllingExpr.get()

3561 : ControllingType.get().getAsOpaquePtr();

3562

3564 KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.isUsable(),

3565 ExprOrTy, Types, Exprs);

3566}

3567

3568

3569

3570

3571

3572

3573

3574

3575

3579 T.skipToEnd();

3580 return true;

3581 }

3582

3587 assert(isFoldOperator(Kind) && "missing fold-operator");

3589 }

3590

3591 assert(Tok.is(tok::ellipsis) && "not a fold-expression");

3593

3595 if (Tok.isNot(tok::r_paren)) {

3596 if (!isFoldOperator(Tok.getKind()))

3597 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);

3598

3599 if (Kind != tok::unknown && Tok.getKind() != Kind)

3600 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)

3604

3607 T.skipToEnd();

3608 return true;

3609 }

3610 }

3611

3613 ? diag::warn_cxx14_compat_fold_expression

3614 : diag::ext_fold_expression);

3615

3616 T.consumeClose();

3618 Kind, EllipsisLoc, RHS.get(),

3619 T.getCloseLocation());

3620}

3621

3622void Parser::injectEmbedTokens() {

3626 Data->BinaryData.size() * 2 - 1),

3627 Data->BinaryData.size() * 2 - 1);

3628 unsigned I = 0;

3629 for (auto &Byte : Data->BinaryData) {

3630 Toks[I].startToken();

3631 Toks[I].setKind(tok::binary_data);

3633 Toks[I].setLength(1);

3634 Toks[I].setLiteralData(&Byte);

3635 if (I != ((Data->BinaryData.size() - 1) * 2)) {

3636 Toks[I + 1].startToken();

3637 Toks[I + 1].setKind(tok::comma);

3638 Toks[I + 1].setLocation(Tok.getLocation());

3639 }

3640 I += 2;

3641 }

3642 PP.EnterTokenStream(std::move(Toks), true,

3643 true);

3645}

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3670 llvm::function_ref<void()> ExpressionStarts,

3671 bool FailImmediatelyOnInvalidExpr,

3672 bool EarlyTypoCorrection,

3673 bool *HasTrailingComma) {

3674 bool SawError = false;

3675 while (true) {

3676 if (ExpressionStarts)

3677 ExpressionStarts();

3678

3681 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);

3682 Expr = ParseBraceInitializer();

3683 } else

3685

3686 if (EarlyTypoCorrection)

3688

3689 if (Tok.is(tok::ellipsis))

3691 else if (Tok.is(tok::code_completion)) {

3692

3693

3694

3695

3696

3697 SawError = true;

3698 cutOffParsing();

3699 break;

3700 }

3701 if (Expr.isInvalid()) {

3702 SawError = true;

3703 if (FailImmediatelyOnInvalidExpr)

3704 break;

3706 } else {

3707 Exprs.push_back(Expr.get());

3708 }

3709

3710 if (Tok.isNot(tok::comma))

3711 break;

3712

3715 checkPotentialAngleBracketDelimiter(Comma);

3716

3717 if (Tok.is(tok::r_paren)) {

3718 if (HasTrailingComma)

3719 *HasTrailingComma = true;

3720 break;

3721 }

3722 }

3723 if (SawError) {

3724

3725

3726 for (auto &E : Exprs) {

3728 if (Expr.isUsable()) E = Expr.get();

3729 }

3730 }

3731 return SawError;

3732}

3733

3734

3735

3736

3737

3738

3739

3740

3741

3743 while (true) {

3745 if (Expr.isInvalid())

3746 return true;

3747

3748 Exprs.push_back(Expr.get());

3749

3750

3751

3752 if (Tok.isNot(tok::comma) || NextToken().is(tok::ellipsis))

3753 return false;

3754

3755

3758 checkPotentialAngleBracketDelimiter(Comma);

3759 }

3760}

3761

3762

3763

3764

3765

3766

3767

3769 if (Tok.is(tok::code_completion)) {

3770 cutOffParsing();

3773 return;

3774 }

3775

3776

3778 ParseSpecifierQualifierList(DS);

3779

3780

3784 ParseDeclarator(DeclaratorInfo);

3785

3786 MaybeParseGNUAttributes(DeclaratorInfo);

3787

3788

3790}

3791

3792

3793

3794

3795

3796

3797

3798

3799

3800

3801

3802ExprResult Parser::ParseBlockLiteralExpression() {

3803 assert(Tok.is(tok::caret) && "block literal starts with ^");

3805

3807 "block literal parsing");

3808

3809

3810

3811

3812

3815

3816

3818

3819

3824

3825

3827

3828

3829

3830 if (Tok.is(tok::l_paren)) {

3831 ParseParenDeclarator(ParamInfo);

3832

3833

3834

3835 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();

3836 ParamInfo.SetIdentifier(nullptr, CaretLoc);

3837 ParamInfo.SetRangeEnd(Tmp);

3838 if (ParamInfo.isInvalidType()) {

3839

3840

3841

3844 }

3845

3846 MaybeParseGNUAttributes(ParamInfo);

3847

3848

3850 } else if (!Tok.is(tok::l_brace)) {

3851 ParseBlockId(CaretLoc);

3852 } else {

3853

3855 ParamInfo.AddTypeInfo(

3857 false,

3858 NoLoc,

3859 nullptr,

3860 0,

3861 NoLoc,

3862 NoLoc,

3863 true,

3864 NoLoc,

3865 NoLoc, EST_None,

3867 nullptr,

3868 nullptr,

3869 0,

3870 nullptr,

3871 nullptr,

3872 {}, CaretLoc,

3873 CaretLoc, ParamInfo),

3874 CaretLoc);

3875

3876 MaybeParseGNUAttributes(ParamInfo);

3877

3878

3880 }

3881

3882

3884 if (!Tok.is(tok::l_brace)) {

3885

3886 Diag(Tok, diag::err_expected_expression);

3889 }

3890

3892 BlockScope.Exit();

3893 if (Stmt.isInvalid())

3895 else

3898}

3899

3900

3901

3902

3903

3904ExprResult Parser::ParseObjCBoolLiteral() {

3907}

3908

3909

3910

3913 llvm::SmallSet<StringRef, 4> Platforms;

3914 bool HasOtherPlatformSpec = false;

3915 bool Valid = true;

3916 for (const auto &Spec : AvailSpecs) {

3917 if (Spec.isOtherPlatformSpec()) {

3918 if (HasOtherPlatformSpec) {

3919 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);

3920 Valid = false;

3921 }

3922

3923 HasOtherPlatformSpec = true;

3924 continue;

3925 }

3926

3927 bool Inserted = Platforms.insert(Spec.getPlatform()).second;

3928 if (!Inserted) {

3929

3930

3931

3932 StringRef Platform = Spec.getPlatform();

3933 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)

3934 << Spec.getEndLoc() << Platform;

3935 Valid = false;

3936 }

3937 }

3938

3939 if (!HasOtherPlatformSpec) {

3940 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();

3941 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)

3943 return true;

3944 }

3945

3946 return !Valid;

3947}

3948

3949

3950

3951

3952

3953

3954std::optional Parser::ParseAvailabilitySpec() {

3955 if (Tok.is(tok::star)) {

3957 } else {

3958

3959 if (Tok.is(tok::code_completion)) {

3960 cutOffParsing();

3962 return std::nullopt;

3963 }

3964 if (Tok.isNot(tok::identifier)) {

3965 Diag(Tok, diag::err_avail_query_expected_platform_name);

3966 return std::nullopt;

3967 }

3968

3969 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();

3971 VersionTuple Version = ParseVersionTuple(VersionRange);

3972

3973 if (Version.empty())

3974 return std::nullopt;

3975

3976 StringRef GivenPlatform = PlatformIdentifier->Ident->getName();

3977 StringRef Platform =

3978 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);

3979

3980 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||

3981 (GivenPlatform.contains("xros") || GivenPlatform.contains("xrOS"))) {

3982 Diag(PlatformIdentifier->Loc,

3983 diag::err_avail_query_unrecognized_platform_name)

3984 << GivenPlatform;

3985 return std::nullopt;

3986 }

3987

3989 VersionRange.getEnd());

3990 }

3991}

3992

3994 assert(Tok.is(tok::kw___builtin_available) ||

3996

3997

3999

4001 if (Parens.expectAndConsume())

4003

4005 bool HasError = false;

4006 while (true) {

4007 std::optional Spec = ParseAvailabilitySpec();

4008 if (!Spec)

4009 HasError = true;

4010 else

4011 AvailSpecs.push_back(*Spec);

4012

4014 break;

4015 }

4016

4017 if (HasError) {

4020 }

4021

4023

4024 if (Parens.consumeClose())

4026

4028 AvailSpecs, BeginLoc, Parens.getCloseLocation());

4029}

Defines the clang::ASTContext interface.

static Decl::Kind getKind(const Decl *D)

Defines the clang::Expr interface and subclasses for C++ expressions.

static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)

Validate availability spec list, emitting diagnostics if necessary.

#define REVERTIBLE_TYPE_TRAIT(Name)

Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...

This file declares semantic analysis for CUDA constructs.

This file declares facilities that support code completion.

This file declares semantic analysis for Objective-C.

This file declares semantic analysis for OpenACC constructs and clauses.

This file declares semantic analysis for OpenMP constructs and clauses.

This file declares semantic analysis for SYCL constructs.

const clang::PrintingPolicy & getPrintingPolicy() const

One specifier in an @available expression.

RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....

Represents a C++ nested-name-specifier or a global scope specifier.

bool isNotEmpty() const

A scope specifier is present, but may be valid or invalid.

CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...

ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.

CompoundStmt - This represents a group of statements like { stmt stmt }.

Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...

virtual bool ValidateCandidate(const TypoCorrection &candidate)

Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

DeclContext * getParent()

getParent - Returns the containing DeclContext.

bool isFileContext() const

Captures information about "declaration specifiers".

Information about one declarator, including the parsed type information and the identifier.

RAII object that enters a new expression evaluation context.

This represents one expression.

bool containsErrors() const

Whether this expression contains subexpressions which had errors, e.g.

SourceLocation getExprLoc() const LLVM_READONLY

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...

ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.

static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)

Create a code modification hint that replaces the given source range with the given code string.

static FixItHint CreateRemoval(CharSourceRange RemoveRange)

Create a code modification hint that removes the given source range.

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.

One of these records is kept for each identifier that is lexed.

bool hasRevertedTokenIDToIdentifier() const

True if revertTokenIDToIdentifier() was called.

StringRef getName() const

Return the actual identifier string.

Represents the declaration of a label.

static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)

Retrieve the name of the immediate macro expansion.

This represents a decl that may have a name.

void * getAsOpaquePtr() const

static const ParsedAttributesView & none()

Parser - This implements a parser for the C family of languages.

TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)

ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].

DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)

SourceLocation ConsumeToken()

ConsumeToken - Consume the current 'peek token' and lex the next one.

Sema & getActions() const

static TypeResult getTypeAnnotation(const Token &Tok)

getTypeAnnotation - Read a parsed type out of an annotation token.

ExprResult ParseCaseExpression(SourceLocation CaseLoc)

ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)

Parse a constraint-logical-or-expression.

bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)

Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.

SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)

ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.

ExprResult ParseConstantExpression()

ExprResult ParseConditionalExpression()

bool TryConsumeToken(tok::TokenKind Expected)

Scope * getCurScope() const

ExprResult ParseArrayBoundExpression()

ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)

Parse a constraint-logical-and-expression.

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 ...

ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)

Parse an expr that doesn't include (top-level) commas.

ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)

const LangOptions & getLangOpts() const

ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)

Simple precedence-based parser for binary/ternary operators.

@ StopBeforeMatch

Stop skipping at specified token, but don't skip the token itself.

@ StopAtSemi

Stop skipping at semicolon.

bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)

TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...

TypeCastState

TypeCastState - State whether an expression is or may be a type cast.

ExprResult ParseUnevaluatedStringLiteralExpression()

ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)

const Token & NextToken()

NextToken - This peeks ahead one token and returns it without consuming it.

ExprResult ParseConstraintExpression()

Parse a constraint-expression.

void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)

void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)

void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)

QualType get(SourceLocation Tok) const

Get the expected type associated with this location, if any.

void EnterToken(const Token &Tok, bool IsReinject)

Enters a token in the token stream to be lexed next.

SourceManager & getSourceManager() const

llvm::BumpPtrAllocator & getPreprocessorAllocator()

StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const

Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...

bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const

Returns true if the given MacroID location points at the first token of the macro expansion.

bool isCodeCompletionReached() const

Returns true if code-completion is enabled and we have hit the code-completion point.

SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)

Computes the source location just past the end of the token at this source location.

If a crash happens while one of these objects are live, the message is printed out along with the spe...

A (possibly-)qualified type.

bool isNull() const

Return true if this QualType doesn't point to a type yet.

@ BlockScope

This is a scope that corresponds to a block/closure object.

@ CompoundStmtScope

This is a compound statement scope.

@ FnScope

This indicates that the scope corresponds to a function, which means that labels are set here.

@ DeclScope

This is a scope that can contain a declaration.

ExprResult ActOnExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)

@ PCC_Type

Code completion occurs where only a type is permitted.

void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)

Perform code-completion in an expression context when we know what type we're looking for.

QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)

Determines the preferred type of the current function argument, by examining the signatures of all po...

void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)

void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)

void CodeCompleteAvailabilityPlatformName()

void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)

void CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)

ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)

ExprResult ActOnClassPropertyRefExpr(const IdentifierInfo &receiverName, const IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)

ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc, bool Value)

ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)

ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)

Checks and creates an Array Section used in an OpenACC construct/clause.

ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)

ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)

ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, ParsedType ParsedTy)

RAII class used to indicate that we are performing provisional semantic analysis to determine the val...

ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)

Unary Operators. 'Tok' is the token for the operator.

ExprResult ActOnConstantExpression(ExprResult Res)

ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)

ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)

void ActOnStartStmtExpr()

void ActOnStmtExprError()

ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)

ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)

ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)

ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)

ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)

ActOnCXXNullPtrLiteral - Parse 'nullptr'.

bool CheckConstraintExpression(const Expr *CE, Token NextToken=Token(), bool *PossibleNonPrimary=nullptr, bool IsTrailingRequiresClause=false)

Check whether the given expression is a valid constraint expression.

ASTContext & getASTContext() const

ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)

ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".

ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)

ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)

ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)

SourceRange getExprRange(Expr *E) const

SemaCodeCompletion & CodeCompletion()

ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)

ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)

The main callback when the parser finds something like expression .

ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)

ControllingExprOrType is either an opaque pointer coming out of a ParsedType or an Expr *.

void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)

ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...

DeclContext * CurContext

CurContext - This is the current declaration context of parsing.

ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)

ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)

ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)

ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)

ActOnConditionalOp - Parse a ?: operation.

LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())

LookupOrCreateLabel - Do a name lookup of a label with the specified name.

TypeResult ActOnTypeName(Declarator &D)

ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)

Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.

ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)

ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....

ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)

Binary Operators. 'Tok' is the token for the operator.

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, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)

If the identifier refers to a type name within this scope, return the declaration of that type.

ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)

@ ConstantEvaluated

The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...

@ Unevaluated

The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...

ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)

Parse a __builtin_astype expression.

ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)

ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)

SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts

A stack of expression evaluation contexts.

ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)

Called when an expression computing the size of a parameter pack is parsed.

ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)

ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)

Handle a C++1z fold-expression: ( expr op ... op expr ).

ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)

ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...

void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)

Run some code with "sufficient" stack space.

ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)

ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())

Attempts to produce a RecoveryExpr after some AST node cannot be created.

ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)

void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)

ActOnBlockStart - This callback is invoked when a block literal is started.

ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)

ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)

ActOnCallExpr - Handle a call to Fn with the specified array of arguments.

ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)

ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...

void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)

ActOnBlockArguments - This callback allows processing of block arguments.

ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)

ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.

ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)

ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, 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...

ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)

Act on the result of classifying a name as an overload set.

Encodes a location in the source.

bool isValid() const

Return true if this is a valid SourceLocation object.

SourceLocation getLocWithOffset(IntTy Offset) const

Return a source location with the specified offset from this SourceLocation.

This class handles loading and caching of source files into memory.

bool isInSystemHeader(SourceLocation Loc) const

Returns if a SourceLocation is in a system header.

A trivial tuple used to represent a source range.

SourceLocation getEnd() const

SourceLocation getBegin() const

Stmt - This represents one statement.

SourceLocation getEndLoc() const LLVM_READONLY

SourceRange getSourceRange() const LLVM_READONLY

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...

SourceLocation getBeginLoc() const LLVM_READONLY

Token - This structure provides full information about a lexed token.

IdentifierInfo * getIdentifierInfo() const

SourceLocation getLocation() const

Return a source location identifier for the specified offset in the current file.

const char * getName() const

void setKind(tok::TokenKind K)

SourceLocation getAnnotationEndLoc() 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)) {....

void * getAnnotationValue() const

tok::TokenKind getKind() const

bool isAtStartOfLine() const

isAtStartOfLine - Return true if this token is at the start of a line.

bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const

bool isNot(tok::TokenKind K) const

bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const

Return true if we have an ObjC keyword identifier.

bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const

Determine whether the token kind starts a simple-type-specifier.

SourceLocation getLastLoc() const

Base wrapper for a particular "section" of type source info.

The base class of the type hierarchy.

bool isSpecificPlaceholderType(unsigned K) const

Test for a specific placeholder type.

bool isFunctionType() const

bool isVectorType() const

Simple class containing the result of Sema::CorrectTypo.

NamedDecl * getCorrectionDecl() const

Gets the pointer to the declaration of the typo correction.

Represents a C++ unqualified-id that has been parsed.

TokenKind

Provides a simple uniform namespace for tokens from all C languages.

The JSON file list parser is used to communicate input to InstallAPI.

bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)

Return true if the token is a string literal, or a function local predefined macro,...

UnaryExprOrTypeTrait

Names for the "expression or type" traits.

@ Result

The result type of a method or function.

ObjCBridgeCastKind

The kind of bridging performed by the Objective-C bridge cast.

@ OBC_Bridge

Bridging via __bridge, which does nothing but reinterpret the bits.

@ OBC_BridgeTransfer

Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC.

@ OBC_BridgeRetained

Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.

ActionResult< Expr * > ExprResult

prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)

Return the precedence of the specified binary operator token.

@ TNK_Type_template

The name refers to a template whose specialization produces a type.

const FunctionProtoType * T

@ Parens

New-expression has a C++98 paren-delimited initializer.

@ EST_None

no exception specification

static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)

DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.

Helper class to shuttle information about #embed directives from the preprocessor to the parser throu...

Wraps an identifier and optional source location for the identifier.

Information about a template-id annotation token.

TemplateNameKind Kind

The kind of template that Template refers to.