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
49 return ParseRHSOfBinaryExpression(LHS, prec::Comma);
50}
51
53Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
54 ExprResult LHS(ParseObjCAtExpression(AtLoc));
55 return ParseRHSOfBinaryExpression(LHS, prec::Comma);
56}
57
59Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
61 {
62
64
66 }
67
68 if (!LHS.isInvalid())
69 LHS = Actions.ActOnUnaryOp(getCurScope(), ExtLoc, tok::kw___extension__,
70 LHS.get());
71
72 return ParseRHSOfBinaryExpression(LHS, prec::Comma);
73}
74
77 if (Tok.is(tok::code_completion)) {
78 cutOffParsing();
79 Actions.CodeCompletion().CodeCompleteExpression(
80 getCurScope(), PreferredType.get(Tok.getLocation()));
82 }
83
84 if (Tok.is(tok::kw_throw))
85 return ParseThrowExpression();
86 if (Tok.is(tok::kw_co_yield))
87 return ParseCoyieldExpression();
88
91 false, CorrectionBehavior);
93}
94
96 if (Tok.is(tok::code_completion)) {
97 cutOffParsing();
98 Actions.CodeCompletion().CodeCompleteExpression(
99 getCurScope(), PreferredType.get(Tok.getLocation()));
101 }
102
103 ExprResult LHS = ParseCastExpression(
107}
108
110Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
113 Expr *ReceiverExpr) {
115 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
116 ReceiverType, ReceiverExpr);
117 R = ParsePostfixExpressionSuffix(R);
119}
120
123 assert(Actions.ExprEvalContexts.back().Context ==
125 "Call this function only if your ExpressionEvaluationContext is "
126 "already ConstantEvaluated");
128 CorrectionBehavior));
130 return Actions.ActOnConstantExpression(Res);
131}
132
143
147
148
149 Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
150
151
152
153
154
155
156
157
158
159
160
161
162
163 for (auto Iter = Actions.ExprEvalContexts.rbegin() + 1;
164 Iter != Actions.ExprEvalContexts.rend(); ++Iter) {
165 if (!Iter->isUnevaluated())
166 break;
167 Iter->InConditionallyConstantEvaluateContext = true;
168 }
171}
172
176 Actions.currentEvaluationContext().IsCaseExpr = true;
177
182 return Actions.ActOnCaseExpr(CaseLoc, Res);
183}
184
190 if (Res.isUsable() && !Actions.CheckConstraintExpression(Res.get())) {
192 }
193 return Res;
194}
195
200 bool NotPrimaryExpression = false;
201 auto ParsePrimary = [&]() {
205 false, &NotPrimaryExpression);
208 auto RecoverFromNonPrimary = [&] (ExprResult E, bool Note) {
209 E = ParsePostfixExpressionSuffix(E);
210
211
216 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
217 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
220 PP.getLocForEndOfToken(E.get()->getEndLoc()), ")")
222 return E;
223 };
224
225 if (NotPrimaryExpression ||
226
227
230
231
232 Tok.isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
233 (Tok.is(tok::l_square) && ().is(tok::l_square))) {
234 E = RecoverFromNonPrimary(E, false);
237 NotPrimaryExpression = false;
238 }
239 bool PossibleNonPrimary;
240 bool IsConstraintExpr =
241 Actions.CheckConstraintExpression(E.get(), Tok, &PossibleNonPrimary,
242 IsTrailingRequiresClause);
243 if (!IsConstraintExpr || PossibleNonPrimary) {
244
245
246
247
248 if (PossibleNonPrimary)
249 E = RecoverFromNonPrimary(E, !IsConstraintExpr);
251 }
252 return E;
253 };
257 while (Tok.is(tok::ampamp)) {
262 }
264 tok::ampamp, LHS.get(), RHS.get());
267 }
268 LHS = Op;
269 }
270 return LHS;
271}
272
278 while (Tok.is(tok::pipepipe)) {
284 }
286 tok::pipepipe, LHS.get(), RHS.get());
289 }
290 LHS = Op;
291 }
292 return LHS;
293}
294
295bool Parser::isNotExpressionStart() {
297 if (K == tok::l_brace || K == tok::r_brace ||
298 K == tok::kw_for || K == tok::kw_while ||
299 K == tok::kw_if || K == tok::kw_else ||
300 K == tok::kw_goto || K == tok::kw_try)
301 return true;
302
303 return isKnownToBeDeclarationSpecifier();
304}
305
306bool Parser::isFoldOperator(prec::Level Level) const {
309}
310
311bool Parser::isFoldOperator(tok::TokenKind Kind) const {
312 return isFoldOperator(getBinOpPrecedence(Kind, GreaterThanIsOperator, true));
313}
314
318 GreaterThanIsOperator,
320 SourceLocation ColonLoc;
321
322 auto SavedType = PreferredType;
323 while (true) {
324
325 PreferredType = SavedType;
326
327
328
329 if (NextTokPrec < MinPrec)
330 return LHS;
331
332
333 Token OpToken = Tok;
335
336
337
338 if (OpToken.isOneOf(tok::comma, tok::greater, tok::greatergreater,
339 tok::greatergreatergreater) &&
340 checkPotentialAngleBracketDelimiter(OpToken))
342
343
344
345
346
347
348 if (OpToken.is(tok::comma) && isNotExpressionStart()) {
349 PP.EnterToken(Tok, true);
350 Tok = OpToken;
351 return LHS;
352 }
353
354
355
356 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {
357
358
359 PP.EnterToken(Tok, true);
360 Tok = OpToken;
361 return LHS;
362 }
363
364
365
366
367
368
370 Tok.isOneOf(tok::colon, tok::r_square) &&
372 PP.EnterToken(Tok, true);
373 Tok = OpToken;
374 return LHS;
375 }
376
377
381
382 SourceLocation BraceLoc = Tok.getLocation();
383 TernaryMiddle = ParseBraceInitializer();
384 if (!TernaryMiddle.isInvalid()) {
385 Diag(BraceLoc, diag::err_init_list_bin_op)
386 << 1 << PP.getSpelling(OpToken)
387 << Actions.getExprRange(TernaryMiddle.get());
389 }
390 } else if (Tok.isNot(tok::colon)) {
391
393
394
395
396
397
399 } else {
400
401
402 TernaryMiddle = nullptr;
403 Diag(Tok, diag::ext_gnu_conditional_expr);
404 }
405
406 if (TernaryMiddle.isInvalid()) {
408 TernaryMiddle = nullptr;
409 }
410
412
413
414
415
416 SourceLocation FILoc = Tok.getLocation();
417 const char *FIText = ": ";
418 const SourceManager &SM = PP.getSourceManager();
419 if (FILoc.isFileID() || PP.isAtStartOfMacroExpansion(FILoc, &FILoc)) {
421 bool IsInvalid = false;
422 const char *SourcePtr =
424 if (!IsInvalid && *SourcePtr == ' ') {
425 SourcePtr =
427 if (!IsInvalid && *SourcePtr == ' ') {
429 FIText = ":";
430 }
431 }
432 }
433
434 Diag(Tok, diag::err_expected)
436 Diag(OpToken, diag::note_matching) << tok::question;
437 ColonLoc = Tok.getLocation();
438 }
439 }
440
441 PreferredType.enterBinary(Actions, Tok.getLocation(), LHS.get(),
443
444
445
446
447
448
449
450
451
452
454 bool RHSIsInitList = false;
456 RHS = ParseBraceInitializer();
457 RHSIsInitList = true;
460 else
462
465 }
466
467
468
470 NextTokPrec = getBinOpPrecedence(Tok.getKind(), GreaterThanIsOperator,
472
473
476
477
478
479 if (ThisPrec < NextTokPrec ||
480 (ThisPrec == NextTokPrec && isRightAssoc)) {
481 if (!RHS.isInvalid() && RHSIsInitList) {
482 Diag(Tok, diag::err_init_list_bin_op)
483 << 0 << PP.getSpelling(Tok) << Actions.getExprRange(RHS.get());
485 }
486
487
488
489
490
491 RHS = ParseRHSOfBinaryExpression(RHS,
492 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
493 RHSIsInitList = false;
494
497 }
498
499 NextTokPrec = getBinOpPrecedence(Tok.getKind(), GreaterThanIsOperator,
501 }
502
503 if (!RHS.isInvalid() && RHSIsInitList) {
505 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
506 << Actions.getExprRange(RHS.get());
507 } else if (ColonLoc.isValid()) {
508 Diag(ColonLoc, diag::err_init_list_bin_op)
509 << 1 << ":"
510 << Actions.getExprRange(RHS.get());
512 } else {
513 Diag(OpToken, diag::err_init_list_bin_op)
514 << 1 << PP.getSpelling(OpToken)
515 << Actions.getExprRange(RHS.get());
517 }
518 }
519
521
522 if (TernaryMiddle.isInvalid()) {
523
524
525
526 if (!GreaterThanIsOperator && OpToken.is(tok::greatergreater))
527 SuggestParentheses(OpToken.getLocation(),
528 diag::warn_cxx11_right_shift_in_template_arg,
529 SourceRange(Actions.getExprRange(LHS.get()).getBegin(),
530 Actions.getExprRange(RHS.get()).getEnd()));
531
536 BinOp = Actions.CreateRecoveryExpr(LHS.get()->getBeginLoc(),
538 {LHS.get(), RHS.get()});
539
540 LHS = BinOp;
541 } else {
542 ExprResult CondOp = Actions.ActOnConditionalOp(
543 OpToken.getLocation(), ColonLoc, LHS.get(), TernaryMiddle.get(),
544 RHS.get());
546 std::vector<clang::Expr *> Args;
547
548 if (TernaryMiddle.get())
549 Args = {LHS.get(), TernaryMiddle.get(), RHS.get()};
550 else
551 Args = {LHS.get(), RHS.get()};
552 CondOp = Actions.CreateRecoveryExpr(LHS.get()->getBeginLoc(),
554 }
555
556 LHS = CondOp;
557 }
558 }
559 }
560}
561
563Parser::ParseCastExpression(CastParseKind ParseKind, bool isAddressOfOperand,
565 bool isVectorLiteral, bool *NotPrimaryExpression) {
566 bool NotCastExpr;
567 ExprResult Res = ParseCastExpression(ParseKind, isAddressOfOperand,
568 NotCastExpr, CorrectionBehavior,
569 isVectorLiteral, NotPrimaryExpression);
570 if (NotCastExpr)
571 Diag(Tok, diag::err_expected_expression);
572 return Res;
573}
574
575namespace {
577public:
578 CastExpressionIdValidator(Token Next,
580 : NextToken(Next) {
581 WantTypeSpecifiers = WantFunctionLikeCasts =
582 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowNonTypes);
584 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowTypes);
585 }
586
587 bool ValidateCandidate(const TypoCorrection &candidate) override {
589 if (!ND)
591
593 return WantTypeSpecifiers;
594
596 return false;
597
598 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
599 return true;
600
601 for (auto *C : candidate) {
604 return true;
605 }
606 return false;
607 }
608
609 std::unique_ptr clone() override {
610 return std::make_unique(*this);
611 }
612
613 private:
614 Token NextToken;
616};
617}
618
619bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
621 if (RevertibleTypeTraits.empty()) {
622
623
624
625#define RTT_JOIN(X, Y) X##Y
626#define REVERTIBLE_TYPE_TRAIT(Name) \
627 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
628
684#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
685 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
686#include "clang/Basic/TransformTypeTraits.def"
687#undef REVERTIBLE_TYPE_TRAIT
688#undef RTT_JOIN
689 }
690 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
691 RevertibleTypeTraits.find(II);
692 if (Known != RevertibleTypeTraits.end()) {
693 if (Kind)
694 *Kind = Known->second;
695 return true;
696 }
697 return false;
698}
699
700ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
702
704 if (T.expectAndConsume())
706
711 }
712
713 SourceLocation EndLoc = Tok.getLocation();
714 T.consumeClose();
715 return Actions.ActOnUnaryExprOrTypeTraitExpr(
716 Loc, UETT_PtrAuthTypeDiscriminator,
717 true, Ty.get().getAsOpaquePtr(), SourceRange(Loc, EndLoc));
718}
719
721Parser::ParseCastExpression(CastParseKind ParseKind, bool isAddressOfOperand,
722 bool &NotCastExpr,
724 bool isVectorLiteral, bool *NotPrimaryExpression) {
727 auto SavedType = PreferredType;
728 NotCastExpr = false;
729
730
731
732
733 bool AllowSuffix = true;
734
735
736
737
738
739
740
741
742
743
744
745 switch (SavedKind) {
746 case tok::l_paren: {
747
748
750 switch (ParseKind) {
753 [[fallthrough]];
756 break;
759 break;
760 }
762 SourceLocation RParenLoc;
763 Res = ParseParenExpression(ParenExprType, false,
765 CastTy, RParenLoc);
766
767
768
769
770 if (isVectorLiteral)
771 return Res;
772
773 switch (ParenExprType) {
775 break;
777 break;
779
780
781 break;
783
784
785 return Res;
787
788
789 break;
790 }
791
792 break;
793 }
794
795
796 case tok::numeric_constant:
797 case tok::binary_data:
798
799
800
801 Res = Actions.ActOnNumericConstant(Tok, getCurScope());
803 break;
804
805 case tok::kw_true:
806 case tok::kw_false:
807 Res = ParseCXXBoolLiteral();
808 break;
809
810 case tok::kw___objc_yes:
811 case tok::kw___objc_no:
812 Res = ParseObjCBoolLiteral();
813 break;
814
815 case tok::kw_nullptr:
817 Diag(Tok, diag::warn_cxx98_compat_nullptr);
818 else
820 : diag::ext_c_nullptr) << Tok.getName();
821
822 Res = Actions.ActOnCXXNullPtrLiteral(ConsumeToken());
823 break;
824
825 case tok::annot_primary_expr:
826 case tok::annot_overload_set:
827 Res = getExprAnnotation(Tok);
828 if (!Res.isInvalid() && Tok.getKind() == tok::annot_overload_set)
829 Res = Actions.ActOnNameClassifiedAsOverloadSet(getCurScope(), Res.get());
830 ConsumeAnnotationToken();
831 if (!Res.isInvalid() && Tok.is(tok::less))
832 checkPotentialAngleBracket(Res);
833 break;
834
835 case tok::annot_non_type:
836 case tok::annot_non_type_dependent:
837 case tok::annot_non_type_undeclared: {
838 CXXScopeSpec SS;
839 Token Replacement;
840 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
842 "should not perform typo correction on annotation token");
843 break;
844 }
845
846 case tok::annot_embed: {
847 injectEmbedTokens();
848 return ParseCastExpression(ParseKind, isAddressOfOperand,
849 CorrectionBehavior, isVectorLiteral,
850 NotPrimaryExpression);
851 }
852
853 case tok::kw___super:
854 case tok::kw_decltype:
855
858 assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super));
859 return ParseCastExpression(ParseKind, isAddressOfOperand,
860 CorrectionBehavior, isVectorLiteral,
861 NotPrimaryExpression);
862
863 case tok::identifier:
864 ParseIdentifier: {
865
866
867
868
870
871
873
874 if (Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&
876
877
878
880 Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
881 return ParseCastExpression(ParseKind, isAddressOfOperand,
882 CorrectionBehavior, isVectorLiteral,
883 NotPrimaryExpression);
884 }
885
886
887
888
889 else if (Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
890 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
891 IdentifierInfo *II = Tok.getIdentifierInfo();
893 if (isRevertibleTypeTrait(II, &Kind)) {
894 Tok.setKind(Kind);
895 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
896 CorrectionBehavior, isVectorLiteral,
897 NotPrimaryExpression);
898 }
899 }
900
901 else if ((!ColonIsSacred && Next.is(tok::colon)) ||
902 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
903 tok::l_brace)) {
904
907 if (!Tok.is(tok::identifier))
908 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
909 CorrectionBehavior, isVectorLiteral,
910 NotPrimaryExpression);
911 }
912 }
913
914
915
916 IdentifierInfo &II = *Tok.getIdentifierInfo();
918
919
921 (Actions.getTypeName(II, ILoc, getCurScope()) ||
922
923 (&II == Ident_super && getCurScope()->isInObjcMethodScope()))) {
925
926 if (Tok.is(tok::code_completion) && &II != Ident_super) {
927 cutOffParsing();
928 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
929 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
931 }
932
933 if (Tok.isNot(tok::identifier) &&
935 Diag(Tok, diag::err_expected_property_name);
937 }
938 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
940
941 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
942 PropertyLoc);
943 break;
944 }
945
946
947
948
949
950 if (getLangOpts().ObjC && &II == Ident_super && !InMessageExpression &&
952 ((Tok.is(tok::identifier) &&
954 Tok.is(tok::code_completion))) {
955 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, nullptr,
956 nullptr);
957 break;
958 }
959
960
961
962
963
964
966 ((Tok.is(tok::identifier) && !InMessageExpression) ||
967 Tok.is(tok::code_completion))) {
969 if (Tok.is(tok::code_completion) ||
970 Next.is(tok::colon) || Next.is(tok::r_square))
972 if (Typ.get()->isObjCObjectOrInterfaceType()) {
973
974 DeclSpec DS(AttrFactory);
975 DS.SetRangeStart(ILoc);
976 DS.SetRangeEnd(ILoc);
977 const char *PrevSpec = nullptr;
978 unsigned DiagID;
979 DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ,
980 Actions.getASTContext().getPrintingPolicy());
981
984 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
986 break;
987
988 Res = ParseObjCMessageExpressionBody(SourceLocation(),
989 SourceLocation(),
990 Ty.get(), nullptr);
991 break;
992 }
993 }
994
995
996 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
997 isAddressOfOperand = false;
998
999
1000
1001
1003 CXXScopeSpec ScopeSpec;
1004 SourceLocation TemplateKWLoc;
1005 Token Replacement;
1006 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1007 Validator.IsAddressOfOperand = isAddressOfOperand;
1008 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1009 Validator.WantExpressionKeywords = false;
1010 Validator.WantRemainingKeywords = false;
1011 } else {
1012 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1013 }
1015 Res = Actions.ActOnIdExpression(
1016 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1017 isAddressOfOperand, &Validator,
1018 false,
1019 Tok.is(tok::r_paren) ? nullptr : &Replacement);
1021 UnconsumeToken(Replacement);
1022 return ParseCastExpression(
1023 ParseKind, isAddressOfOperand, NotCastExpr, CorrectionBehavior,
1024 false, NotPrimaryExpression);
1025 }
1026 Res = tryParseCXXPackIndexingExpression(Res);
1027 if (!Res.isInvalid() && Tok.is(tok::less))
1028 checkPotentialAngleBracket(Res);
1029 break;
1030 }
1031 case tok::char_constant:
1032 case tok::wide_char_constant:
1033 case tok::utf8_char_constant:
1034 case tok::utf16_char_constant:
1035 case tok::utf32_char_constant:
1036 Res = Actions.ActOnCharacterConstant(Tok, getCurScope());
1038 break;
1039 case tok::kw___func__:
1040 case tok::kw___FUNCTION__:
1041 case tok::kw___FUNCDNAME__:
1042 case tok::kw___FUNCSIG__:
1043 case tok::kw_L__FUNCTION__:
1044 case tok::kw_L__FUNCSIG__:
1045 case tok::kw___PRETTY_FUNCTION__:
1046
1047
1048
1052 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1054 break;
1055 }
1056 [[fallthrough]];
1057 case tok::string_literal:
1058 case tok::wide_string_literal:
1059 case tok::utf8_string_literal:
1060 case tok::utf16_string_literal:
1061 case tok::utf32_string_literal:
1063 break;
1064 case tok::kw__Generic:
1065 Res = ParseGenericSelectionExpression();
1066 break;
1067 case tok::kw___builtin_available:
1068 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1069 break;
1070 case tok::kw___builtin_va_arg:
1071 case tok::kw___builtin_offsetof:
1072 case tok::kw___builtin_choose_expr:
1073 case tok::kw___builtin_astype:
1074 case tok::kw___builtin_convertvector:
1075 case tok::kw___builtin_COLUMN:
1076 case tok::kw___builtin_FILE:
1077 case tok::kw___builtin_FILE_NAME:
1078 case tok::kw___builtin_FUNCTION:
1079 case tok::kw___builtin_FUNCSIG:
1080 case tok::kw___builtin_LINE:
1081 case tok::kw___builtin_source_location:
1082 if (NotPrimaryExpression)
1083 *NotPrimaryExpression = true;
1084
1085 return ParseBuiltinPrimaryExpression();
1086 case tok::kw___null:
1087 Res = Actions.ActOnGNUNullExpr(ConsumeToken());
1088 break;
1089
1090 case tok::plusplus:
1091 case tok::minusminus: {
1092 if (NotPrimaryExpression)
1093 *NotPrimaryExpression = true;
1094
1095
1096
1097
1098 Token SavedTok = Tok;
1100
1101 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.getKind(),
1103
1104
1105
1109 false, NotCastExpr,
1111 if (NotCastExpr) {
1112
1113
1115 UnconsumeToken(SavedTok);
1117 }
1119 Expr *Arg = Res.get();
1121 SavedKind, Arg);
1123 Res = Actions.CreateRecoveryExpr(SavedTok.getLocation(),
1125 }
1126 return Res;
1127 }
1128 case tok::amp: {
1129 if (NotPrimaryExpression)
1130 *NotPrimaryExpression = true;
1131
1133 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1134
1136 true);
1138 Expr *Arg = Res.get();
1139 Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Arg);
1141 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->getEndLoc(),
1142 Arg);
1143 }
1144 return Res;
1145 }
1146
1147 case tok:⭐
1148 case tok:➕
1149 case tok:➖
1150 case tok::tilde:
1151 case tok::exclaim:
1152 case tok::kw___real:
1153 case tok::kw___imag: {
1154 if (NotPrimaryExpression)
1155 *NotPrimaryExpression = true;
1157 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1160 Expr *Arg = Res.get();
1161 Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Arg,
1162 isAddressOfOperand);
1164 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->getEndLoc(), Arg);
1165 }
1166 return Res;
1167 }
1168
1169 case tok::kw_co_await: {
1170 if (NotPrimaryExpression)
1171 *NotPrimaryExpression = true;
1175 Res = Actions.ActOnCoawaitExpr(getCurScope(), CoawaitLoc, Res.get());
1176 return Res;
1177 }
1178
1179 case tok::kw___extension__:{
1180
1181 if (NotPrimaryExpression)
1182 *NotPrimaryExpression = true;
1183 ExtensionRAIIObject O(Diags);
1187 Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
1188 return Res;
1189 }
1190 case tok::kw__Alignof:
1191 diagnoseUseOfC11Keyword(Tok);
1192 [[fallthrough]];
1193 case tok::kw_alignof:
1194 case tok::kw___alignof:
1195
1196 case tok::kw_sizeof:
1197
1198
1199
1200 case tok::kw___datasizeof:
1201 case tok::kw_vec_step:
1202
1203 case tok::kw___builtin_omp_required_simd_align:
1204 case tok::kw___builtin_vectorelements:
1205 case tok::kw__Countof:
1206 if (NotPrimaryExpression)
1207 *NotPrimaryExpression = true;
1208 AllowSuffix = false;
1209 Res = ParseUnaryExprOrTypeTraitExpression();
1210 break;
1211 case tok::ampamp: {
1212 if (NotPrimaryExpression)
1213 *NotPrimaryExpression = true;
1215 if (Tok.isNot(tok::identifier))
1216 return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
1217
1218 if (getCurScope()->getFnParent() == nullptr)
1219 return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn));
1220
1221 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1222 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1223 Tok.getLocation());
1224 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1226 AllowSuffix = false;
1227 break;
1228 }
1229 case tok::kw_const_cast:
1230 case tok::kw_dynamic_cast:
1231 case tok::kw_reinterpret_cast:
1232 case tok::kw_static_cast:
1233 case tok::kw_addrspace_cast:
1234 if (NotPrimaryExpression)
1235 *NotPrimaryExpression = true;
1236 Res = ParseCXXCasts();
1237 break;
1238 case tok::kw___builtin_bit_cast:
1239 if (NotPrimaryExpression)
1240 *NotPrimaryExpression = true;
1241 Res = ParseBuiltinBitCast();
1242 break;
1243 case tok::kw_typeid:
1244 if (NotPrimaryExpression)
1245 *NotPrimaryExpression = true;
1246 Res = ParseCXXTypeid();
1247 break;
1248 case tok::kw___uuidof:
1249 if (NotPrimaryExpression)
1250 *NotPrimaryExpression = true;
1251 Res = ParseCXXUuidof();
1252 break;
1253 case tok::kw_this:
1254 Res = ParseCXXThis();
1255 break;
1256 case tok::kw___builtin_sycl_unique_stable_name:
1257 Res = ParseSYCLUniqueStableNameExpression();
1258 break;
1259
1260 case tok::annot_typename:
1261 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1263
1264
1265 DeclSpec DS(AttrFactory);
1266 DS.SetRangeStart(Tok.getLocation());
1267 DS.SetRangeEnd(Tok.getLastLoc());
1268
1269 const char *PrevSpec = nullptr;
1270 unsigned DiagID;
1271 DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(),
1272 PrevSpec, DiagID, Type,
1273 Actions.getASTContext().getPrintingPolicy());
1274
1277 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1279 break;
1280
1281 ConsumeAnnotationToken();
1282 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1283 Ty.get(), nullptr);
1284 break;
1285 }
1286 [[fallthrough]];
1287
1288 case tok::annot_decltype:
1289 case tok::annot_pack_indexing_type:
1290 case tok::kw_char:
1291 case tok::kw_wchar_t:
1292 case tok::kw_char8_t:
1293 case tok::kw_char16_t:
1294 case tok::kw_char32_t:
1295 case tok::kw_bool:
1296 case tok::kw_short:
1297 case tok::kw_int:
1298 case tok::kw_long:
1299 case tok::kw___int64:
1300 case tok::kw___int128:
1301 case tok::kw__ExtInt:
1302 case tok::kw__BitInt:
1303 case tok::kw_signed:
1304 case tok::kw_unsigned:
1305 case tok::kw_half:
1306 case tok::kw_float:
1307 case tok::kw_double:
1308 case tok::kw___bf16:
1309 case tok::kw__Float16:
1310 case tok::kw___float128:
1311 case tok::kw___ibm128:
1312 case tok::kw_void:
1313 case tok::kw_auto:
1314 case tok::kw_typename:
1315 case tok::kw_typeof:
1316 case tok::kw___vector:
1317 case tok::kw__Accum:
1318 case tok::kw__Fract:
1319 case tok::kw__Sat:
1320#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1321#include "clang/Basic/OpenCLImageTypes.def"
1322#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1323#include "clang/Basic/HLSLIntangibleTypes.def"
1324 {
1326 Diag(Tok, diag::err_expected_expression);
1328 }
1329
1330
1331 if (NotPrimaryExpression)
1332 *NotPrimaryExpression = true;
1333
1334 if (SavedKind == tok::kw_typename) {
1335
1336
1339
1340 if (!Tok.isSimpleTypeSpecifier(getLangOpts()))
1341
1342
1344 }
1345
1346
1347
1348
1349 DeclSpec DS(AttrFactory);
1350
1351 ParseCXXSimpleTypeSpecifier(DS);
1352 if (Tok.isNot(tok::l_paren) &&
1354 return ExprError(Diag(Tok, diag::err_expected_lparen_after_type)
1355 << DS.getSourceRange());
1356
1357 if (Tok.is(tok::l_brace))
1358 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1359
1360 Res = ParseCXXTypeConstructExpression(DS);
1361 break;
1362 }
1363
1364 case tok::annot_cxxscope: {
1365
1366
1369 if (!Tok.is(tok::annot_cxxscope))
1370 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1371 CorrectionBehavior, isVectorLiteral,
1372 NotPrimaryExpression);
1373
1375 if (Next.is(tok::annot_template_id)) {
1376 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Next);
1378
1379
1380
1381 CXXScopeSpec SS;
1382 ParseOptionalCXXScopeSpecifier(SS, nullptr,
1383 false,
1384 false);
1386 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1387 CorrectionBehavior, isVectorLiteral,
1388 NotPrimaryExpression);
1389 }
1390 }
1391
1392
1393 Res = ParseCXXIdExpression(isAddressOfOperand);
1394 break;
1395 }
1396
1397 case tok::annot_template_id: {
1398 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1400
1401
1402
1403 CXXScopeSpec SS;
1405 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1406 CorrectionBehavior, isVectorLiteral,
1407 NotPrimaryExpression);
1408 }
1409
1410
1411 [[fallthrough]];
1412 }
1413
1414 case tok::kw_operator:
1415 Res = ParseCXXIdExpression(isAddressOfOperand);
1416 break;
1417
1418 case tok::coloncolon: {
1419
1420
1423 if (!Tok.is(tok::coloncolon))
1424 return ParseCastExpression(ParseKind, isAddressOfOperand,
1425 CorrectionBehavior, isVectorLiteral,
1426 NotPrimaryExpression);
1427
1428
1429
1431 if (Tok.is(tok::kw_new)) {
1432 if (NotPrimaryExpression)
1433 *NotPrimaryExpression = true;
1434 Res = ParseCXXNewExpression(true, CCLoc);
1435 AllowSuffix = false;
1436 break;
1437 }
1438 if (Tok.is(tok::kw_delete)) {
1439 if (NotPrimaryExpression)
1440 *NotPrimaryExpression = true;
1441 Res = ParseCXXDeleteExpression(true, CCLoc);
1442 AllowSuffix = false;
1443 break;
1444 }
1445
1446
1447 Diag(CCLoc, diag::err_expected_expression);
1449 }
1450
1451 case tok::kw_new:
1452 if (NotPrimaryExpression)
1453 *NotPrimaryExpression = true;
1454 Res = ParseCXXNewExpression(false, Tok.getLocation());
1455 AllowSuffix = false;
1456 break;
1457
1458 case tok::kw_delete:
1459 if (NotPrimaryExpression)
1460 *NotPrimaryExpression = true;
1461 Res = ParseCXXDeleteExpression(false, Tok.getLocation());
1462 AllowSuffix = false;
1463 break;
1464
1465 case tok::kw_requires:
1466 Res = ParseRequiresExpression();
1467 AllowSuffix = false;
1468 break;
1469
1470 case tok::kw_noexcept: {
1471 if (NotPrimaryExpression)
1472 *NotPrimaryExpression = true;
1473 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1476
1477 if (T.expectAndConsume(diag::err_expected_lparen_after, "noexcept"))
1479
1480
1481
1482 EnterExpressionEvaluationContext Unevaluated(
1485
1486 T.consumeClose();
1487
1489 Res = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Res.get(),
1490 T.getCloseLocation());
1491 AllowSuffix = false;
1492 break;
1493 }
1494
1495#define TYPE_TRAIT(N,Spelling,K) \
1496 case tok::kw_##Spelling:
1497#include "clang/Basic/TokenKinds.def"
1498 Res = ParseTypeTrait();
1499 break;
1500
1501 case tok::kw___array_rank:
1502 case tok::kw___array_extent:
1503 if (NotPrimaryExpression)
1504 *NotPrimaryExpression = true;
1505 Res = ParseArrayTypeTrait();
1506 break;
1507
1508 case tok::kw___builtin_ptrauth_type_discriminator:
1509 return ParseBuiltinPtrauthTypeDiscriminator();
1510
1511 case tok::kw___is_lvalue_expr:
1512 case tok::kw___is_rvalue_expr:
1513 if (NotPrimaryExpression)
1514 *NotPrimaryExpression = true;
1515 Res = ParseExpressionTrait();
1516 break;
1517
1518 case tok::at: {
1519 if (NotPrimaryExpression)
1520 *NotPrimaryExpression = true;
1522 return ParseObjCAtExpression(AtLoc);
1523 }
1524 case tok::caret:
1525 Res = ParseBlockLiteralExpression();
1526 break;
1527 case tok::code_completion: {
1528 cutOffParsing();
1529 Actions.CodeCompletion().CodeCompleteExpression(
1530 getCurScope(), PreferredType.get(Tok.getLocation()));
1532 }
1533#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1534#include "clang/Basic/TransformTypeTraits.def"
1535
1536
1538 Tok.setKind(tok::identifier);
1539 Diag(Tok, diag::ext_keyword_as_ident)
1540 << Tok.getIdentifierInfo()->getName() << 0;
1541 goto ParseIdentifier;
1542 }
1543 goto ExpectedExpression;
1544 case tok::l_square:
1547
1548
1549
1550
1551
1552 Res = TryParseLambdaExpression();
1554
1555
1556 if (NotPrimaryExpression)
1557 *NotPrimaryExpression = true;
1558 Res = ParseObjCMessageExpression();
1559 }
1560 break;
1561 }
1562 Res = ParseLambdaExpression();
1563 break;
1564 }
1566 Res = ParseObjCMessageExpression();
1567 break;
1568 }
1569 [[fallthrough]];
1570 default:
1571 ExpectedExpression:
1572 NotCastExpr = true;
1574 }
1575
1576
1577
1578
1579
1581
1582
1583 return Res;
1584
1585 if (!AllowSuffix) {
1586
1587
1589 return Res;
1590
1591 switch (Tok.getKind()) {
1592 case tok::l_square:
1593 case tok::l_paren:
1594 case tok::plusplus:
1595 case tok::minusminus:
1596
1597
1598 if (Tok.isAtStartOfLine())
1599 return Res;
1600
1601 [[fallthrough]];
1602 case tok::period:
1603 case tok::arrow:
1604 break;
1605
1606 default:
1607 return Res;
1608 }
1609
1610
1611
1612
1613 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1617 ")");
1618 }
1619
1620
1621 PreferredType = SavedType;
1622 Res = ParsePostfixExpressionSuffix(Res);
1624 ().getOpenCLOptions().isAvailableOption(
1625 "__cl_clang_function_pointers", getLangOpts()))
1626 if (Expr *PostfixExpr = Res.get()) {
1627 QualType Ty = PostfixExpr->getType();
1629 Diag(PostfixExpr->getExprLoc(),
1630 diag::err_opencl_taking_function_address_parser);
1632 }
1633 }
1634
1635 return Res;
1636}
1637
1639Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
1640
1641
1642 SourceLocation Loc;
1643 auto SavedType = PreferredType;
1644 while (true) {
1645
1646 PreferredType = SavedType;
1647 switch (Tok.getKind()) {
1648 case tok::code_completion:
1649 if (InMessageExpression)
1650 return LHS;
1651
1652 cutOffParsing();
1653 Actions.CodeCompletion().CodeCompletePostfixExpression(
1654 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1656
1657 case tok::identifier:
1658
1659
1660
1663 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1664 nullptr, LHS.get());
1665 break;
1666 }
1667
1668 [[fallthrough]];
1669
1670 default:
1671 return LHS;
1672 case tok::l_square: {
1673
1674
1675
1676
1677
1678
1680 isSimpleObjCMessageExpression())
1681 return LHS;
1682
1683
1684
1685 if (CheckProhibitedCXX11Attribute()) {
1687 }
1689 T.consumeOpen();
1690 Loc = T.getOpenLocation();
1692 SourceLocation ColonLocFirst, ColonLocSecond;
1693 ExprVector ArgExprs;
1694 bool HasError = false;
1695 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.get());
1696
1697
1698
1699
1700
1701 if ((().OpenMP && !AllowOpenACCArraySections) ||
1702 Tok.isNot(tok::colon)) {
1706 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1707 Idx = ParseBraceInitializer();
1708 } else {
1710 }
1712 HasError = true;
1713 } else {
1714 ArgExprs.push_back(Idx.get());
1715 }
1716 } else if (Tok.isNot(tok::r_square)) {
1717 if (ParseExpressionList(ArgExprs)) {
1718 HasError = true;
1719 }
1720 }
1721 }
1722
1723
1724
1725
1726
1727 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1729 if (Tok.is(tok::colon)) {
1730
1732 if (Tok.isNot(tok::r_square))
1734 }
1735 } else if (ArgExprs.size() <= 1 && getLangOpts().OpenMP) {
1737 if (Tok.is(tok::colon)) {
1738
1740 if (Tok.isNot(tok::r_square) &&
1742 ((Tok.isNot(tok::colon) && getLangOpts().OpenMP >= 50)))) {
1744 }
1745 }
1747 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1748 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1749 Tok.is(tok::colon)) {
1750
1752 if (Tok.isNot(tok::r_square)) {
1754 }
1755 }
1756 }
1757
1758 SourceLocation RLoc = Tok.getLocation();
1759 if (!LHS.isInvalid() && !HasError && !Length.isInvalid() &&
1760 !Stride.isInvalid() && Tok.is(tok::r_square)) {
1761 if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) {
1762
1763
1764
1765
1766 if (AllowOpenACCArraySections) {
1767 assert(!Stride.isUsable() && !ColonLocSecond.isValid() &&
1768 "Stride/second colon not allowed for OpenACC");
1769 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1770 LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
1771 ColonLocFirst, Length.get(), RLoc);
1772 } else {
1773 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1774 LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
1775 ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(),
1776 RLoc);
1777 }
1778 } else {
1779 LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
1780 ArgExprs, RLoc);
1781 }
1782 } else {
1784 }
1785
1786
1787 T.consumeClose();
1788 break;
1789 }
1790
1791 case tok::l_paren:
1792 case tok::lesslessless: {
1793
1796
1797 Expr *ExecConfig = nullptr;
1798
1800
1801 if (OpKind == tok::lesslessless) {
1802 ExprVector ExecConfigExprs;
1804
1805 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1807 }
1808
1809 SourceLocation CloseLoc;
1810 if (TryConsumeToken(tok::greatergreatergreater, CloseLoc)) {
1813 } else {
1814
1815 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1816 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1819 }
1820
1822 if (ExpectAndConsume(tok::l_paren))
1824 else
1825 Loc = PrevTokLocation;
1826 }
1827
1829 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1830 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1833 else
1834 ExecConfig = ECResult.get();
1835 }
1836 } else {
1837 PT.consumeOpen();
1838 Loc = PT.getOpenLocation();
1839 }
1840
1841 ExprVector ArgExprs;
1842 auto RunSignatureHelp = [&]() -> QualType {
1843 QualType PreferredType =
1844 Actions.CodeCompletion().ProduceCallSignatureHelp(
1845 LHS.get(), ArgExprs, PT.getOpenLocation());
1846 CalledSignatureHelp = true;
1847 return PreferredType;
1848 };
1849 bool ExpressionListIsInvalid = false;
1850 if (OpKind == tok::l_paren || !LHS.isInvalid()) {
1851 if (Tok.isNot(tok::r_paren)) {
1852 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1853 PreferredType.enterFunctionArgument(Tok.getLocation(),
1854 RunSignatureHelp);
1855 }))) {
1856
1857
1858
1859
1860 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1861 RunSignatureHelp();
1862 }
1863 }
1864 }
1865
1866
1869 } else if (ExpressionListIsInvalid) {
1871 ArgExprs.insert(ArgExprs.begin(), Fn);
1872 LHS = Actions.CreateRecoveryExpr(Fn->getBeginLoc(), Tok.getLocation(),
1873 ArgExprs);
1875 } else if (Tok.isNot(tok::r_paren)) {
1876 bool HadErrors = false;
1878 HadErrors = true;
1879 for (auto &E : ArgExprs)
1880 if (E->containsErrors())
1881 HadErrors = true;
1882
1883
1884
1885 if (HadErrors)
1887 else
1888 PT.consumeClose();
1890 } else {
1892 SourceLocation RParLoc = Tok.getLocation();
1893 LHS = Actions.ActOnCallExpr(getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1894 ExecConfig);
1896 ArgExprs.insert(ArgExprs.begin(), Fn);
1897 LHS =
1898 Actions.CreateRecoveryExpr(Fn->getBeginLoc(), RParLoc, ArgExprs);
1899 }
1900 PT.consumeClose();
1901 }
1902
1903 break;
1904 }
1905 case tok::arrow:
1906 case tok::period: {
1907
1908
1910 SourceLocation OpLoc = ConsumeToken();
1911
1912 CXXScopeSpec SS;
1914 bool MayBePseudoDestructor = false;
1915 Expr* OrigLHS = !LHS.isInvalid() ? LHS.get() : nullptr;
1916
1917 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1918
1920 Expr *Base = OrigLHS;
1921 const Type* BaseType = Base->getType().getTypePtrOrNull();
1922 if (BaseType && Tok.is(tok::l_paren) &&
1925 Diag(OpLoc, diag::err_function_is_not_record)
1926 << OpKind << Base->getSourceRange()
1928 return ParsePostfixExpressionSuffix(Base);
1929 }
1930
1931 LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base, OpLoc,
1932 OpKind, ObjectType,
1933 MayBePseudoDestructor);
1935
1936
1937
1938 if (Tok.is(tok::code_completion)) {
1939 cutOffParsing();
1941 }
1942 break;
1943 }
1944 ParseOptionalCXXScopeSpecifier(
1946 false, &MayBePseudoDestructor);
1948 ObjectType = nullptr;
1949 }
1950
1951 if (Tok.is(tok::code_completion)) {
1953 OpKind == tok::arrow ? tok::period : tok::arrow;
1954 ExprResult CorrectedLHS(true);
1956
1957
1958 Sema::TentativeAnalysisScope Trap(Actions);
1959 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1960 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1961 MayBePseudoDestructor);
1962 }
1963
1965 Expr *CorrectedBase = CorrectedLHS.get();
1967 CorrectedBase = Base;
1968
1969
1970 cutOffParsing();
1971 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
1972 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
1973 Base && ExprStatementTokLoc == Base->getBeginLoc(),
1974 PreferredType.get(Tok.getLocation()));
1975
1977 }
1978
1979 if (MayBePseudoDestructor && !LHS.isInvalid()) {
1980 LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS,
1981 ObjectType);
1982 break;
1983 }
1984
1985
1986
1987
1988
1989
1990
1991
1992 SourceLocation TemplateKWLoc;
1995 Tok.is(tok::kw_class)) {
1996
1997
1998
1999
2000
2001
2002
2003 IdentifierInfo *Id = Tok.getIdentifierInfo();
2008 false,
2009 true,
2010
2012 false, &TemplateKWLoc, Name)) {
2014 }
2015
2017 LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.get(), OpLoc,
2018 OpKind, SS, TemplateKWLoc, Name,
2019 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2020 : nullptr);
2022 if (Tok.is(tok::less))
2023 checkPotentialAngleBracket(LHS);
2024 } else if (OrigLHS && Name.isValid()) {
2025
2026 LHS = Actions.CreateRecoveryExpr(OrigLHS->getBeginLoc(),
2028 }
2029 break;
2030 }
2031 case tok::plusplus:
2032 case tok::minusminus:
2034 Expr *Arg = LHS.get();
2035 LHS = Actions.ActOnPostfixUnaryOp(getCurScope(), Tok.getLocation(),
2036 Tok.getKind(), Arg);
2038 LHS = Actions.CreateRecoveryExpr(Arg->getBeginLoc(),
2039 Tok.getLocation(), Arg);
2040 }
2042 break;
2043 }
2044 }
2045}
2046
2048Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,
2049 bool &isCastExpr,
2052
2053 assert(OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2054 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2055 tok::kw__Alignof, tok::kw_vec_step,
2056 tok::kw___builtin_omp_required_simd_align,
2057 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2058 "Not a typeof/sizeof/alignof/vec_step expression!");
2059
2061
2062
2063 if (Tok.isNot(tok::l_paren)) {
2064
2065
2066 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2067 tok::kw_alignof, tok::kw__Alignof)) {
2068 if (isTypeIdUnambiguously()) {
2069 DeclSpec DS(AttrFactory);
2070 ParseSpecifierQualifierList(DS);
2073 ParseDeclarator(DeclaratorInfo);
2074
2075 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation());
2076 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2079 diag::err_expected_parentheses_around_typename)
2081 } else {
2082 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2085 }
2086 isCastExpr = true;
2088 }
2089 }
2090
2091 isCastExpr = false;
2092 if (OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2095 << tok::l_paren;
2097 }
2098
2099
2100
2101
2102
2103 if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2104 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2105 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2106 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2107 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2108 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2109 });
2110 else
2112 } else {
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127 bool ParenKnownToBeNonCast =
2128 OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2130 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2131
2132 Operand = ParseParenExpression(
2133 ExprType, true,
2137 CastRange = SourceRange(LParenLoc, RParenLoc);
2138
2139
2140
2142 isCastExpr = true;
2144 }
2145
2147 !OpTok.isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2148
2149
2150
2151
2152 if (.isInvalid())
2153 Operand = ParsePostfixExpressionSuffix(Operand.get());
2154 }
2155 }
2156
2157
2158 isCastExpr = false;
2160}
2161
2162ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2163 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2164 "Not __builtin_sycl_unique_stable_name");
2165
2168
2169
2170 if (T.expectAndConsume(diag::err_expected_lparen_after,
2171 "__builtin_sycl_unique_stable_name"))
2173
2175
2177 T.skipToEnd();
2179 }
2180
2181 if (T.consumeClose())
2183
2184 return Actions.SYCL().ActOnUniqueStableNameExpr(
2185 OpLoc, T.getOpenLocation(), T.getCloseLocation(), Ty.get());
2186}
2187
2188ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2189 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2190 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2191 tok::kw___builtin_omp_required_simd_align,
2192 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2193 "Not a sizeof/alignof/vec_step expression!");
2194 Token OpTok = Tok;
2196
2197
2198 if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
2199 SourceLocation EllipsisLoc = ConsumeToken();
2200 SourceLocation LParenLoc, RParenLoc;
2201 IdentifierInfo *Name = nullptr;
2202 SourceLocation NameLoc;
2203 if (Tok.is(tok::l_paren)) {
2205 T.consumeOpen();
2206 LParenLoc = T.getOpenLocation();
2207 if (Tok.is(tok::identifier)) {
2208 Name = Tok.getIdentifierInfo();
2210 T.consumeClose();
2211 RParenLoc = T.getCloseLocation();
2213 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2214 } else {
2215 Diag(Tok, diag::err_expected_parameter_pack);
2217 }
2218 } else if (Tok.is(tok::identifier)) {
2219 Name = Tok.getIdentifierInfo();
2221 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2222 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2223 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2224 << Name
2227 } else {
2228 Diag(Tok, diag::err_sizeof_parameter_pack);
2229 }
2230
2231 if (!Name)
2233
2234 EnterExpressionEvaluationContext Unevaluated(
2237
2238 return Actions.ActOnSizeofParameterPackExpr(getCurScope(),
2240 *Name, NameLoc,
2241 RParenLoc);
2242 }
2243
2245 OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2246 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2248 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.getName();
2250 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.getName();
2251
2252 EnterExpressionEvaluationContext Unevaluated(
2255
2256 bool isCastExpr;
2258 SourceRange CastRange;
2260 isCastExpr,
2261 CastTy,
2262 CastRange);
2263
2265 switch (OpTok.getKind()) {
2266 case tok::kw_alignof:
2267 case tok::kw__Alignof:
2268 ExprKind = UETT_AlignOf;
2269 break;
2270 case tok::kw___alignof:
2271 ExprKind = UETT_PreferredAlignOf;
2272 break;
2273 case tok::kw_vec_step:
2274 ExprKind = UETT_VecStep;
2275 break;
2276 case tok::kw___builtin_omp_required_simd_align:
2277 ExprKind = UETT_OpenMPRequiredSimdAlign;
2278 break;
2279 case tok::kw___datasizeof:
2280 ExprKind = UETT_DataSizeOf;
2281 break;
2282 case tok::kw___builtin_vectorelements:
2283 ExprKind = UETT_VectorElements;
2284 break;
2285 case tok::kw__Countof:
2286 ExprKind = UETT_CountOf;
2289 Diag(OpTok, diag::ext_c2y_feature) << OpTok.getName();
2290 break;
2291 default:
2292 break;
2293 }
2294
2295 if (isCastExpr)
2296 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2297 ExprKind,
2298 true,
2300 CastRange);
2301
2302 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2304
2305
2306 if (.isInvalid())
2307 Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2308 ExprKind,
2309 false,
2311 CastRange);
2313}
2314
2315ExprResult Parser::ParseBuiltinPrimaryExpression() {
2317 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2318
2320 SourceLocation StartLoc = ConsumeToken();
2321
2322
2323 if (Tok.isNot(tok::l_paren))
2324 return ExprError(Diag(Tok, diag::err_expected_after) << BuiltinII
2325 << tok::l_paren);
2326
2328 PT.consumeOpen();
2329
2330
2331
2332 switch (T) {
2333 default: llvm_unreachable("Not a builtin primary expression!");
2334 case tok::kw___builtin_va_arg: {
2336
2337 if (ExpectAndConsume(tok::comma)) {
2340 }
2341
2343
2344 if (Tok.isNot(tok::r_paren)) {
2345 Diag(Tok, diag::err_expected) << tok::r_paren;
2347 }
2348
2349 if (Expr.isInvalid() || Ty.isInvalid())
2351 else
2352 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.get(), ConsumeParen());
2353 break;
2354 }
2355 case tok::kw___builtin_offsetof: {
2356 SourceLocation TypeLoc = Tok.getLocation();
2358 if (Tok.getLocation().isMacroID()) {
2360 Tok.getLocation(), PP.getSourceManager(), getLangOpts());
2361 if (MacroName == "offsetof")
2363 }
2365 {
2371 }
2372 }
2373
2374 if (ExpectAndConsume(tok::comma)) {
2377 }
2378
2379
2380 if (Tok.isNot(tok::identifier)) {
2381 Diag(Tok, diag::err_expected) << tok::identifier;
2384 }
2385
2386
2387 SmallVector<Sema::OffsetOfComponent, 4> Comps;
2388
2389 Comps.push_back(Sema::OffsetOfComponent());
2390 Comps.back().isBrackets = false;
2391 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2392 Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken();
2393
2394
2395 while (true) {
2396 if (Tok.is(tok::period)) {
2397
2398 Comps.push_back(Sema::OffsetOfComponent());
2399 Comps.back().isBrackets = false;
2401
2402 if (Tok.isNot(tok::identifier)) {
2403 Diag(Tok, diag::err_expected) << tok::identifier;
2406 }
2407 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2409 } else if (Tok.is(tok::l_square)) {
2410 if (CheckProhibitedCXX11Attribute())
2412
2413
2414 Comps.push_back(Sema::OffsetOfComponent());
2415 Comps.back().isBrackets = true;
2417 ST.consumeOpen();
2418 Comps.back().LocStart = ST.getOpenLocation();
2422 return Res;
2423 }
2424 Comps.back().U.E = Res.get();
2425
2426 ST.consumeClose();
2427 Comps.back().LocEnd = ST.getCloseLocation();
2428 } else {
2429 if (Tok.isNot(tok::r_paren)) {
2430 PT.consumeClose();
2434 } else {
2435 PT.consumeClose();
2436 Res = Actions.ActOnBuiltinOffsetOf(getCurScope(), StartLoc, TypeLoc,
2437 Ty.get(), Comps,
2438 PT.getCloseLocation());
2439 }
2440 break;
2441 }
2442 }
2443 break;
2444 }
2445 case tok::kw___builtin_choose_expr: {
2447 if (Cond.isInvalid()) {
2449 return Cond;
2450 }
2451 if (ExpectAndConsume(tok::comma)) {
2454 }
2455
2457 if (Expr1.isInvalid()) {
2459 return Expr1;
2460 }
2461 if (ExpectAndConsume(tok::comma)) {
2464 }
2465
2467 if (Expr2.isInvalid()) {
2469 return Expr2;
2470 }
2471 if (Tok.isNot(tok::r_paren)) {
2472 Diag(Tok, diag::err_expected) << tok::r_paren;
2474 }
2475 Res = Actions.ActOnChooseExpr(StartLoc, Cond.get(), Expr1.get(),
2476 Expr2.get(), ConsumeParen());
2477 break;
2478 }
2479 case tok::kw___builtin_astype: {
2480
2482 if (Expr.isInvalid()) {
2485 }
2486
2487 if (ExpectAndConsume(tok::comma)) {
2490 }
2491
2492
2496
2497
2498 if (Tok.isNot(tok::r_paren)) {
2499 Diag(Tok, diag::err_expected) << tok::r_paren;
2502 }
2503
2504 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.get(), StartLoc,
2505 ConsumeParen());
2506 break;
2507 }
2508 case tok::kw___builtin_convertvector: {
2509
2511 if (Expr.isInvalid()) {
2514 }
2515
2516 if (ExpectAndConsume(tok::comma)) {
2519 }
2520
2521
2525
2526
2527 if (Tok.isNot(tok::r_paren)) {
2528 Diag(Tok, diag::err_expected) << tok::r_paren;
2531 }
2532
2533 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.get(), StartLoc,
2534 ConsumeParen());
2535 break;
2536 }
2537 case tok::kw___builtin_COLUMN:
2538 case tok::kw___builtin_FILE:
2539 case tok::kw___builtin_FILE_NAME:
2540 case tok::kw___builtin_FUNCTION:
2541 case tok::kw___builtin_FUNCSIG:
2542 case tok::kw___builtin_LINE:
2543 case tok::kw___builtin_source_location: {
2544
2545 if (Tok.isNot(tok::r_paren)) {
2546 Diag(Tok, diag::err_expected) << tok::r_paren;
2549 }
2551 switch (T) {
2552 case tok::kw___builtin_FILE:
2554 case tok::kw___builtin_FILE_NAME:
2556 case tok::kw___builtin_FUNCTION:
2558 case tok::kw___builtin_FUNCSIG:
2560 case tok::kw___builtin_LINE:
2562 case tok::kw___builtin_COLUMN:
2564 case tok::kw___builtin_source_location:
2566 default:
2567 llvm_unreachable("invalid keyword");
2568 }
2569 }();
2570 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2571 break;
2572 }
2573 }
2574
2577
2578
2579
2580 return ParsePostfixExpressionSuffix(Res.get());
2581}
2582
2583bool Parser::tryParseOpenMPArrayShapingCastPart() {
2584 assert(Tok.is(tok::l_square) && "Expected open bracket");
2585 bool ErrorFound = true;
2586 TentativeParsingAction TPA(*this);
2587 do {
2588 if (Tok.isNot(tok::l_square))
2589 break;
2590
2591 ConsumeBracket();
2592
2593 while ((tok::r_square, tok::annot_pragma_openmp_end,
2595 ;
2596 if (Tok.isNot(tok::r_square))
2597 break;
2598
2599 ConsumeBracket();
2600
2601 if (Tok.is(tok::r_paren)) {
2602 ErrorFound = false;
2603 break;
2604 }
2605 } while (Tok.isNot(tok::annot_pragma_openmp_end));
2606 TPA.Revert();
2607 return !ErrorFound;
2608}
2609
2611Parser::ParseParenExpression(ParenParseOption &ExprType, bool StopIfCastExpr,
2615 assert(Tok.is(tok::l_paren) && "Not a paren expr!");
2618 if (T.consumeOpen())
2620 SourceLocation OpenLoc = T.getOpenLocation();
2621
2622 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2623
2625 bool isAmbiguousTypeId;
2626 CastTy = nullptr;
2627
2628 if (Tok.is(tok::code_completion)) {
2629 cutOffParsing();
2630 Actions.CodeCompletion().CodeCompleteExpression(
2631 getCurScope(), PreferredType.get(Tok.getLocation()),
2634 }
2635
2636
2637 bool BridgeCast = (getLangOpts().ObjC &&
2638 Tok.isOneOf(tok::kw___bridge,
2639 tok::kw___bridge_transfer,
2640 tok::kw___bridge_retained,
2641 tok::kw___bridge_retain));
2642 if (BridgeCast && ().ObjCAutoRefCount) {
2644 StringRef BridgeCastName = Tok.getName();
2645 SourceLocation BridgeKeywordLoc = ConsumeToken();
2646 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2647 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2648 << BridgeCastName
2650 }
2651 BridgeCast = false;
2652 }
2653
2654
2655
2657 Diag(Tok, OpenLoc.isMacroID() ? diag::ext_gnu_statement_expr_macro
2658 : diag::ext_gnu_statement_expr);
2659
2660 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2661
2664 } else {
2665
2666
2667
2668 DeclContext *CodeDC = Actions.CurContext;
2672 "statement expr not in code context");
2673 }
2674 Sema::ContextRAII SavedContext(Actions, CodeDC, false);
2675
2676 Actions.ActOnStartStmtExpr();
2677
2678 StmtResult Stmt(ParseCompoundStatement(true));
2680
2681
2682 if (!Stmt.isInvalid()) {
2683 Result = Actions.ActOnStmtExpr(getCurScope(), OpenLoc, Stmt.get(),
2684 Tok.getLocation());
2685 } else {
2686 Actions.ActOnStmtExprError();
2687 }
2688 }
2691 SourceLocation BridgeKeywordLoc = ConsumeToken();
2692
2693
2695 if (tokenKind == tok::kw___bridge)
2697 else if (tokenKind == tok::kw___bridge_transfer)
2699 else if (tokenKind == tok::kw___bridge_retained)
2701 else {
2702
2703
2704 assert(tokenKind == tok::kw___bridge_retain);
2706 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2707 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2709 "__bridge_retained");
2710 }
2711
2713 T.consumeClose();
2714 ColonProtection.restore();
2715 RParenLoc = T.getCloseLocation();
2716
2717 PreferredType.enterTypeCast(Tok.getLocation(), Ty.get().get());
2719
2722
2723 return Actions.ObjC().ActOnObjCBridgedCast(getCurScope(), OpenLoc, Kind,
2724 BridgeKeywordLoc, Ty.get(),
2725 RParenLoc, SubExpr.get());
2727 isTypeIdInParens(isAmbiguousTypeId)) {
2728
2729
2730
2731
2732
2733
2734
2735
2736 if (isAmbiguousTypeId && !StopIfCastExpr) {
2737 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2738 ColonProtection);
2739 RParenLoc = T.getCloseLocation();
2740 return res;
2741 }
2742
2743
2744 DeclSpec DS(AttrFactory);
2745 ParseSpecifierQualifierList(DS);
2748 ParseDeclarator(DeclaratorInfo);
2749
2750
2751
2752
2753 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2757 {
2759 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2760 }
2761 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2762 SourceLocation(),
2763 Ty.get(), nullptr);
2764 } else {
2765
2766 T.consumeClose();
2767 ColonProtection.restore();
2768 RParenLoc = T.getCloseLocation();
2772 {
2774 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2775 }
2776 return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);
2777 }
2778
2780
2782 {
2784 {
2786 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2787 }
2789 {
2791 }
2794 {
2795
2796
2797
2798
2799
2800 Result = ParseCastExpression(
2802 false,
2804 true);
2805
2806 if (.isInvalid()) {
2808 DeclaratorInfo, CastTy,
2809 RParenLoc, Result.get());
2810 }
2811
2812
2813 if (.isInvalid()) {
2814 Result = ParsePostfixExpressionSuffix(Result);
2815 }
2816
2818 }
2819 }
2820 }
2821
2823
2824
2825 if (DeclaratorInfo.isInvalidType())
2827
2828
2829
2830 if (StopIfCastExpr) {
2832 {
2834 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2835 }
2836 CastTy = Ty.get();
2838 }
2839
2840
2842 Tok.getIdentifierInfo() == Ident_super &&
2845 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2846 << SourceRange(OpenLoc, RParenLoc);
2848 }
2849
2850 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.get());
2851
2852
2853 Result = ParseCastExpression(
2855 false,
2857 if (.isInvalid()) {
2859 DeclaratorInfo, CastTy,
2860 RParenLoc, Result.get());
2861 }
2863 }
2864
2865 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2867 }
2871 return ParseFoldExpression(ExprResult(), T);
2873
2874
2876 ExprVector ArgExprs;
2877
2878 if (!ParseSimpleExpressionList(ArgExprs)) {
2879
2880
2882 isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) {
2884 return ParseFoldExpression(ArgExprs[0], T);
2885 }
2886
2888 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2889 ArgExprs);
2890 }
2891 } else if (getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2893 tryParseOpenMPArrayShapingCastPart()) {
2894 bool ErrorFound = false;
2895 SmallVector<Expr *, 4> OMPDimensions;
2896 SmallVector<SourceRange, 4> OMPBracketsRanges;
2897 do {
2899 TS.consumeOpen();
2901 if (!NumElements.isUsable()) {
2902 ErrorFound = true;
2903 while ((tok::r_square, tok::r_paren,
2905 ;
2906 }
2907 TS.consumeClose();
2908 OMPDimensions.push_back(NumElements.get());
2909 OMPBracketsRanges.push_back(TS.getRange());
2910 } while (Tok.isNot(tok::r_paren));
2911
2912 T.consumeClose();
2913 RParenLoc = T.getCloseLocation();
2915 if (ErrorFound) {
2917 } else if (.isInvalid()) {
2918 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2919 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2920 }
2922 } else {
2924
2927 isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis)) {
2929 return ParseFoldExpression(Result, T);
2930 }
2932
2933
2934 if (.isInvalid() && Tok.is(tok::r_paren))
2936 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.get());
2937 }
2938
2939
2940 if (Result.isInvalid()) {
2943 }
2944
2945 T.consumeClose();
2946 RParenLoc = T.getCloseLocation();
2948}
2949
2951Parser::ParseCompoundLiteralExpression(ParsedType Ty,
2954 assert(Tok.is(tok::l_brace) && "Not a compound literal!");
2955 if (().C99)
2956 Diag(LParenLoc, diag::ext_c99_compound_literal);
2957 PreferredType.enterTypeCast(Tok.getLocation(), Ty.get());
2959 if (.isInvalid() && Ty)
2960 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.get());
2962}
2963
2968
2973
2977 "Not a string-literal-like token!");
2978
2979
2980
2981
2983
2984 do {
2985 StringToks.push_back(Tok);
2988
2990 assert(!AllowUserDefinedLiteral && "UDL are always evaluated");
2992 }
2993
2994
2995 return Actions.ActOnStringLiteral(StringToks,
2997 : nullptr);
2998}
2999
3000ExprResult Parser::ParseGenericSelectionExpression() {
3001 assert(Tok.is(tok::kw__Generic) && "_Generic keyword expected");
3002
3003 diagnoseUseOfC11Keyword(Tok);
3004
3007 if (T.expectAndConsume())
3009
3010
3011
3014 if (isTypeIdForGenericSelection()) {
3016 if (ControllingType.isInvalid()) {
3019 }
3021 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3022 Diag(Loc, getLangOpts().C2y ? diag::warn_c2y_compat_generic_with_type_arg
3023 : diag::ext_c2y_generic_with_type_arg);
3024 } else {
3025
3026
3027 EnterExpressionEvaluationContext Unevaluated(
3030 if (ControllingExpr.isInvalid()) {
3033 }
3034 }
3035
3036 if (ExpectAndConsume(tok::comma)) {
3039 }
3040
3041 SourceLocation DefaultLoc;
3042 SmallVector<ParsedType, 12> Types;
3043 ExprVector Exprs;
3044 do {
3046 if (Tok.is(tok::kw_default)) {
3047
3048
3050 Diag(Tok, diag::err_duplicate_default_assoc);
3051 Diag(DefaultLoc, diag::note_previous_default_assoc);
3054 }
3056 Ty = nullptr;
3057 } else {
3063 }
3064 Ty = TR.get();
3065 }
3066 Types.push_back(Ty);
3067
3068 if (ExpectAndConsume(tok::colon)) {
3071 }
3072
3073
3074
3079 }
3080 Exprs.push_back(ER.get());
3082
3083 T.consumeClose();
3084 if (T.getCloseLocation().isInvalid())
3086
3087 void *ExprOrTy = ControllingExpr.isUsable()
3088 ? ControllingExpr.get()
3090
3091 return Actions.ActOnGenericSelectionExpr(
3092 KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.isUsable(),
3093 ExprOrTy, Types, Exprs);
3094}
3095
3099 T.skipToEnd();
3100 return true;
3101 }
3102
3104 SourceLocation FirstOpLoc;
3106 Kind = Tok.getKind();
3107 assert(isFoldOperator(Kind) && "missing fold-operator");
3109 }
3110
3111 assert(Tok.is(tok::ellipsis) && "not a fold-expression");
3112 SourceLocation EllipsisLoc = ConsumeToken();
3113
3115 if (Tok.isNot(tok::r_paren)) {
3116 if (!isFoldOperator(Tok.getKind()))
3117 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3118
3119 if (Kind != tok::unknown && Tok.getKind() != Kind)
3120 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3121 << SourceRange(FirstOpLoc);
3122 Kind = Tok.getKind();
3124
3127 T.skipToEnd();
3128 return true;
3129 }
3130 }
3131
3133 ? diag::warn_cxx14_compat_fold_expression
3134 : diag::ext_fold_expression);
3135
3136 T.consumeClose();
3137 return Actions.ActOnCXXFoldExpr(getCurScope(), T.getOpenLocation(), LHS.get(),
3138 Kind, EllipsisLoc, RHS.get(),
3139 T.getCloseLocation());
3140}
3141
3142void Parser::injectEmbedTokens() {
3143 EmbedAnnotationData *Data =
3144 reinterpret_cast<EmbedAnnotationData *>(Tok.getAnnotationValue());
3145 MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(
3146 Data->BinaryData.size() * 2 - 1),
3147 Data->BinaryData.size() * 2 - 1);
3148 unsigned I = 0;
3149 for (auto &Byte : Data->BinaryData) {
3150 Toks[I].startToken();
3151 Toks[I].setKind(tok::binary_data);
3152 Toks[I].setLocation(Tok.getLocation());
3153 Toks[I].setLength(1);
3154 Toks[I].setLiteralData(&Byte);
3155 if (I != ((Data->BinaryData.size() - 1) * 2)) {
3156 Toks[I + 1].startToken();
3157 Toks[I + 1].setKind(tok::comma);
3158 Toks[I + 1].setLocation(Tok.getLocation());
3159 }
3160 I += 2;
3161 }
3162 PP.EnterTokenStream(std::move(Toks), true,
3163 true);
3165}
3166
3168 llvm::function_ref<void()> ExpressionStarts,
3169 bool FailImmediatelyOnInvalidExpr) {
3170 bool SawError = false;
3171 while (true) {
3172 if (ExpressionStarts)
3173 ExpressionStarts();
3174
3177 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3178 Expr = ParseBraceInitializer();
3179 } else
3181
3182 if (Tok.is(tok::ellipsis))
3183 Expr = Actions.ActOnPackExpansion(Expr.get(), ConsumeToken());
3184 else if (Tok.is(tok::code_completion)) {
3185
3186
3187
3188
3189
3190 SawError = true;
3191 cutOffParsing();
3192 break;
3193 }
3195 SawError = true;
3196 if (FailImmediatelyOnInvalidExpr)
3197 break;
3199 } else {
3200 Exprs.push_back(Expr.get());
3201 }
3202
3203 if (Tok.isNot(tok::comma))
3204 break;
3205
3206 Token Comma = Tok;
3208 checkPotentialAngleBracketDelimiter(Comma);
3209 }
3210 return SawError;
3211}
3212
3214 while (true) {
3217 return true;
3218
3219 Exprs.push_back(Expr.get());
3220
3221
3222
3223 if (Tok.isNot(tok::comma) || NextToken().is(tok::ellipsis))
3224 return false;
3225
3226
3227 Token Comma = Tok;
3229 checkPotentialAngleBracketDelimiter(Comma);
3230 }
3231}
3232
3234 if (Tok.is(tok::code_completion)) {
3235 cutOffParsing();
3236 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3238 return;
3239 }
3240
3241
3242 DeclSpec DS(AttrFactory);
3243 ParseSpecifierQualifierList(DS);
3244
3245
3249 ParseDeclarator(DeclaratorInfo);
3250
3251 MaybeParseGNUAttributes(DeclaratorInfo);
3252
3253
3254 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo, getCurScope());
3255}
3256
3257ExprResult Parser::ParseBlockLiteralExpression() {
3258 assert(Tok.is(tok::caret) && "block literal starts with ^");
3260
3261 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3262 "block literal parsing");
3263
3264
3265
3266
3267
3270
3271
3272 Actions.ActOnBlockStart(CaretLoc, getCurScope());
3273
3274
3275 DeclSpec DS(AttrFactory);
3279
3280
3281 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3282
3283
3284
3285 if (Tok.is(tok::l_paren)) {
3286 ParseParenDeclarator(ParamInfo);
3287
3288
3289
3290 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3291 ParamInfo.SetIdentifier(nullptr, CaretLoc);
3292 ParamInfo.SetRangeEnd(Tmp);
3293 if (ParamInfo.isInvalidType()) {
3294
3295
3296
3297 Actions.ActOnBlockError(CaretLoc, getCurScope());
3299 }
3300
3301 MaybeParseGNUAttributes(ParamInfo);
3302
3303
3304 Actions.ActOnBlockArguments(CaretLoc, ParamInfo, getCurScope());
3305 } else if (!Tok.is(tok::l_brace)) {
3306 ParseBlockId(CaretLoc);
3307 } else {
3308
3309 SourceLocation NoLoc;
3310 ParamInfo.AddTypeInfo(
3312 false,
3313 NoLoc,
3314 nullptr,
3315 0,
3316 NoLoc,
3317 NoLoc,
3318 true,
3319 NoLoc,
3320 NoLoc, EST_None,
3321 SourceRange(),
3322 nullptr,
3323 nullptr,
3324 0,
3325 nullptr,
3326 nullptr,
3327 {}, CaretLoc,
3328 CaretLoc, ParamInfo),
3329 CaretLoc);
3330
3331 MaybeParseGNUAttributes(ParamInfo);
3332
3333
3334 Actions.ActOnBlockArguments(CaretLoc, ParamInfo, getCurScope());
3335 }
3336
3337
3339 if (!Tok.is(tok::l_brace)) {
3340
3341 Diag(Tok, diag::err_expected_expression);
3342 Actions.ActOnBlockError(CaretLoc, getCurScope());
3344 }
3345 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3347 StmtResult Stmt(ParseCompoundStatementBody());
3348 BlockScope.Exit();
3349 if (!Stmt.isInvalid())
3350 Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.get(), getCurScope());
3351 else
3352 Actions.ActOnBlockError(CaretLoc, getCurScope());
3354}
3355
3356ExprResult Parser::ParseObjCBoolLiteral() {
3358 return Actions.ObjC().ActOnObjCBoolLiteral(ConsumeToken(), Kind);
3359}
3360
3361
3362
3365 llvm::SmallSet<StringRef, 4> Platforms;
3366 bool HasOtherPlatformSpec = false;
3367 bool Valid = true;
3368 for (const auto &Spec : AvailSpecs) {
3369 if (Spec.isOtherPlatformSpec()) {
3370 if (HasOtherPlatformSpec) {
3371 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3373 }
3374
3375 HasOtherPlatformSpec = true;
3376 continue;
3377 }
3378
3379 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3380 if (!Inserted) {
3381
3382
3383
3384 StringRef Platform = Spec.getPlatform();
3385 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3386 << Spec.getEndLoc() << Platform;
3388 }
3389 }
3390
3391 if (!HasOtherPlatformSpec) {
3392 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3393 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3395 return true;
3396 }
3397
3399}
3400
3401std::optional Parser::ParseAvailabilitySpec() {
3402 if (Tok.is(tok::star)) {
3404 } else {
3405
3406 if (Tok.is(tok::code_completion)) {
3407 cutOffParsing();
3408 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3409 return std::nullopt;
3410 }
3411 if (Tok.isNot(tok::identifier)) {
3412 Diag(Tok, diag::err_avail_query_expected_platform_name);
3413 return std::nullopt;
3414 }
3415
3416 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3417 SourceRange VersionRange;
3418 VersionTuple Version = ParseVersionTuple(VersionRange);
3419
3420 if (Version.empty())
3421 return std::nullopt;
3422
3423 StringRef GivenPlatform =
3425 StringRef Platform =
3426 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3427
3428 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3429 (GivenPlatform.contains("xros") || GivenPlatform.contains("xrOS"))) {
3431 diag::err_avail_query_unrecognized_platform_name)
3432 << GivenPlatform;
3433 return std::nullopt;
3434 }
3435
3436 return AvailabilitySpec(Version, Platform, PlatformIdentifier->getLoc(),
3437 VersionRange.getEnd());
3438 }
3439}
3440
3442 assert(Tok.is(tok::kw___builtin_available) ||
3443 Tok.isObjCAtKeyword(tok::objc_available));
3444
3445
3447
3449 if (Parens.expectAndConsume())
3451
3452 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3453 bool HasError = false;
3454 while (true) {
3455 std::optional Spec = ParseAvailabilitySpec();
3456 if (!Spec)
3457 HasError = true;
3458 else
3459 AvailSpecs.push_back(*Spec);
3460
3462 break;
3463 }
3464
3465 if (HasError) {
3468 }
3469
3471
3472 if (Parens.consumeClose())
3474
3475 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3476 AvailSpecs, BeginLoc, Parens.getCloseLocation());
3477}
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatToken * Next
The next token in the unwrapped line.
bool is(tok::TokenKind Kind) const
static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)
Validate availability spec list, emitting diagnostics if necessary.
Definition ParseExpr.cpp:3363
#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.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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 * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
RAII object that enters a new expression evaluation context.
This represents one expression.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
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.
StringRef getName() const
Return the actual identifier string.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void * getAsOpaquePtr() const
static const ParsedAttributesView & none()
ParseScope - Introduces a new scope for parsing.
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.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
Definition ParseExpr.cpp:2964
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)
Definition ParseExpr.cpp:173
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
Definition ParseExpr.cpp:274
ExprResult ParseConstantExpressionInExprEvalContext(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Definition ParseExpr.cpp:121
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.
friend class ColonProtectionRAIIObject
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
const Token & GetLookAheadToken(unsigned N)
GetLookAheadToken - This peeks ahead N tokens and returns that token without consuming any tokens.
ExprResult ParseConstantExpression()
Definition ParseExpr.cpp:133
ExprResult ParseConditionalExpression()
Definition ParseExpr.cpp:95
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
ExprResult ParseArrayBoundExpression()
Definition ParseExpr.cpp:144
friend class InMessageExpressionRAIIObject
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
Definition ParseExpr.cpp:197
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 ...
friend class OffsetOfStateRAIIObject
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
Definition ParseExpr.cpp:47
@ 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...
ExprResult ParseUnevaluatedStringLiteralExpression()
Definition ParseExpr.cpp:2969
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
Definition ParseExpr.cpp:75
friend class BalancedDelimiterTracker
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
Definition ParseExpr.cpp:185
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
@ 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.
@ PCC_Type
Code completion occurs where only a type is permitted.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
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.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
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
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)) {....
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isFunctionType() const
bool isVectorType() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
SourceLocation getEndLoc() const LLVM_READONLY
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 isa(CodeGen::Address addr)
TypoCorrectionTypeBehavior
If a typo should be encountered, should typo correction suggest type names, non type names,...
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.
ActionResult< ParsedType > TypeResult
const FunctionProtoType * T
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.
@ Type
The name was classified as a type.
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.
ParenExprKind
In a call to ParseParenExpression, are the initial parentheses part of an operator that requires the ...
U cast(CodeGen::Address addr)
CastParseKind
Control what ParseCastExpression will parse.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ParenParseOption
ParenParseOption - Control what ParseParenExpression will parse.
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ EST_None
no exception specification
ActionResult< Stmt * > StmtResult
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.
TemplateNameKind Kind
The kind of template that Template refers to.