59 #include "llvm/ADT/STLExtras.h"
60 #include "llvm/ADT/STLForwardCompat.h"
61 #include "llvm/ADT/StringExtras.h"
62 #include "llvm/Support/Casting.h"
63 #include "llvm/Support/ConvertUTF.h"
64 #include "llvm/Support/SaveAndRestore.h"
65 #include "llvm/Support/TypeSize.h"
68 using namespace clang;
75 if (ParsingInitForAutoVars.count(D))
85 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
91 if (TreatUnavailableAsInvalid &&
92 isUnavailableAlignedAllocationFunction(*FD))
101 if (isa<UnresolvedUsingIfExistsDecl>(D))
109 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
112 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
113 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
115 if (DC && !DC->
hasAttr<UnusedAttr>())
116 S.
Diag(
Loc, diag::warn_used_but_marked_unused) << D;
125 if (
Decl->isDefaulted()) {
132 DiagnoseDeletedDefaultedFunction(
Decl);
136 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
137 if (Ctor && Ctor->isInheritingConstructor())
138 return NoteDeletedInheritingConstructor(Ctor);
148 if (I->getStorageClass() !=
SC_None)
175 if (!Current->isInlined())
177 if (!Current->isExternallyVisible())
193 if (!DowngradeWarning && UsedFn)
196 S.
Diag(
Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
197 : diag::ext_internal_in_extern_inline)
212 Diag(DeclBegin, diag::note_convert_inline_to_static)
231 bool ObjCPropertyAccess,
232 bool AvoidPartialAvailabilityChecks,
234 bool SkipTrailingRequiresClause) {
235 if (getLangOpts().SYCLIsDevice) {
236 if (
auto VD = dyn_cast<VarDecl>(D)) {
237 bool IsConst = VD->getType().isConstant(Context);
238 bool IsRuntimeEvaluated =
239 ExprEvalContexts.empty() ||
240 (!isUnevaluatedContext() && !isConstantEvaluatedContext());
241 bool IsEsimdPrivateGlobal = SYCL().isSYCLEsimdPrivateGlobal(VD);
244 if (IsRuntimeEvaluated && !IsEsimdPrivateGlobal && !IsConst &&
246 !VD->hasAttr<SYCLGlobalVarAttr>() &&
248 SYCLGlobalVariableAllowedAttr>(VD->getType()))
249 SYCL().DiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
253 else if (IsRuntimeEvaluated && !IsEsimdPrivateGlobal && !IsConst &&
254 VD->hasGlobalStorage() && !VD->hasAttr<SYCLGlobalVarAttr>() &&
256 SYCLGlobalVariableAllowedAttr>(VD->getType()))
257 SYCL().DiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
260 else if (IsRuntimeEvaluated && IsEsimdPrivateGlobal &&
261 VD->hasGlobalStorage())
262 SYCL().DiagIfDeviceCode(*Locs.begin(),
263 diag::err_esimd_global_in_sycl_context,
265 }
else if (
auto *FDecl = dyn_cast<FunctionDecl>(D)) {
270 auto isMsvcMathFn = [=](StringRef Name) {
274 if (!AuxInfo->getTriple().isWindowsMSVCEnvironment())
276 return llvm::StringSwitch<bool>(Name)
277 .Case(
"_FDtest",
true)
278 .Case(
"_hypotf",
true)
279 .Case(
"_fdpcomp",
true)
280 .Case(
"_fdsign",
true)
281 .Case(
"_fdtest",
true)
282 .Case(
"_FDnorm",
true)
283 .Case(
"_FDscale",
true)
285 .Case(
"_FCosh",
true)
286 .Case(
"_FSinh",
true)
290 Id && !
Id->getName().starts_with(
"__spirv_") &&
291 !
Id->getName().starts_with(
"__sycl_") &&
292 !
Id->getName().starts_with(
"__devicelib_ConvertBF16ToFINTEL") &&
293 !
Id->getName().starts_with(
"__devicelib_ConvertFToBF16INTEL") &&
294 !
Id->getName().starts_with(
"__assert_fail") &&
295 !isMsvcMathFn(
Id->getName())) {
296 SYCL().DiagIfDeviceCode(
297 *Locs.begin(), diag::err_sycl_device_function_is_called_from_esimd,
304 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
308 if (Pos != SuppressedDiagnostics.end()) {
310 Diag(Suppressed.first, Suppressed.second);
321 if (cast<FunctionDecl>(D)->isMain())
322 Diag(
Loc, diag::ext_main_used);
324 diagnoseUnavailableAlignedAllocation(*cast<FunctionDecl>(D),
Loc);
328 if (ParsingInitForAutoVars.count(D)) {
329 if (isa<BindingDecl>(D)) {
330 Diag(
Loc, diag::err_binding_cannot_appear_in_own_initializer)
333 Diag(
Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
334 << D->
getDeclName() << cast<VarDecl>(D)->getType();
341 if (FD->isDeleted()) {
342 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
343 if (Ctor && Ctor->isInheritingConstructor())
344 Diag(
Loc, diag::err_deleted_inherited_ctor_use)
346 << Ctor->getInheritedConstructor().getConstructor()->getParent();
349 Diag(
Loc, diag::err_deleted_function_use)
350 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
352 NoteDeletedFunction(FD);
364 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
366 if (CheckFunctionConstraints(FD, Satisfaction,
Loc,
373 diag::err_reference_to_function_with_unsatisfied_constraints)
375 DiagnoseUnsatisfiedConstraint(Satisfaction);
382 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
383 DeduceReturnType(FD,
Loc))
386 if (getLangOpts().
CUDA && !
CUDA().CheckCall(
Loc, FD))
391 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
393 if (MD->getParent()->isLambda() &&
394 ((isa<CXXConstructorDecl>(MD) &&
395 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
396 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
397 Diag(
Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
398 << !isa<CXXConstructorDecl>(MD);
402 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
404 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
409 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl,
Loc))
411 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D,
Loc)) {
419 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(CurContext);
420 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
422 Diag(
Loc, diag::err_omp_wrong_var_in_declare_reduction)
423 << getCurFunction()->HasOMPDeclareReductionCombiner;
433 if (LangOpts.OpenMP && isa<VarDecl>(D) &&
434 !OpenMP().isOpenMPDeclareMapperVarDeclAllowed(cast<VarDecl>(D))) {
435 Diag(
Loc, diag::err_omp_declare_mapper_wrong_var)
436 << OpenMP().getOpenMPDeclareMapperVarName();
441 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
442 Diag(
Loc, diag::err_use_of_empty_using_if_exists);
443 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
447 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
448 AvoidPartialAvailabilityChecks, ClassReceiver);
454 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
455 if (getLangOpts().getFPEvalMethod() !=
456 LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine &&
457 PP.getLastFPEvalPragmaLocation().isValid() &&
458 PP.getCurrentFPEvalMethod() != getLangOpts().getFPEvalMethod())
460 diag::err_type_available_only_in_default_eval_method)
464 if (
auto *VD = dyn_cast<ValueDecl>(D))
465 checkTypeSupport(VD->getType(),
Loc, VD);
467 if (LangOpts.SYCLIsDevice ||
468 (LangOpts.OpenMP && LangOpts.OpenMPIsTargetDevice)) {
470 if (
const auto *VD = dyn_cast<VarDecl>(D))
472 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
475 if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->
getDeclContext()) &&
476 !isUnevaluatedContext()) {
480 Diag(
Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
495 const SentinelAttr *
Attr = D->
getAttr<SentinelAttr>();
500 unsigned NumFormalParams;
504 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
506 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
507 NumFormalParams = MD->param_size();
508 CalleeKind = CK_Method;
509 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
510 NumFormalParams = FD->param_size();
511 CalleeKind = CK_Function;
512 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
519 CalleeKind = CK_Function;
522 CalleeKind = CK_Block;
527 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
528 NumFormalParams = proto->getNumParams();
539 unsigned NullPos =
Attr->getNullPos();
540 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
541 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
544 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
548 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
555 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
568 std::string NullValue;
569 if (CalleeKind == CK_Method && PP.isMacroDefined(
"nil"))
572 NullValue =
"nullptr";
573 else if (PP.isMacroDefined(
"NULL"))
576 NullValue =
"(void*) 0";
579 Diag(
Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
581 Diag(MissingNilLoc, diag::warn_missing_sentinel)
606 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
610 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
615 CK_FunctionToPointerDecay).get();
630 CK_ArrayToPointerDecay);
646 if (UO && UO->getOpcode() == UO_Deref &&
647 UO->getSubExpr()->getType()->isPointerType()) {
649 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
652 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
654 !UO->getType().isVolatileQualified()) {
656 S.
PDiag(diag::warn_indirection_through_null)
657 << UO->getSubExpr()->getSourceRange());
659 S.
PDiag(diag::note_indirection_through_null));
691 if (ObjectSetClass) {
735 assert(!
T.isNull() &&
"r-value conversion on typeless expression?");
760 if (getLangOpts().
OpenCL &&
761 !getOpenCLOptions().isAvailableOption(
"cl_khr_fp16", getLangOpts()) &&
770 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
777 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
794 if (
T.hasQualifiers())
795 T =
T.getUnqualifiedType();
802 ExprResult Res = CheckLValueToRValueConversionOperand(E);
810 Cleanup.setExprNeedsCleanups(
true);
813 Cleanup.setExprNeedsCleanups(
true);
819 CurFPFeatureOverrides());
825 T =
Atomic->getValueType().getUnqualifiedType();
834 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
837 Res = DefaultLvalueConversion(Res.
get());
852 CK_FunctionToPointerDecay);
856 Res = DefaultLvalueConversion(Res.
get());
869 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
875 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
879 (getLangOpts().getFPEvalMethod() !=
880 LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine ||
881 PP.getLastFPEvalPragmaLocation().isValid())) {
882 switch (EvalMethod) {
884 llvm_unreachable(
"Unrecognized float evaluation method");
887 llvm_unreachable(
"Float evaluation method should be set by now");
893 ? ImpCastExprToType(E,
895 CK_FloatingComplexCast)
896 : ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast);
904 CK_FloatingComplexCast)
912 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
913 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
934 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
939 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
952 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
964 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
966 if (getLangOpts().OpenCL &&
967 !getOpenCLOptions().isAvailableOption(
"cl_khr_fp64", getLangOpts())) {
968 if (BTy->
getKind() == BuiltinType::Half) {
969 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
972 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
976 getLangOpts().getExtendIntArgs() ==
984 : ImpCastExprToType(E, Context.
LongLongTy, CK_IntegralCast).get();
986 "Unexpected typesize for LongLongTy");
1051 if (!
Record->hasNonTrivialCopyConstructor() &&
1052 !
Record->hasNonTrivialMoveConstructor() &&
1053 !
Record->hasNonTrivialDestructor())
1054 return VAK_ValidInCXX11;
1062 if (getLangOpts().MSVCCompat)
1063 return VAK_MSVCUndefined;
1067 return VAK_Undefined;
1077 case VAK_ValidInCXX11:
1078 DiagRuntimeBehavior(
1080 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1087 PDiag(diag::warn_pass_class_arg_to_vararg)
1088 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
1093 case VAK_MSVCUndefined:
1095 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1102 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1106 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1110 << isa<InitListExpr>(E) << Ty << CT;
1121 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1122 (CT == VariadicMethod ||
1123 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1124 E = ObjC().stripARCUnbridgedCast(E);
1128 ExprResult ExprRes = CheckPlaceholderExpr(E);
1135 ExprResult ExprRes = DefaultArgumentPromotion(E);
1141 maybeExtendBlockObject(ExprRes);
1147 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
1152 Name.setIdentifier(PP.getIdentifierInfo(
"__builtin_trap"),
1154 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc, Name,
1162 if (Call.isInvalid())
1166 ActOnBinOp(TUScope, E->
getBeginLoc(), tok::comma, Call.get(), E);
1167 if (Comma.isInvalid())
1174 diag::err_call_incomplete_argument))
1192 if (SkipCast)
return false;
1199 CK_IntegralComplexToFloatingComplex);
1217 bool PromotePrecision) {
1222 if (PromotePrecision) {
1227 if (LongerIsComplex)
1239 QualType RHSType,
bool IsCompAssign) {
1264 bool ConvertFloat,
bool ConvertInt) {
1269 CK_IntegralToFloating);
1280 CK_IntegralComplexToFloatingComplex);
1285 CK_FloatingRealToComplex);
1294 QualType RHSType,
bool IsCompAssign) {
1304 else if (!IsCompAssign)
1306 return LHSFloat ? LHSType : RHSType;
1311 if (LHSFloat && RHSFloat) {
1318 assert(order < 0 &&
"illegal float comparison");
1352 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1358 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1359 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1360 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1361 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1378 CK_IntegralComplexCast);
1384 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1387 QualType RHSType,
bool IsCompAssign) {
1392 if (LHSSigned == RHSSigned) {
1395 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1397 }
else if (!IsCompAssign)
1398 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1400 }
else if (order != (LHSSigned ? 1 : -1)) {
1404 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1406 }
else if (!IsCompAssign)
1407 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1414 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1416 }
else if (!IsCompAssign)
1417 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1426 RHS = (*doRHSCast)(S, RHS.
get(), result);
1428 LHS = (*doLHSCast)(S, LHS.
get(), result);
1438 bool IsCompAssign) {
1442 if (LHSComplexInt && RHSComplexInt) {
1446 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1447 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1452 if (LHSComplexInt) {
1455 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1456 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1459 CK_IntegralRealToComplex);
1464 assert(RHSComplexInt);
1468 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1469 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1474 CK_IntegralRealToComplex);
1483 assert(BTy &&
"Expected a builtin type.");
1485 switch (BTy->getKind()) {
1486 case BuiltinType::ShortFract:
1487 case BuiltinType::UShortFract:
1488 case BuiltinType::SatShortFract:
1489 case BuiltinType::SatUShortFract:
1491 case BuiltinType::Fract:
1492 case BuiltinType::UFract:
1493 case BuiltinType::SatFract:
1494 case BuiltinType::SatUFract:
1496 case BuiltinType::LongFract:
1497 case BuiltinType::ULongFract:
1498 case BuiltinType::SatLongFract:
1499 case BuiltinType::SatULongFract:
1501 case BuiltinType::ShortAccum:
1502 case BuiltinType::UShortAccum:
1503 case BuiltinType::SatShortAccum:
1504 case BuiltinType::SatUShortAccum:
1506 case BuiltinType::Accum:
1507 case BuiltinType::UAccum:
1508 case BuiltinType::SatAccum:
1509 case BuiltinType::SatUAccum:
1511 case BuiltinType::LongAccum:
1512 case BuiltinType::ULongAccum:
1513 case BuiltinType::SatLongAccum:
1514 case BuiltinType::SatULongAccum:
1517 if (BTy->isInteger())
1519 llvm_unreachable(
"Unexpected fixed point or integer type");
1531 "Expected at least one of the operands to be a fixed point type");
1534 "Special fixed point arithmetic operation conversions are only "
1535 "applied to ints or other fixed point types");
1557 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1580 REnum = R->isUnscopedEnumerationType();
1582 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1585 ? diag::err_arith_conv_enum_float_cxx26
1587 ? diag::warn_arith_conv_enum_float_cxx20
1588 : diag::warn_arith_conv_enum_float)
1591 }
else if (!IsCompAssign && LEnum && REnum &&
1597 DiagID = diag::err_conv_mixed_enum_types_cxx26;
1599 !R->castAs<
EnumType>()->getDecl()->hasNameForLinkage()) {
1604 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1605 : diag::warn_arith_conv_mixed_anon_enum_types;
1610 ? diag::warn_conditional_mixed_enum_types_cxx20
1611 : diag::warn_conditional_mixed_enum_types;
1616 ? diag::warn_comparison_mixed_enum_types_cxx20
1617 : diag::warn_comparison_mixed_enum_types;
1620 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1621 : diag::warn_arith_conv_mixed_enum_types;
1624 << (
int)ACK << L << R;
1637 if (ACK != ACK_CompAssign) {
1638 LHS = UsualUnaryConversions(LHS.
get());
1643 RHS = UsualUnaryConversions(RHS.
get());
1654 LHSType = AtomicLHS->getValueType();
1666 QualType LHSUnpromotedType = LHSType;
1670 if (!LHSBitfieldPromoteTy.
isNull())
1671 LHSType = LHSBitfieldPromoteTy;
1672 if (LHSType != LHSUnpromotedType && ACK != ACK_CompAssign)
1673 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1689 ACK == ACK_CompAssign);
1694 ACK == ACK_CompAssign);
1699 ACK == ACK_CompAssign);
1705 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1706 (*
this, LHS, RHS, LHSType, RHSType, ACK == ACK_CompAssign);
1716 bool PredicateIsExpr,
void *ControllingExprOrType,
1718 unsigned NumAssocs = ArgTypes.size();
1719 assert(NumAssocs == ArgExprs.size());
1722 for (
unsigned i = 0; i < NumAssocs; ++i) {
1724 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1731 if (!PredicateIsExpr) {
1735 assert(ControllingType &&
"couldn't get the type out of the parser");
1736 ControllingExprOrType = ControllingType;
1740 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1748 bool PredicateIsExpr,
void *ControllingExprOrType,
1750 unsigned NumAssocs = Types.size();
1751 assert(NumAssocs == Exprs.size());
1752 assert(ControllingExprOrType &&
1753 "Must have either a controlling expression or a controlling type");
1755 Expr *ControllingExpr =
nullptr;
1757 if (PredicateIsExpr) {
1763 ExprResult R = DefaultFunctionArrayLvalueConversion(
1764 reinterpret_cast<Expr *
>(ControllingExprOrType));
1767 ControllingExpr = R.
get();
1770 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1771 if (!ControllingType)
1775 bool TypeErrorFound =
false,
1776 IsResultDependent = ControllingExpr
1779 ContainsUnexpandedParameterPack =
1786 if (!inTemplateInstantiation() && !IsResultDependent && ControllingExpr &&
1789 diag::warn_side_effects_unevaluated_context);
1791 for (
unsigned i = 0; i < NumAssocs; ++i) {
1792 if (Exprs[i]->containsUnexpandedParameterPack())
1793 ContainsUnexpandedParameterPack =
true;
1796 if (Types[i]->getType()->containsUnexpandedParameterPack())
1797 ContainsUnexpandedParameterPack =
true;
1799 if (Types[i]->getType()->isDependentType()) {
1800 IsResultDependent =
true;
1813 if (ControllingExpr && Types[i]->getType()->isIncompleteType())
1814 D = diag::err_assoc_type_incomplete;
1815 else if (ControllingExpr && !Types[i]->getType()->isObjectType())
1816 D = diag::err_assoc_type_nonobject;
1817 else if (Types[i]->getType()->isVariablyModifiedType())
1818 D = diag::err_assoc_type_variably_modified;
1819 else if (ControllingExpr) {
1838 unsigned Reason = 0;
1847 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1848 diag::warn_unreachable_association)
1849 << QT << (Reason - 1);
1853 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1854 << Types[i]->getTypeLoc().getSourceRange()
1855 << Types[i]->getType();
1856 TypeErrorFound =
true;
1861 for (
unsigned j = i+1; j < NumAssocs; ++j)
1862 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1864 Types[j]->getType())) {
1865 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1866 diag::err_assoc_compatible_types)
1867 << Types[j]->getTypeLoc().getSourceRange()
1868 << Types[j]->getType()
1869 << Types[i]->getType();
1870 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1871 diag::note_compat_assoc)
1872 << Types[i]->getTypeLoc().getSourceRange()
1873 << Types[i]->getType();
1874 TypeErrorFound =
true;
1884 if (IsResultDependent) {
1885 if (ControllingExpr)
1887 Types, Exprs, DefaultLoc, RParenLoc,
1888 ContainsUnexpandedParameterPack);
1890 Exprs, DefaultLoc, RParenLoc,
1891 ContainsUnexpandedParameterPack);
1895 unsigned DefaultIndex = -1U;
1899 for (
unsigned i = 0; i < NumAssocs; ++i) {
1902 else if (ControllingExpr &&
1905 Types[i]->getType()))
1906 CompatIndices.push_back(i);
1907 else if (ControllingType &&
1910 Types[i]->getType()))
1911 CompatIndices.push_back(i);
1914 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
1918 if (ControllingExpr)
1927 return std::make_pair(SR, QT);
1933 if (CompatIndices.size() > 1) {
1934 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1937 << SR <<
P.second << (
unsigned)CompatIndices.size();
1938 for (
unsigned I : CompatIndices) {
1939 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1940 diag::note_compat_assoc)
1941 << Types[I]->getTypeLoc().getSourceRange()
1942 << Types[I]->getType();
1950 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1951 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1953 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR <<
P.second;
1962 unsigned ResultIndex =
1963 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1965 if (ControllingExpr) {
1967 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1968 ContainsUnexpandedParameterPack, ResultIndex);
1971 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
1972 ContainsUnexpandedParameterPack, ResultIndex);
1978 llvm_unreachable(
"unexpected TokenKind");
1979 case tok::kw___func__:
1981 case tok::kw___FUNCTION__:
1983 case tok::kw___FUNCDNAME__:
1985 case tok::kw___FUNCSIG__:
1987 case tok::kw_L__FUNCTION__:
1989 case tok::kw_L__FUNCSIG__:
1991 case tok::kw___PRETTY_FUNCTION__:
2000 while (DC && !isa<BlockDecl, CapturedDecl, FunctionDecl, ObjCMethodDecl>(DC))
2002 return cast_or_null<Decl>(DC);
2020 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
2023 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2024 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
2025 if (ArgTy[ArgIdx]->isArrayType())
2046 std::vector<Token> ExpandedToks;
2047 if (getLangOpts().MicrosoftExt)
2048 StringToks = ExpandedToks = ExpandFunctionLocalPredefinedMacros(StringToks);
2056 for (
const Token &Tok : StringToks)
2057 StringTokLocs.push_back(Tok.getLocation());
2061 &StringTokLocs[0], StringTokLocs.size());
2063 if (!
Literal.getUDSuffix().empty()) {
2067 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2080 assert(getLangOpts().MicrosoftExt);
2089 std::vector<Token> ExpandedToks;
2090 ExpandedToks.reserve(Toks.size());
2091 for (
const Token &Tok : Toks) {
2094 ExpandedToks.emplace_back(Tok);
2097 if (isa<TranslationUnitDecl>(CurrentDecl))
2098 Diag(Tok.getLocation(), diag::ext_predef_outside_function);
2100 Diag(Tok.getLocation(), diag::ext_string_literal_from_predefined)
2103 llvm::raw_svector_ostream OS(Str);
2104 Token &Exp = ExpandedToks.emplace_back();
2106 if (Tok.getKind() == tok::kw_L__FUNCTION__ ||
2107 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2109 Exp.
setKind(tok::wide_string_literal);
2111 Exp.
setKind(tok::string_literal);
2117 PP.CreateString(OS.str(), Exp, Tok.
getLocation(), Tok.getEndLoc());
2119 return ExpandedToks;
2130 assert(!StringToks.empty() &&
"Must have at least one string!");
2133 std::vector<Token> ExpandedToks;
2134 if (getLangOpts().MicrosoftExt)
2135 StringToks = ExpandedToks = ExpandFunctionLocalPredefinedMacros(StringToks);
2142 for (
const Token &Tok : StringToks)
2143 StringTokLocs.push_back(Tok.getLocation());
2150 }
else if (
Literal.isUTF8()) {
2151 if (getLangOpts().Char8)
2154 }
else if (
Literal.isUTF16()) {
2157 }
else if (
Literal.isUTF32()) {
2160 }
else if (
Literal.isPascal()) {
2168 Diag(StringTokLocs.front(), diag::warn_cxx20_compat_utf8_string);
2174 auto RemovalDiag = PDiag(diag::note_cxx20_compat_utf8_string_remove_u8);
2176 for (
const Token &Tok : StringToks) {
2177 if (Tok.getKind() == tok::utf8_string_literal) {
2179 RemovalDiagLoc = Tok.getLocation();
2183 getSourceManager(), getLangOpts())));
2186 Diag(RemovalDiagLoc, RemovalDiag);
2196 StringTokLocs.size());
2197 if (
Literal.getUDSuffix().empty())
2208 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2223 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
2224 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
2233 Expr *Args[] = { Lit, LenArg };
2235 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
2238 case LOLR_Template: {
2243 return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt,
2244 StringTokLocs.back(), &ExplicitArgs);
2247 case LOLR_StringTemplatePack: {
2258 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2264 return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt,
2265 StringTokLocs.back(), &ExplicitArgs);
2268 case LOLR_ErrorNoDiagnostic:
2269 llvm_unreachable(
"unexpected literal operator lookup result");
2273 llvm_unreachable(
"unexpected literal operator lookup result");
2281 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
2292 return BuildDeclRefExpr(D, Ty, VK, NameInfo, NNS, FoundD, TemplateKWLoc,
2305 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2308 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2309 if (!Referee || !Referee->hasGlobalStorage() ||
2310 Referee->hasAttr<CUDADeviceAttr>())
2316 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2317 if (MD && MD->getParent()->isLambda() &&
2318 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2327 if (isUnevaluatedContext())
2340 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2341 if (VD->getType()->isReferenceType() &&
2342 !(getLangOpts().OpenMP && OpenMP().isOpenMPCapturedDecl(D)) &&
2344 VD->isUsableInConstantExpressions(Context))
2361 bool RefersToCapturedVariable = isa<VarDecl, BindingDecl>(D) &&
2362 NeedToCaptureVariable(D, NameInfo.
getLoc());
2365 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2366 VK, FoundD, TemplateArgs, getNonOdrUseReasonInCurrentContext(D));
2367 MarkDeclRefReferenced(E);
2383 if (
const auto *NewFPT = ResolveExceptionSpec(NameInfo.
getLoc(), FPT))
2388 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
2390 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->
getBeginLoc()))
2391 getCurFunction()->recordUseOfWeak(E);
2393 const auto *FD = dyn_cast<FieldDecl>(D);
2394 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2395 FD = IFD->getAnonField();
2397 UnusedPrivateFields.remove(FD);
2399 if (FD->isBitField())
2405 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2406 if (
const auto *BE = BD->getBinding())
2431 Id.TemplateId->NumArgs);
2432 translateTemplateArguments(TemplateArgsPtr, Buffer);
2437 TemplateArgs = &Buffer;
2439 NameInfo = GetNameFromUnqualifiedId(
Id);
2440 TemplateArgs =
nullptr;
2447 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
2454 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
2457 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
2462 bool DroppedSpecifier =
2465 ? diag::note_implicit_param_decl
2466 : diag::note_previous_decl;
2469 SemaRef.
PDiag(NoteID));
2472 << Typo << Ctx << DroppedSpecifier
2474 SemaRef.
PDiag(NoteID));
2489 bool isDefaultArgument =
2490 !CodeSynthesisContexts.empty() &&
2491 CodeSynthesisContexts.back().Kind ==
2492 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
2493 const auto *CurMethod = dyn_cast<CXXMethodDecl>(CurContext);
2494 bool isInstance = CurMethod && CurMethod->isInstance() &&
2503 unsigned DiagID = diag::err_found_in_dependent_base;
2504 unsigned NoteID = diag::note_member_declared_at;
2506 DiagID = getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2507 : diag::err_found_later_in_class;
2508 }
else if (getLangOpts().MSVCCompat) {
2509 DiagID = diag::ext_found_in_dependent_base;
2510 NoteID = diag::note_dependent_member_use;
2526 Diag(D->getLocation(), NoteID);
2535 if (isDefaultArgument && ((*R.
begin())->isCXXInstanceMember())) {
2554 unsigned diagnostic = diag::err_undeclared_var_use;
2555 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2559 diagnostic = diag::err_undeclared_use;
2560 diagnostic_suggest = diag::err_undeclared_use_suggest;
2568 LookupCtx ? LookupCtx : (SS.
isEmpty() ? CurContext :
nullptr);
2570 if (isa<CXXRecordDecl>(DC)) {
2571 LookupQualifiedName(R, DC);
2581 AddOverloadedCallCandidates(R, ExplicitTemplateArgs, Args, Candidates);
2586 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2590 return DiagnoseDependentMemberLookup(R);
2603 assert(!ExplicitTemplateArgs &&
2604 "Diagnosing an empty lookup with explicit template args!");
2605 *Out = CorrectTypoDelayed(
2608 emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args,
2609 diagnostic, diagnostic_suggest);
2611 nullptr, CTK_ErrorRecovery, LookupCtx);
2614 }
else if (S && (Corrected =
2616 &SS, CCC, CTK_ErrorRecovery, LookupCtx))) {
2617 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
2618 bool DroppedSpecifier =
2622 bool AcceptableWithRecovery =
false;
2623 bool AcceptableWithoutRecovery =
false;
2632 dyn_cast<FunctionTemplateDecl>(CD))
2633 AddTemplateOverloadCandidate(
2636 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2637 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2643 ND = Best->FoundDecl;
2644 Corrected.setCorrectionDecl(ND);
2648 Corrected.setCorrectionDecl(ND);
2660 Record = cast<CXXRecordDecl>(
2666 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2667 isa<FunctionTemplateDecl>(UnderlyingND);
2673 AcceptableWithoutRecovery = isa<TypeDecl>(UnderlyingND) ||
2675 isa<ObjCInterfaceDecl>(UnderlyingND);
2679 AcceptableWithoutRecovery =
true;
2682 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2684 ? diag::note_implicit_param_decl
2685 : diag::note_previous_decl;
2687 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2688 PDiag(NoteID), AcceptableWithRecovery);
2690 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2691 << Name << computeDeclContext(SS,
false)
2692 << DroppedSpecifier << SS.
getRange(),
2693 PDiag(NoteID), AcceptableWithRecovery);
2696 return !AcceptableWithRecovery;
2705 << Name << computeDeclContext(SS,
false)
2732 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2740 auto DB = S.
Diag(
Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2741 DB << NameInfo.
getName() << RD;
2743 if (!ThisType.
isNull()) {
2746 Context,
nullptr, ThisType,
true,
2748 nullptr, NameInfo, TemplateArgs);
2765 bool HasTrailingLParen,
bool IsAddressOfOperand,
2767 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2768 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2769 "cannot be direct & operand and have a trailing lparen");
2778 DecomposeUnqualifiedId(
Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2794 if (isBoundsAttrContext() && !getLangOpts().
CPlusPlus && S->isClassScope()) {
2798 if (LookupName(R, S)) {
2799 if (
auto *VD = dyn_cast<ValueDecl>(R.
getFoundDecl())) {
2811 ? LookupObjCImplicitSelfParam
2812 : LookupOrdinaryName);
2813 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2820 if (LookupTemplateName(R, S, SS,
QualType(),
2821 false, TemplateKWLoc,
2826 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2827 IsAddressOfOperand, TemplateArgs);
2829 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2830 LookupParsedName(R, S, &SS,
QualType(),
2831 !IvarLookupFollowUp);
2836 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2837 IsAddressOfOperand, TemplateArgs);
2841 if (IvarLookupFollowUp) {
2842 ExprResult E(ObjC().LookupInObjCMethod(R, S, II,
true));
2856 if (R.
empty() && HasTrailingLParen && II &&
2857 getLangOpts().implicitFunctionsAllowed()) {
2858 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2864 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2866 if (R.
empty() && !ADL) {
2867 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2869 TemplateKWLoc, TemplateArgs))
2874 if (IsInlineAsmIdentifier)
2884 "Typo correction callback misconfigured");
2894 if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator,
nullptr,
2895 std::nullopt,
nullptr, &TE)) {
2896 if (TE && KeywordReplacement) {
2897 auto &
State = getTypoExprState(TE);
2898 auto BestTC =
State.Consumer->getNextCorrection();
2899 if (BestTC.isKeyword()) {
2900 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2901 if (
State.DiagHandler)
2902 State.DiagHandler(BestTC);
2906 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2909 clearDelayedTypo(TE);
2912 return (
Expr*)
nullptr;
2914 State.Consumer->resetCorrectionStream();
2919 assert(!R.
empty() &&
2920 "DiagnoseEmptyLookup returned false but added no results");
2927 ExprResult E(ObjC().LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2937 assert(!R.
empty() || ADL);
2963 if (isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
2964 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs,
2967 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2975 "There should only be one declaration found.");
2978 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2981 return BuildDeclarationNameExpr(SS, R, ADL);
2992 LookupParsedName(R,
nullptr, &SS,
QualType());
3007 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
3008 if (CD->isInvalidDecl())
3019 unsigned DiagID = diag::err_typename_missing;
3020 if (RecoveryTSI && getLangOpts().MSVCCompat)
3021 DiagID = diag::ext_typename_missing;
3051 if (isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
3052 return BuildPossibleImplicitMemberExpr(SS,
3057 return BuildDeclarationNameExpr(SS, R,
false);
3085 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3093 bool PointerConversions =
false;
3094 if (isa<FieldDecl>(
Member)) {
3098 DestRecordType, FromPtrType
3105 PointerConversions =
true;
3107 DestType = DestRecordType;
3108 FromRecordType = FromType;
3110 }
else if (
const auto *Method = dyn_cast<CXXMethodDecl>(
Member)) {
3111 if (!Method->isImplicitObjectMemberFunction())
3114 DestType = Method->getThisType().getNonReferenceType();
3115 DestRecordType = Method->getFunctionObjectParameterType();
3119 PointerConversions =
true;
3121 FromRecordType = FromType;
3122 DestType = DestRecordType;
3127 if (FromAS != DestAS) {
3132 if (PointerConversions)
3134 From = ImpCastExprToType(From, FromTypeWithDestAS,
3173 if (Qualifier && Qualifier->getAsType()) {
3175 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3182 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
3184 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
3185 FromLoc, FromRange, &BasePath))
3188 if (PointerConversions)
3190 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
3191 VK, &BasePath).get();
3194 FromRecordType = QRecordType;
3204 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
3205 FromLoc, FromRange, &BasePath,
3209 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
3215 bool HasTrailingLParen) {
3217 if (!HasTrailingLParen)
3235 if (D->isCXXClassMember())
3244 if (isa<UsingShadowDecl>(D))
3245 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3246 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3253 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3255 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3257 }
else if (!isa<FunctionTemplateDecl>(D))
3270 bool AcceptInvalid) {
3274 if (isa<TypedefNameDecl>(D)) {
3279 if (isa<ObjCInterfaceDecl>(D)) {
3284 if (isa<NamespaceDecl>(D)) {
3296 const auto *FD = dyn_cast<FunctionDecl>(R.
getFoundDecl());
3298 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3303 bool AcceptInvalidDecl) {
3342 bool AcceptInvalidDecl) {
3343 assert(D &&
"Cannot refer to a NULL declaration");
3344 assert(!isa<FunctionTemplateDecl>(D) &&
3345 "Cannot refer unambiguously to a function template");
3355 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
3363 if (!isa<ValueDecl, UnresolvedUsingIfExistsDecl>(D)) {
3373 if (DiagnoseUseOfDecl(D,
Loc))
3376 auto *VD = cast<ValueDecl>(D);
3379 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3385 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3386 IndirectField && !IndirectField->isCXXClassMember())
3387 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
3398 type =
type.getNonPackExpansionType();
3402 #define ABSTRACT_DECL(kind)
3403 #define VALUE(type, base)
3404 #define DECL(type, base) case Decl::type:
3405 #include "clang/AST/DeclNodes.inc"
3406 llvm_unreachable(
"invalid value decl kind");
3409 case Decl::ObjCAtDefsField:
3410 llvm_unreachable(
"forming non-member reference to ivar?");
3414 case Decl::EnumConstant:
3415 case Decl::UnresolvedUsingValue:
3416 case Decl::OMPDeclareReduction:
3417 case Decl::OMPDeclareMapper:
3426 case Decl::IndirectField:
3427 case Decl::ObjCIvar:
3428 assert((getLangOpts().
CPlusPlus || isBoundsAttrContext()) &&
3429 "building reference to field in C?");
3439 case Decl::NonTypeTemplateParm: {
3441 type = reftype->getPointeeType();
3451 if (
type->isRecordType()) {
3452 type =
type.getUnqualifiedType().withConst();
3465 case Decl::VarTemplateSpecialization:
3466 case Decl::VarTemplatePartialSpecialization:
3467 case Decl::Decomposition:
3468 case Decl::OMPCapturedExpr:
3471 type->isVoidType()) {
3477 case Decl::ImplicitParam:
3478 case Decl::ParmVar: {
3486 if (!isUnevaluatedContext()) {
3487 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD),
Loc);
3488 if (!CapturedType.
isNull())
3489 type = CapturedType;
3501 case Decl::Function: {
3502 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3521 if (getLangOpts().CPlusPlus) {
3531 if (!cast<FunctionDecl>(VD)->hasPrototype() && isa<FunctionProtoType>(fty))
3540 case Decl::CXXDeductionGuide:
3541 llvm_unreachable(
"building reference to deduction guide");
3543 case Decl::MSProperty:
3545 case Decl::TemplateParamObject:
3551 case Decl::UnnamedGlobalConstant:
3555 case Decl::CXXMethod:
3560 dyn_cast<FunctionProtoType>(VD->getType()))
3568 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3574 case Decl::CXXConversion:
3575 case Decl::CXXDestructor:
3576 case Decl::CXXConstructor:
3582 BuildDeclRefExpr(VD,
type, valueKind, NameInfo, &SS, FoundD,
3588 if (VD->isInvalidDecl() && E)
3589 return CreateRecoveryExpr(E->getBeginLoc(), E->getEndLoc(), {E});
3595 Target.resize(CharByteWidth * (Source.size() + 1));
3596 char *ResultPtr = &
Target[0];
3597 const llvm::UTF8 *ErrorPtr;
3599 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3609 Diag(
Loc, diag::ext_predef_outside_function);
3615 if (cast<DeclContext>(currentDecl)->isDependentContext())
3620 bool ForceElaboratedPrinting =
3624 unsigned Length = Str.length();
3659 bool Invalid =
false;
3660 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3672 else if (
Literal.isUTF8() && getLangOpts().
C23)
3674 else if (
Literal.isUTF8() && getLangOpts().Char8)
3699 if (
Literal.getUDSuffix().empty())
3709 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3731 if (RM == llvm::RoundingMode::Dynamic)
3732 RM = llvm::RoundingMode::NearestTiesToEven;
3733 APFloat::opStatus result =
Literal.GetFloatValue(Val, RM);
3737 if ((result & APFloat::opOverflow) ||
3738 ((result & APFloat::opUnderflow) && Val.isZero())) {
3739 unsigned diagnostic;
3741 if (result & APFloat::opOverflow) {
3742 diagnostic = diag::warn_float_overflow;
3743 APFloat::getLargest(Format).toString(buffer);
3745 diagnostic = diag::warn_float_underflow;
3746 APFloat::getSmallest(Format).toString(buffer);
3749 S.
Diag(
Loc, diagnostic) << Ty << buffer.str();
3752 bool isExact = (result == APFloat::opOK);
3757 assert(E &&
"Invalid expression");
3764 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3769 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3779 bool ValueIsPositive =
3780 AllowZero ? ValueAPS.isNonNegative() : ValueAPS.isStrictlyPositive();
3781 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3782 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3783 <<
toString(ValueAPS, 10) << ValueIsPositive;
3794 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3795 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3803 SpellingBuffer.resize(Tok.
getLength() + 1);
3806 bool Invalid =
false;
3807 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3812 PP.getSourceManager(), PP.getLangOpts(),
3813 PP.getTargetInfo(), PP.getDiagnostics());
3825 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3828 if (
Literal.isFloatingLiteral()) {
3849 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3850 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3854 case LOLR_ErrorNoDiagnostic:
3862 if (
Literal.isFloatingLiteral()) {
3866 if (
Literal.GetIntegerValue(ResultVal))
3872 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3879 unsigned Length =
Literal.getUDSuffixOffset();
3886 false, StrTy, &TokLoc, 1);
3887 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3890 case LOLR_Template: {
3897 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3899 for (
unsigned I = 0, N =
Literal.getUDSuffixOffset(); I != N; ++I) {
3900 Value = TokSpelling[I];
3905 return BuildLiteralOperatorCall(R, OpNameInfo, std::nullopt, TokLoc,
3908 case LOLR_StringTemplatePack:
3909 llvm_unreachable(
"unexpected literal operator lookup result");
3915 if (
Literal.isFixedPointLiteral()) {
3938 bool isSigned = !
Literal.isUnsigned;
3943 bool Overflowed =
Literal.GetFixedPointValue(Val, scale);
3944 bool ValIsZero = Val.isZero() && !Overflowed;
3947 if (
Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3953 else if (Val.ugt(MaxVal) || Overflowed)
3958 }
else if (
Literal.isFloatingLiteral()) {
3961 if (getLangOpts().
HLSL ||
3962 getOpenCLOptions().isAvailableOption(
"cl_khr_fp16", getLangOpts()))
3976 else if (getLangOpts().
HLSL)
3984 if (getLangOpts().SinglePrecisionConstants) {
3986 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3988 }
else if (getLangOpts().
OpenCL && !getOpenCLOptions().isAvailableOption(
3989 "cl_khr_fp64", getLangOpts())) {
3992 << (getLangOpts().getOpenCLCompatibleVersion() >= 300);
3993 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3996 }
else if (!
Literal.isIntegerLiteral()) {
4005 ? diag::warn_cxx20_compat_size_t_suffix
4006 : diag::ext_cxx23_size_t_suffix
4007 : diag::err_cxx23_size_t_suffix);
4016 getLangOpts().
CPlusPlus ? diag::ext_cxx_bitint_suffix
4017 : getLangOpts().
C23 ? diag::warn_c23_compat_bitint_suffix
4018 : diag::ext_c23_bitint_suffix);
4027 unsigned BitsNeeded =
4028 Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
4033 if (
Literal.GetIntegerValue(ResultVal)) {
4038 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
4039 "long long is not intmax_t?");
4046 bool AllowUnsigned =
Literal.isUnsigned ||
Literal.getRadix() != 10;
4061 if (
Literal.MicrosoftInteger) {
4066 Width =
Literal.MicrosoftInteger;
4077 Width =
std::max(ResultVal.getActiveBits(), 1u) +
4078 (
Literal.isUnsigned ? 0u : 1u);
4082 unsigned int MaxBitIntWidth =
4084 if (Width > MaxBitIntWidth) {
4087 Width = MaxBitIntWidth;
4094 ResultVal = ResultVal.zextOrTrunc(Width);
4100 assert(!
Literal.MicrosoftInteger &&
4101 "size_t literals can't be Microsoft literals");
4106 if (ResultVal.isIntN(SizeTSize)) {
4108 if (!
Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4110 else if (AllowUnsigned)
4122 if (ResultVal.isIntN(IntSize)) {
4124 if (!
Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4126 else if (AllowUnsigned)
4137 if (ResultVal.isIntN(LongSize)) {
4139 if (!
Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4141 else if (AllowUnsigned)
4146 const unsigned LongLongSize =
4151 ? diag::warn_old_implicitly_unsigned_long_cxx
4153 ext_old_implicitly_unsigned_long_cxx
4154 : diag::warn_old_implicitly_unsigned_long)
4155 << (LongLongSize > LongSize ? 0
4168 if (ResultVal.isIntN(LongLongSize)) {
4172 if (!
Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4173 (getLangOpts().MSVCCompat &&
Literal.isLongLong)))
4175 else if (AllowUnsigned)
4177 Width = LongLongSize;
4181 if (getLangOpts().CPlusPlus)
4183 ? diag::warn_cxx98_compat_longlong
4184 : diag::ext_cxx11_longlong);
4185 else if (!getLangOpts().C99)
4199 diag::ext_integer_literal_too_large_for_signed);
4204 if (ResultVal.getBitWidth() != Width)
4205 ResultVal = ResultVal.trunc(Width);
4221 assert(E &&
"ActOnParenExpr() missing expr");
4223 if (getLangOpts().ProtectParens && CurFPFeatures.getAllowFPReassociate() &&
4225 return BuildBuiltinCallExpr(R, Builtin::BI__arithmetic_fence, E);
4226 return new (Context)
ParenExpr(L, R, E);
4237 S.
Diag(
Loc, diag::err_vecstep_non_scalar_vector_type)
4243 "Scalar types should always be complete");
4252 return S.
Diag(
Loc, diag::err_builtin_non_vector_type)
4254 <<
"__builtin_vectorelements" <<
T << ArgRange;
4269 (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4270 TraitKind == UETT_PreferredAlignOf)) {
4272 S.
Diag(
Loc, diag::ext_sizeof_alignof_function_type)
4280 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4281 : diag::ext_sizeof_alignof_void_type;
4296 S.
Diag(
Loc, diag::err_sizeof_nonfragile_interface)
4297 <<
T << (TraitKind == UETT_SizeOf)
4314 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4315 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4318 S.
Diag(
Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4320 << ICE->getSubExpr()->getType();
4335 bool IsUnevaluatedOperand =
4336 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4337 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4338 ExprKind == UETT_VecStep);
4339 if (IsUnevaluatedOperand) {
4340 ExprResult Result = CheckUnevaluatedOperand(E);
4341 if (Result.isInvalid())
4351 if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
4355 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4357 if (ExprKind == UETT_VecStep)
4361 if (ExprKind == UETT_VectorElements)
4383 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4384 if (RequireCompleteSizedType(
4386 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4390 if (RequireCompleteSizedExprType(
4391 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4410 if (ExprKind == UETT_SizeOf) {
4411 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4412 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4413 QualType OType = PVD->getOriginalType();
4418 Diag(PVD->getLocation(), diag::note_declared_at);
4426 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4443 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4450 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4452 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4453 D = ME->getMemberDecl();
4473 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4476 if (!FD->getParent()->isCompleteDefinition()) {
4477 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4486 if (!FD->getType()->isReferenceType())
4500 return CheckUnaryExprOrTypeTraitOperand(E, UETT_VecStep);
4506 assert(CSI !=
nullptr);
4510 const Type *Ty =
T.getTypePtr();
4512 #define TYPE(Class, Base)
4513 #define ABSTRACT_TYPE(Class, Base)
4514 #define NON_CANONICAL_TYPE(Class, Base)
4515 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
4516 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4517 #include "clang/AST/TypeNodes.inc"
4524 case Type::ExtVector:
4525 case Type::ConstantMatrix:
4528 case Type::TemplateSpecialization:
4529 case Type::ObjCObject:
4530 case Type::ObjCInterface:
4531 case Type::ObjCObjectPointer:
4532 case Type::ObjCTypeParam:
4535 llvm_unreachable(
"type class is never variably-modified!");
4536 case Type::Elaborated:
4537 T = cast<ElaboratedType>(Ty)->getNamedType();
4539 case Type::Adjusted:
4540 T = cast<AdjustedType>(Ty)->getOriginalType();
4545 case Type::ArrayParameter:
4546 T = cast<ArrayParameterType>(Ty)->getElementType();
4551 case Type::BlockPointer:
4554 case Type::LValueReference:
4555 case Type::RValueReference:
4558 case Type::MemberPointer:
4561 case Type::ConstantArray:
4562 case Type::IncompleteArray:
4564 T = cast<ArrayType>(Ty)->getElementType();
4566 case Type::VariableArray: {
4574 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4580 case Type::FunctionProto:
4581 case Type::FunctionNoProto:
4586 case Type::UnaryTransform:
4587 case Type::Attributed:
4588 case Type::BTFTagAttributed:
4589 case Type::SubstTemplateTypeParm:
4590 case Type::MacroQualified:
4591 case Type::CountAttributed:
4593 T =
T.getSingleStepDesugaredType(Context);
4596 T = cast<TypedefType>(Ty)->
desugar();
4598 case Type::Decltype:
4599 T = cast<DecltypeType>(Ty)->
desugar();
4601 case Type::PackIndexing:
4602 T = cast<PackIndexingType>(Ty)->
desugar();
4605 T = cast<UsingType>(Ty)->
desugar();
4608 case Type::DeducedTemplateSpecialization:
4609 T = cast<DeducedType>(Ty)->getDeducedType();
4611 case Type::TypeOfExpr:
4612 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4615 T = cast<AtomicType>(Ty)->getValueType();
4656 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4657 ExprKind == UETT_OpenMPRequiredSimdAlign)
4660 if (ExprKind == UETT_VecStep)
4663 if (ExprKind == UETT_VectorElements)
4672 if (RequireCompleteSizedType(
4673 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4678 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4686 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4697 for (
auto I = FunctionScopes.rbegin(),
4698 E = std::prev(FunctionScopes.rend());
4700 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4704 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4705 DC = LSI->CallOperator;
4706 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4707 DC = CRSI->TheCapturedDecl;
4708 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4733 CheckUnaryExprOrTypeTraitOperand(
T, OpLoc, R, ExprKind,
4739 if (isUnevaluatedContext() && ExprKind == UETT_SizeOf &&
4741 TInfo = TransformToPotentiallyEvaluated(TInfo);
4763 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4765 }
else if (ExprKind == UETT_VecStep) {
4767 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4771 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4773 }
else if (ExprKind == UETT_VectorElements) {
4774 isInvalid = CheckUnaryExprOrTypeTraitOperand(E, UETT_VectorElements);
4776 isInvalid = CheckUnaryExprOrTypeTraitOperand(E, UETT_SizeOf);
4783 PE = TransformToPotentiallyEvaluated(E);
4806 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4810 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4818 return CheckUnaryExprOrTypeTraitOperand(TInfo->
getType(), OpLoc, R,
4819 UETT_AlignOf, KWName);
4834 return CheckAlignasTypeArgument(KWName, TInfo, OpLoc, R);
4839 if (
V.get()->isTypeDependent())
4851 return CT->getElementType();
4854 if (
V.get()->getType()->isArithmeticType())
4855 return V.get()->getType();
4860 if (PR.
get() !=
V.get()) {
4866 S.
Diag(
Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
4867 << (IsReal ?
"__real" :
"__imag");
4878 default: llvm_unreachable(
"Unknown unary op!");
4879 case tok::plusplus: Opc = UO_PostInc;
break;
4880 case tok::minusminus: Opc = UO_PostDec;
break;
4884 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4885 if (Result.isInvalid())
return ExprError();
4886 Input = Result.get();
4888 return BuildUnaryOp(S, OpLoc, Opc, Input);
4899 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4902 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4909 auto *BaseNoParens =
Base->IgnoreParens();
4910 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4911 return MSProp->getPropertyDecl()->getType()->isArrayType();
4912 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4932 if (RTy->isIntegralOrUnscopedEnumerationType()) {
4934 Result = PT->getPointeeType();
4936 Result = AT->getElementType();
4939 Result = PT->getPointeeType();
4941 Result = AT->getElementType();
4944 return Result->isDependentType() ? Result : Ctx.
DependentTy;
4954 auto *AS = cast<ArraySectionExpr>(base);
4955 if (AS->isOMPArraySection())
4956 return OpenMP().ActOnOMPArraySectionExpr(
4961 return OpenACC().ActOnArraySectionExpr(base, lbLoc, ArgExprs.front(),
4967 if (isa<ParenListExpr>(base)) {
4968 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4971 base = result.
get();
4978 auto CheckAndReportCommaError = [
this, base, rbLoc](
Expr *E) {
4979 if (isa<BinaryOperator>(E) && cast<BinaryOperator>(E)->isCommaOp()) {
4980 Diag(E->getExprLoc(), diag::err_matrix_subscript_comma)
4990 !isa<MatrixSubscriptExpr>(base)) {
4991 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
4997 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
4998 if (matSubscriptE) {
4999 assert(ArgExprs.size() == 1);
5000 if (CheckAndReportCommaError(ArgExprs.front()))
5003 assert(matSubscriptE->isIncomplete() &&
5004 "base has to be an incomplete matrix subscript");
5005 return CreateBuiltinMatrixSubscriptExpr(matSubscriptE->getBase(),
5006 matSubscriptE->getRowIdx(),
5007 ArgExprs.front(), rbLoc);
5020 bool IsMSPropertySubscript =
false;
5023 if (!IsMSPropertySubscript) {
5024 ExprResult result = CheckPlaceholderExpr(base);
5027 base = result.
get();
5033 assert(ArgExprs.size() == 1);
5034 if (CheckAndReportCommaError(ArgExprs.front()))
5037 return CreateBuiltinMatrixSubscriptExpr(base, ArgExprs.front(),
nullptr,
5041 if (ArgExprs.size() == 1 && getLangOpts().
CPlusPlus20) {
5042 Expr *idx = ArgExprs[0];
5043 if ((isa<BinaryOperator>(idx) && cast<BinaryOperator>(idx)->isCommaOp()) ||
5044 (isa<CXXOperatorCallExpr>(idx) &&
5045 cast<CXXOperatorCallExpr>(idx)->getOperator() == OO_Comma)) {
5051 if (ArgExprs.size() == 1 &&
5052 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
5053 ExprResult result = CheckPlaceholderExpr(ArgExprs[0]);
5056 ArgExprs[0] = result.
get();
5058 if (CheckArgsForPlaceholders(ArgExprs))
5063 if (getLangOpts().
CPlusPlus && ArgExprs.size() == 1 &&
5066 !isa<PackExpansionExpr>(ArgExprs[0])) {
5068 base, ArgExprs.front(),
5081 if (IsMSPropertySubscript) {
5082 assert(ArgExprs.size() == 1);
5085 return new (Context)
5100 (ArgExprs.size() != 1 || isa<PackExpansionExpr>(ArgExprs[0]) ||
5101 ArgExprs[0]->getType()->isRecordType())))) {
5102 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, ArgExprs);
5106 CreateBuiltinArraySubscriptExpr(base, lbLoc, ArgExprs.front(), rbLoc);
5108 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
5109 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
5130 ExprResult RowR = CheckPlaceholderExpr(RowIdx);
5133 RowIdx = RowR.
get();
5145 ExprResult ColumnR = CheckPlaceholderExpr(ColumnIdx);
5148 ColumnIdx = ColumnR.
get();
5153 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5154 bool IsColumnIdx) ->
Expr * {
5162 if (std::optional<llvm::APSInt> Idx =
5164 if ((*Idx < 0 || *Idx >= Dim)) {
5166 << IsColumnIdx << Dim;
5172 tryConvertExprToType(IndexExpr, Context.
getSizeType());
5174 "should be able to convert any integer type to size type");
5175 return ConvExpr.
get();
5179 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5180 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5181 if (!RowIdx || !ColumnIdx)
5185 MTy->getElementType(), RBLoc);
5188 void Sema::CheckAddressOfNoDeref(
const Expr *E) {
5189 ExpressionEvaluationContextRecord &LastRecord = ExprEvalContexts.back();
5195 while ((Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5196 StrippedExpr =
Member->getBase()->IgnoreParenImpCasts();
5198 LastRecord.PossibleDerefs.erase(StrippedExpr);
5202 if (isUnevaluatedContext())
5206 ExpressionEvaluationContextRecord &LastRecord = ExprEvalContexts.back();
5209 if (isa<ArrayType>(ResultTy))
5212 if (ResultTy->
hasAttr(attr::NoDeref)) {
5213 LastRecord.PossibleDerefs.insert(E);
5221 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
5226 while ((Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5230 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5231 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5232 LastRecord.PossibleDerefs.insert(E);
5248 for (
auto *Op : {LHSExp, RHSExp}) {
5249 Op = Op->IgnoreImplicit();
5250 if (Op->getType()->isArrayType() && !Op->isLValue())
5257 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
5258 if (Result.isInvalid())
5260 LHSExp = Result.get();
5262 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
5263 if (Result.isInvalid())
5265 RHSExp = Result.get();
5273 Expr *BaseExpr, *IndexExpr;
5292 return ObjC().BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
5308 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5328 if (getLangOpts().CPlusPlus11 && LHSExp->
isPRValue()) {
5329 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
5332 LHSExp = Materialized.
get();
5341 Qualifiers Combined = BaseQuals + MemberQuals;
5342 if (Combined != MemberQuals)
5353 CK_ArrayToPointerDecay).get();
5359 }
else if (RHSTy->isArrayType()) {
5364 CK_ArrayToPointerDecay).get();
5371 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5376 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5382 std::optional<llvm::APSInt> IntegerContantExpr =
5384 if (!IntegerContantExpr.has_value() ||
5385 IntegerContantExpr.value().isNegative())
5401 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5410 RequireCompleteSizedType(
5412 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5415 assert(VK ==
VK_PRValue || LangOpts.CPlusPlus ||
5419 FunctionScopes.size() > 1) {
5422 for (
auto I = FunctionScopes.rbegin(),
5423 E = std::prev(FunctionScopes.rend());
5425 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5429 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5430 DC = LSI->CallOperator;
5431 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
5432 DC = CRSI->TheCapturedDecl;
5433 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
5445 return new (Context)
5451 bool SkipImmediateInvocations) {
5453 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
5456 if (!UnparsedDefaultArgLocs.count(Param)) {
5457 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
5458 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
5463 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
5465 Diag(UnparsedDefaultArgLocs[Param],
5466 diag::note_default_argument_declared_here);
5471 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
5472 if (InstantiateDefaultArgument(CallLoc, FD, Param))
5476 Expr *Init = RewrittenInit ? RewrittenInit : Param->
getInit();
5477 assert(Init &&
"default argument but no initializer?");
5486 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(Init)) {
5489 Cleanup.setExprNeedsCleanups(InitWithCleanup->cleanupsHaveSideEffects());
5493 assert(!InitWithCleanup->getNumObjects() &&
5494 "default argument expression has capturing blocks?");
5503 ? ExpressionEvaluationContext::ImmediateFunctionContext
5504 : ExpressionEvaluationContext::PotentiallyEvaluated,
5506 ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
5507 SkipImmediateInvocations;
5509 MarkDeclarationsReferencedInExpr(Init,
true);
5518 bool HasImmediateCalls =
false;
5523 HasImmediateCalls |= FD->isImmediateFunction();
5529 HasImmediateCalls |= FD->isImmediateFunction();
5538 HasImmediateCalls =
true;
5553 return TraverseStmt(E->
getExpr());
5557 return TraverseStmt(E->
getExpr());
5584 SemaRef.CurContext);
5591 assert(Param->
hasDefaultArg() &&
"can't build nonexistent default arg");
5593 bool NestedDefaultChecking = isCheckingDefaultArgumentOrInitializer();
5594 bool InLifetimeExtendingContext = isInLifetimeExtendingContext();
5595 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5596 InitializationContext =
5597 OutermostDeclarationWithDelayedImmediateInvocations();
5598 if (!InitializationContext.has_value())
5599 InitializationContext.emplace(CallLoc, Param, CurContext);
5612 ? ExpressionEvaluationContext::ImmediateFunctionContext
5613 : ExpressionEvaluationContext::PotentiallyEvaluated,
5617 if (InstantiateDefaultArgument(CallLoc, FD, Param))
5625 if (!NestedDefaultChecking)
5626 V.TraverseDecl(Param);
5630 if (
V.HasImmediateCalls || InLifetimeExtendingContext) {
5631 if (
V.HasImmediateCalls)
5632 ExprEvalContexts.back().DelayedDefaultInitializationContext = {
5633 CallLoc, Param, CurContext};
5636 keepInLifetimeExtendingContext();
5640 Res = Immediate.TransformInitializer(Param->
getInit(),
5644 Res = ConvertParamDefaultArgument(Param, Res.
get(),
5652 if (CheckCXXDefaultArgExpr(
5653 CallLoc, FD, Param, Init,
5654 NestedDefaultChecking))
5658 Init, InitializationContext->Context);
5662 assert(Field->hasInClassInitializer());
5665 if (Field->isInvalidDecl())
5670 auto *ParentRD = cast<CXXRecordDecl>(Field->getParent());
5672 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5673 InitializationContext =
5674 OutermostDeclarationWithDelayedImmediateInvocations();
5675 if (!InitializationContext.has_value())
5676 InitializationContext.emplace(
Loc, Field, CurContext);
5678 Expr *Init =
nullptr;
5679 bool HasRewrittenInit =
false;
5681 bool NestedDefaultChecking = isCheckingDefaultArgumentOrInitializer();
5682 bool InLifetimeExtendingContext = isInLifetimeExtendingContext();
5684 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Field);
5686 if (!Field->getInClassInitializer()) {
5692 ClassPattern->
lookup(Field->getDeclName());
5695 for (
auto *L : Lookup) {
5696 if ((Pattern = dyn_cast<FieldDecl>(L)))
5699 assert(Pattern &&
"We must have set the Pattern!");
5701 InstantiateInClassInitializer(
Loc, Field, Pattern,
5702 getTemplateInstantiationArgs(Field))) {
5703 Field->setInvalidDecl();
5715 if (!NestedDefaultChecking)
5716 V.TraverseDecl(Field);
5725 bool ContainsAnyTemporaries =
5726 isa_and_present<ExprWithCleanups>(Field->getInClassInitializer());
5727 if (
V.HasImmediateCalls || InLifetimeExtendingContext ||
5728 ContainsAnyTemporaries) {
5729 HasRewrittenInit =
true;
5730 ExprEvalContexts.back().DelayedDefaultInitializationContext = {
Loc, Field,
5732 ExprEvalContexts.back().IsCurrentlyCheckingDefaultArgumentOrInitializer =
5733 NestedDefaultChecking;
5736 keepInLifetimeExtendingContext();
5743 Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
5747 Res = ConvertMemberDefaultInitExpression(Field, Res.
get(),
Loc);
5749 Field->setInvalidDecl();
5755 if (Field->getInClassInitializer()) {
5756 Expr *E = Init ? Init : Field->getInClassInitializer();
5757 if (!NestedDefaultChecking)
5759 MarkDeclarationsReferencedInExpr(E,
false);
5764 ExprResult Res = ActOnFinishFullExpr(E,
false);
5765 if (Res.isInvalid()) {
5766 Field->setInvalidDecl();
5772 Field, InitializationContext->Context,
5773 HasRewrittenInit ? Init :
nullptr);
5791 Diag(
Loc, diag::err_default_member_initializer_not_yet_parsed)
5792 << OutermostClass << Field;
5793 Diag(Field->getEndLoc(),
5794 diag::note_default_member_initializer_not_yet_parsed);
5796 if (!isSFINAEContext())
5797 Field->setInvalidDecl();
5805 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
5806 return VariadicConstructor;
5808 return VariadicBlock;
5810 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5811 if (Method->isInstance())
5812 return VariadicMethod;
5814 return VariadicMethod;
5815 return VariadicFunction;
5817 return VariadicDoesNotApply;
5826 FunctionName(FuncName) {}
5828 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
5837 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
5838 return std::make_unique<FunctionCallCCC>(*
this);
5858 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
5859 if (Corrected.isOverloaded()) {
5869 ND = Best->FoundDecl;
5870 Corrected.setCorrectionDecl(ND);
5876 ND = ND->getUnderlyingDecl();
5877 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
5896 bool IsExecConfig) {
5905 bool HasExplicitObjectParameter =
5907 unsigned ExplicitObjectParameterOffset = HasExplicitObjectParameter ? 1 : 0;
5909 bool Invalid =
false;
5918 if (Args.size() < NumParams) {
5919 if (Args.size() < MinArgs) {
5924 ? diag::err_typecheck_call_too_few_args_suggest
5925 : diag::err_typecheck_call_too_few_args_at_least_suggest;
5928 << FnKind << MinArgs - ExplicitObjectParameterOffset
5929 <<
static_cast<unsigned>(Args.size()) -
5930 ExplicitObjectParameterOffset
5932 }
else if (MinArgs - ExplicitObjectParameterOffset == 1 && FDecl &&
5937 ? diag::err_typecheck_call_too_few_args_one
5938 : diag::err_typecheck_call_too_few_args_at_least_one)
5939 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
5943 ? diag::err_typecheck_call_too_few_args
5944 : diag::err_typecheck_call_too_few_args_at_least)
5945 << FnKind << MinArgs - ExplicitObjectParameterOffset
5946 <<
static_cast<unsigned>(Args.size()) -
5947 ExplicitObjectParameterOffset
5951 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5959 assert((Call->getNumArgs() == NumParams) &&
5960 "We should have reserved space for the default arguments before!");
5965 if (Args.size() > NumParams) {
5971 ? diag::err_typecheck_call_too_many_args_suggest
5972 : diag::err_typecheck_call_too_many_args_at_most_suggest;
5975 << FnKind << NumParams - ExplicitObjectParameterOffset
5976 <<
static_cast<unsigned>(Args.size()) -
5977 ExplicitObjectParameterOffset
5979 }
else if (NumParams - ExplicitObjectParameterOffset == 1 && FDecl &&
5982 Diag(Args[NumParams]->getBeginLoc(),
5983 MinArgs == NumParams
5984 ? diag::err_typecheck_call_too_many_args_one
5985 : diag::err_typecheck_call_too_many_args_at_most_one)
5986 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
5987 <<
static_cast<unsigned>(Args.size()) -
5988 ExplicitObjectParameterOffset
5991 Args.back()->getEndLoc());
5993 Diag(Args[NumParams]->getBeginLoc(),
5994 MinArgs == NumParams
5995 ? diag::err_typecheck_call_too_many_args
5996 : diag::err_typecheck_call_too_many_args_at_most)
5997 << FnKind << NumParams - ExplicitObjectParameterOffset
5998 <<
static_cast<unsigned>(Args.size()) -
5999 ExplicitObjectParameterOffset
6002 Args.back()->getEndLoc());
6005 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6010 Call->shrinkNumArgs(NumParams);
6017 Invalid = GatherArgumentsForCall(Call->getBeginLoc(), FDecl, Proto, 0, Args,
6021 unsigned TotalNumArgs = AllArgs.size();
6022 for (
unsigned i = 0; i < TotalNumArgs; ++i)
6023 Call->setArg(i, AllArgs[i]);
6025 Call->computeDependence();
6034 bool IsListInitialization) {
6036 bool Invalid =
false;
6039 for (
unsigned i = FirstParam; i < NumParams; i++) {
6044 if (ArgIx < Args.size()) {
6045 Arg = Args[ArgIx++];
6047 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
6048 diag::err_call_incomplete_argument, Arg))
6052 bool CFAudited =
false;
6054 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6055 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
6056 Arg = ObjC().stripARCUnbridgedCast(Arg);
6057 else if (getLangOpts().ObjCAutoRefCount &&
6058 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6059 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
6065 BE->getBlockDecl()->setDoesNotEscape();
6078 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
6084 assert(Param &&
"can't use default arguments without a known callee");
6086 ExprResult ArgExpr = BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
6096 CheckArrayAccess(Arg);
6099 CheckStaticArrayArgument(CallLoc, Param, Arg);
6101 AllArgs.push_back(Arg);
6105 if (CallType != VariadicDoesNotApply) {
6110 for (
Expr *A : Args.slice(ArgIx)) {
6113 Invalid |=
arg.isInvalid();
6114 AllArgs.push_back(
arg.get());
6119 for (
Expr *A : Args.slice(ArgIx)) {
6120 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
6122 AllArgs.push_back(Arg.
get());
6127 for (
Expr *A : Args.slice(ArgIx))
6128 CheckArrayAccess(A);
6136 TL = DTL.getOriginalLoc();
6139 << ATL.getLocalSourceRange();
6153 const Expr *ArgExpr) {
6180 if (getASTContext().hasSameUnqualifiedType(CAT->
getElementType(),
6183 Diag(CallLoc, diag::warn_static_array_too_small)
6191 std::optional<CharUnits> ArgSize =
6192 getASTContext().getTypeSizeInCharsIfKnown(ArgCAT);
6193 std::optional<CharUnits> ParmSize =
6194 getASTContext().getTypeSizeInCharsIfKnown(CAT);
6195 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6196 Diag(CallLoc, diag::warn_static_array_too_small)
6198 << (
unsigned)ParmSize->getQuantity() << 1;
6212 if (!placeholder)
return false;
6214 switch (placeholder->
getKind()) {
6216 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6217 case BuiltinType::Id:
6218 #include "clang/Basic/OpenCLImageTypes.def"
6219 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6220 case BuiltinType::Sampled##Id:
6221 #define IMAGE_WRITE_TYPE(Type, Id, Ext)
6222 #define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
6223 #include "clang/Basic/OpenCLImageTypes.def"
6224 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6225 case BuiltinType::Id:
6226 #include "clang/Basic/OpenCLExtensionTypes.def"
6229 #define SVE_TYPE(Name, Id, SingletonId) \
6230 case BuiltinType::Id:
6231 #include "clang/Basic/AArch64SVEACLETypes.def"
6232 #define PPC_VECTOR_TYPE(Name, Id, Size) \
6233 case BuiltinType::Id:
6234 #include "clang/Basic/PPCTypes.def"
6235 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6236 #include "clang/Basic/RISCVVTypes.def"
6237 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6238 #include "clang/Basic/WebAssemblyReferenceTypes.def"
6239 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6240 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6241 #include "clang/AST/BuiltinTypes.def"
6244 case BuiltinType::UnresolvedTemplate:
6247 case BuiltinType::Overload:
6252 case BuiltinType::ARCUnbridgedCast:
6256 case BuiltinType::PseudoObject:
6261 case BuiltinType::UnknownAny:
6265 case BuiltinType::BoundMember:
6266 case BuiltinType::BuiltinFn:
6267 case BuiltinType::IncompleteMatrixIdx:
6268 case BuiltinType::ArraySection:
6269 case BuiltinType::OMPArrayShaping:
6270 case BuiltinType::OMPIterator:
6274 llvm_unreachable(
"bad builtin type kind");
6280 bool hasInvalid =
false;
6281 for (
size_t i = 0, e = args.size(); i != e; i++) {
6283 ExprResult result = CheckPlaceholderExpr(args[i]);
6284 if (result.
isInvalid()) hasInvalid =
true;
6285 else args[i] = result.
get();
6313 bool NeedsNewDecl =
false;
6326 if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6330 OverloadParams.push_back(ParamType);
6338 NeedsNewDecl =
true;
6351 OverloadParams, EPI);
6360 FT = cast<FunctionProtoType>(OverloadTy);
6361 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6368 Params.push_back(Parm);
6370 OverloadDecl->setParams(Params);
6372 return OverloadDecl;
6383 !Callee->isVariadic())
6385 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6388 if (
const EnableIfAttr *
Attr =
6391 isa<CXXMethodDecl>(Callee)
6392 ? diag::err_ovl_no_viable_member_function_in_call
6393 : diag::err_ovl_no_viable_function_in_call)
6394 << Callee << Callee->getSourceRange();
6395 S.
Diag(Callee->getLocation(),
6396 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6397 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6405 const auto GetFunctionLevelDCIfCXXClass =
6413 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6414 return MD->
getParent()->getCanonicalDecl();
6417 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6418 return RD->getCanonicalDecl();
6425 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6426 if (!CurParentClass)
6433 assert(NamingClass &&
"Must have naming class even for implicit access");
6439 return CurParentClass == NamingClass ||
6488 if (Call->getNumArgs() != 1)
6491 const Expr *E = Call->getCallee()->IgnoreParenImpCasts();
6492 if (!E || isa<UnresolvedLookupExpr>(E))
6494 const DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(E);
6507 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
6510 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
6519 BuildCallExpr(
Scope, Fn, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
6521 if (Call.isInvalid())
6526 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn);
6527 ULE && ULE->hasExplicitTemplateArgs() &&
6528 ULE->decls_begin() == ULE->decls_end()) {
6530 ? diag::warn_cxx17_compat_adl_only_template_id
6531 : diag::ext_adl_only_template_id)
6535 if (LangOpts.OpenMP)
6536 Call = OpenMP().ActOnOpenMPCall(Call,
Scope, LParenLoc, ArgExprs, RParenLoc,
6538 if (LangOpts.CPlusPlus) {
6539 if (
const auto *CE = dyn_cast<CallExpr>(Call.get()))
6550 Expr *ExecConfig,
bool IsExecConfig,
6551 bool AllowRecovery) {
6554 if (Result.isInvalid())
return ExprError();
6557 if (CheckArgsForPlaceholders(ArgExprs))
6562 if (isa<CXXPseudoDestructorExpr>(Fn)) {
6563 if (!ArgExprs.empty()) {
6568 ArgExprs.back()->getEndLoc()));
6572 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
6575 ExprResult result = CheckPlaceholderExpr(Fn);
6585 cast<CallExpr>(ExecConfig), ArgExprs,
6587 RParenLoc, CurFPFeatureOverrides());
6591 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
6595 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
6601 return BuildCallToObjectOfClassType(
Scope, Fn, LParenLoc, ArgExprs,
6611 return BuildCallToMemberFunction(
Scope, Fn, LParenLoc, ArgExprs,
6612 RParenLoc, ExecConfig, IsExecConfig,
6625 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
6628 return BuildOverloadedCallExpr(
6629 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
6631 return BuildCallToMemberFunction(
Scope, Fn, LParenLoc, ArgExprs,
6632 RParenLoc, ExecConfig, IsExecConfig,
6646 bool CallingNDeclIndirectly =
false;
6648 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
6649 if (UnOp->getOpcode() == UO_AddrOf) {
6650 CallingNDeclIndirectly =
true;
6655 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
6656 NDecl = DRE->getDecl();
6669 nullptr, DRE->isNonOdrUse());
6672 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
6673 NDecl = ME->getMemberDecl();
6675 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
6688 if (getLangOpts().
HIP && getLangOpts().CUDAIsDevice && FD &&
6689 FD->getBuiltinID()) {
6690 for (
unsigned Idx = 0; Idx < FD->param_size(); ++Idx) {
6693 !ArgExprs[Idx]->getType()->isPointerType())
6697 auto ArgTy = ArgExprs[Idx]->getType();
6698 auto ArgPtTy = ArgTy->getPointeeType();
6699 auto ArgAS = ArgPtTy.getAddressSpace();
6702 bool NeedImplicitASC =
6706 getASTContext().getTargetAddressSpace(ArgAS) == getASTContext().getTargetAddressSpace(ParamAS));
6707 if (!NeedImplicitASC)
6711 if (ArgExprs[Idx]->isGLValue()) {
6713 Context, ArgExprs[Idx]->getType(), CK_NoOp, ArgExprs[Idx],
6718 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
6727 ArgExprs[Idx] = ImpCastExprToType(ArgExprs[Idx], NewArgTy,
6728 CK_AddressSpaceConversion)
6738 llvm::any_of(ArgExprs,
6739 [](
clang::Expr *E) { return E->containsErrors(); })) &&
6740 "should only occur in error-recovery path.");
6742 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
6744 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
6745 ExecConfig, IsExecConfig);
6755 LookupName(R, TUScope,
true);
6758 assert(BuiltInDecl &&
"failed to find builtin declaration");
6761 BuildDeclRefExpr(BuiltInDecl, BuiltInDecl->getType(),
VK_LValue,
Loc);
6762 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
6765 BuildCallExpr(
nullptr, DeclRef.
get(),
Loc, CallArgs,
Loc);
6767 assert(!Call.isInvalid() &&
"Call to builtin cannot fail!");
6778 QualType DstTy = GetTypeFromParser(ParsedDestTy);
6779 return BuildAsTypeExpr(E, DstTy, BuiltinLoc, RParenLoc);
6792 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
6794 return new (Context)
AsTypeExpr(E, DestTy, VK, OK, BuiltinLoc, RParenLoc);
6806 GetTypeFromParser(ParsedDestTy, &TInfo);
6821 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
6822 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
6825 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
6837 if (
auto *Caller = getCurFunctionDecl()) {
6838 if (Caller->hasAttr<ARMInterruptAttr>()) {
6840 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>())) {
6841 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
6846 if (Caller->hasAttr<AnyX86InterruptAttr>() ||
6847 Caller->hasAttr<AnyX86NoCallerSavedRegistersAttr>()) {
6849 bool HasNonGPRRegisters =
6851 if (HasNonGPRRegisters &&
6852 (!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())) {
6854 << (Caller->hasAttr<AnyX86InterruptAttr>() ? 0 : 1);
6873 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
6876 Result = CallExprUnaryConversions(Fn);
6877 ResultTy = Context.
BoolTy;
6879 if (Result.isInvalid())
6894 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
6909 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
6917 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
6918 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
6922 assert(UsesADL == ADLCallKind::NotADL &&
6923 "CUDAKernelCallExpr should not use ADL");
6926 CurFPFeatureOverrides(), NumParams);
6930 CurFPFeatureOverrides(), NumParams, UsesADL);
6941 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
6942 if (!Result.isUsable())
return ExprError();
6944 TheCall = dyn_cast<CallExpr>(Result.get());
6945 bool CorrectedTypos = TheCall != TheOldCall;
6946 if (!TheCall)
return Result;
6953 if (CorrectedTypos && Args.size() < NumParams) {
6956 Context, Fn, cast<CallExpr>(Config), Args, ResultTy,
VK_PRValue,
6957 RParenLoc, CurFPFeatureOverrides(), NumParams);
6961 CurFPFeatureOverrides(), NumParams, UsesADL);
6969 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
6971 if (getLangOpts().
CUDA) {
6974 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
6975 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
6982 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
6986 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
6987 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
7003 for (
const Expr *Arg : Args) {
7004 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
7006 diag::err_wasm_table_as_function_parameter));
7012 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
7016 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
7024 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
7025 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
7045 if (!Proto && !Args.empty() &&
7047 !Diags.isIgnored(diag::warn_strict_uses_without_prototype,
7049 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
7050 << (FDecl !=
nullptr) << FDecl;
7053 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7054 Expr *Arg = Args[i];
7056 if (Proto && i < Proto->getNumParams()) {
7058 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
7067 ExprResult ArgE = DefaultArgumentPromotion(Arg);
7076 diag::err_call_incomplete_argument, Arg))
7084 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
7085 if (!isa<RequiresExprBodyDecl>(CurContext) &&
7086 Method->isImplicitObjectMemberFunction())
7087 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
7092 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
7096 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7097 if (
const auto *RT =
7098 dyn_cast<RecordType>(Args[i]->getType().getCanonicalType())) {
7099 if (RT->getDecl()->isOrContainsUnion())
7100 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
7108 if (CheckFunctionCall(FDecl, TheCall, Proto))
7111 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
7114 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7116 if (CheckPointerCall(NDecl, TheCall, Proto))
7119 if (CheckOtherCall(TheCall, Proto))
7123 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FDecl);
7129 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
7130 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
7133 QualType literalType = GetTypeFromParser(Ty, &TInfo);
7137 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
7146 if (RequireCompleteSizedType(
7148 diag::err_array_incomplete_or_sizeless_type,
7170 auto diagID = LangOpts.CPlusPlus
7171 ? diag::err_variable_object_no_init
7172 : diag::err_compound_literal_with_vla_type;
7173 if (!tryToFixVariablyModifiedVarType(TInfo, literalType, LParenLoc,
7178 RequireCompleteType(LParenLoc, literalType,
7179 diag::err_typecheck_decl_incomplete_type,
7192 if (Result.isInvalid())
7194 LiteralExpr = Result.get();
7196 bool isFileScope = !CurContext->isFunctionOrMethod();
7217 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
7222 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
7223 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7224 Expr *Init = ILE->getInit(i);
7229 VK, LiteralExpr, isFileScope);
7234 if (CheckForConstantInitializer(LiteralExpr))
7241 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7246 if (!isFileScope && !getLangOpts().
CPlusPlus) {
7254 NTCUC_CompoundLiteral, NTCUK_Destruct);
7258 Cleanup.setExprNeedsCleanups(
true);
7259 ExprCleanupObjects.push_back(E);
7260 getCurFunction()->setHasBranchProtectedScope();
7266 checkNonTrivialCUnionInInitializer(E->getInitializer(),
7269 return MaybeBindToTemporary(E);
7277 bool DiagnosedArrayDesignator =
false;
7278 bool DiagnosedNestedDesignator =
false;
7279 bool DiagnosedMixedDesignator =
false;
7283 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7284 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7286 FirstDesignator = DIE->getBeginLoc();
7291 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7292 DiagnosedNestedDesignator =
true;
7293 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7294 << DIE->getDesignatorsSourceRange();
7297 for (
auto &Desig : DIE->designators()) {
7298 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7299 DiagnosedArrayDesignator =
true;
7300 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7301 << Desig.getSourceRange();
7305 if (!DiagnosedMixedDesignator &&
7306 !isa<DesignatedInitExpr>(InitArgList[0])) {
7307 DiagnosedMixedDesignator =
true;
7308 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7309 << DIE->getSourceRange();
7310 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7311 << InitArgList[0]->getSourceRange();
7313 }
else if (getLangOpts().
CPlusPlus && !DiagnosedMixedDesignator &&
7314 isa<DesignatedInitExpr>(InitArgList[0])) {
7315 DiagnosedMixedDesignator =
true;
7316 auto *DIE = cast<DesignatedInitExpr>(InitArgList[0]);
7317 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7318 << DIE->getSourceRange();
7319 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7320 << InitArgList[I]->getSourceRange();
7324 if (FirstDesignator.
isValid()) {
7327 if (getLangOpts().
CPlusPlus && !DiagnosedArrayDesignator &&
7328 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7330 ? diag::warn_cxx17_compat_designated_init
7331 : diag::ext_cxx_designated_init);
7332 }
else if (!getLangOpts().
CPlusPlus && !getLangOpts().
C99) {
7333 Diag(FirstDesignator, diag::ext_designated_init);
7337 return BuildInitList(LBraceLoc, InitArgList, RBraceLoc);
7348 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7349 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
7350 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
7356 InitArgList[I] = result.
get();
7372 if (!getLangOpts().ObjCAutoRefCount)
return;
7375 Context, E.
get()->
getType(), CK_ARCExtendBlockObject, E.
get(),
7377 Cleanup.setExprNeedsCleanups(
true);
7393 llvm_unreachable(
"member pointer type in C");
7402 if (SrcAS != DestAS)
7403 return CK_AddressSpaceConversion;
7410 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7415 return CK_CPointerToObjCPointerCast;
7416 maybeExtendBlockObject(Src);
7417 return CK_BlockPointerToObjCPointerCast;
7419 return CK_PointerToBoolean;
7421 return CK_PointerToIntegral;
7427 llvm_unreachable(
"illegal cast from pointer");
7429 llvm_unreachable(
"Should have returned before this");
7434 return CK_FixedPointCast;
7436 return CK_FixedPointToBoolean;
7438 return CK_FixedPointToIntegral;
7440 return CK_FixedPointToFloating;
7444 diag::err_unimplemented_conversion_with_fixed_point_type)
7446 return CK_IntegralCast;
7451 llvm_unreachable(
"illegal cast to pointer type");
7453 llvm_unreachable(
"Should have returned before this");
7463 return CK_NullToPointer;
7464 return CK_IntegralToPointer;
7466 return CK_IntegralToBoolean;
7468 return CK_IntegralCast;
7470 return CK_IntegralToFloating;
7472 Src = ImpCastExprToType(Src.
get(),
7475 return CK_IntegralRealToComplex;
7477 Src = ImpCastExprToType(Src.
get(),
7479 CK_IntegralToFloating);
7480 return CK_FloatingRealToComplex;
7482 llvm_unreachable(
"member pointer type in C");
7484 return CK_IntegralToFixedPoint;
7486 llvm_unreachable(
"Should have returned before this");
7491 return CK_FloatingCast;
7493 return CK_FloatingToBoolean;
7495 return CK_FloatingToIntegral;
7497 Src = ImpCastExprToType(Src.
get(),
7500 return CK_FloatingRealToComplex;
7502 Src = ImpCastExprToType(Src.
get(),
7504 CK_FloatingToIntegral);
7505 return CK_IntegralRealToComplex;
7509 llvm_unreachable(
"valid float->pointer cast?");
7511 llvm_unreachable(
"member pointer type in C");
7513 return CK_FloatingToFixedPoint;
7515 llvm_unreachable(
"Should have returned before this");
7520 return CK_FloatingComplexCast;
7522 return CK_FloatingComplexToIntegralComplex;
7526 return CK_FloatingComplexToReal;
7527 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
7528 return CK_FloatingCast;
7531 return CK_FloatingComplexToBoolean;
7533 Src = ImpCastExprToType(Src.
get(),
7535 CK_FloatingComplexToReal);
7536 return CK_FloatingToIntegral;
7540 llvm_unreachable(
"valid complex float->pointer cast?");
7542 llvm_unreachable(
"member pointer type in C");
7545 diag::err_unimplemented_conversion_with_fixed_point_type)
7547 return CK_IntegralCast;
7549 llvm_unreachable(
"Should have returned before this");
7554 return CK_IntegralComplexToFloatingComplex;
7556 return CK_IntegralComplexCast;
7560 return CK_IntegralComplexToReal;
7561 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
7562 return CK_IntegralCast;
7565 return CK_IntegralComplexToBoolean;
7567 Src = ImpCastExprToType(Src.
get(),
7569 CK_IntegralComplexToReal);
7570 return CK_IntegralToFloating;
7574 llvm_unreachable(
"valid complex int->pointer cast?");
7576 llvm_unreachable(
"member pointer type in C");
7579 diag::err_unimplemented_conversion_with_fixed_point_type)
7581 return CK_IntegralCast;
7583 llvm_unreachable(
"Should have returned before this");
7586 llvm_unreachable(
"Unhandled scalar cast");
7593 len = vecType->getNumElements();
7594 eltType = vecType->getElementType();
7601 if (!
type->isRealType())
return false;
7617 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
7621 const auto *VecTy = SecondType->getAs<
VectorType>();
7625 return ValidScalableConversion(srcTy, destTy) ||
7626 ValidScalableConversion(destTy, srcTy);
7638 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
7639 matSrcType->
getNumColumns() == matDestType->getNumColumns();
7658 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
7664 "expected at least one type to be a vector here");
7666 bool IsSrcTyAltivec =
7682 return (IsSrcTyAltivec || IsDestTyAltivec);
7703 return areVectorTypesSameSize(srcTy, destTy);
7711 switch (Context.
getLangOpts().getLaxVectorConversions()) {
7718 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7723 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7733 return areLaxCompatibleVectorTypes(srcTy, destTy);
7739 if (!areMatrixTypesOfTheSameDimension(SrcTy, DestTy)) {
7740 return Diag(R.
getBegin(), diag::err_invalid_conversion_between_matrixes)
7741 << DestTy << SrcTy << R;
7745 diag::err_invalid_conversion_between_matrix_and_type)
7746 << SrcTy << DestTy << R;
7749 diag::err_invalid_conversion_between_matrix_and_type)
7750 << DestTy << SrcTy << R;
7753 Kind = CK_MatrixCast;
7759 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
7762 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
7765 diag::err_invalid_conversion_between_vectors :
7766 diag::err_invalid_conversion_between_vector_and_integer)
7767 << VectorTy << Ty << R;
7770 diag::err_invalid_conversion_between_vector_and_scalar)
7771 << VectorTy << Ty << R;
7780 if (DestElemTy == SplattedExpr->
getType())
7781 return SplattedExpr;
7793 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
7794 CK_BooleanToSignedIntegral);
7795 SplattedExpr = CastExprRes.
get();
7796 CK = CK_IntegralToFloating;
7798 CK = CK_BooleanToSignedIntegral;
7802 CK = PrepareScalarCast(CastExprRes, DestElemTy);
7805 SplattedExpr = CastExprRes.
get();
7807 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
7821 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
7824 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
7825 << DestTy << SrcTy << R;
7837 diag::err_invalid_conversion_between_vector_and_scalar)
7838 << DestTy << SrcTy << R;
7840 Kind = CK_VectorSplat;
7841 return prepareVectorSplat(DestTy,
CastExpr);
7849 "ActOnCastExpr(): missing type or expr");
7857 CheckExtraCXXDefaultArguments(D);
7866 checkUnusedDeclAttributes(D);
7869 Ty = CreateParsedType(castType, castTInfo);
7871 bool isVectorLiteral =
false;
7877 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().
OpenCL)
7886 isVectorLiteral =
true;
7889 isVectorLiteral =
true;
7894 if (isVectorLiteral)
7895 return BuildVectorLiteral(LParenLoc, RParenLoc,
CastExpr, castTInfo);
7900 if (isa<ParenListExpr>(
CastExpr)) {
7902 if (Result.isInvalid())
return ExprError();
7909 ObjC().CheckTollFreeBridgeCast(castType,
CastExpr);
7911 ObjC().CheckObjCBridgeRelatedCast(castType,
CastExpr);
7915 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc,
CastExpr);
7921 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
7922 "Expected paren or paren list expression");
7929 LiteralLParenLoc = PE->getLParenLoc();
7930 LiteralRParenLoc = PE->getRParenLoc();
7931 exprs = PE->getExprs();
7932 numExprs = PE->getNumExprs();
7934 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
7935 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
7936 subExpr = cast<ParenExpr>(E)->getSubExpr();
7955 if (ShouldSplatAltivecScalarInCast(VTy)) {
7959 if (numExprs == 1) {
7965 PrepareScalarCast(
Literal, ElemTy));
7966 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
Literal.get());
7968 else if (numExprs < numElems) {
7970 diag::err_incorrect_number_of_vector_initializers);
7974 initExprs.append(exprs, exprs + numExprs);
7986 PrepareScalarCast(
Literal, ElemTy));
7987 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
Literal.get());
7990 initExprs.append(exprs, exprs + numExprs);
7995 initExprs, LiteralRParenLoc);
7997 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
8010 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
8011 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
8014 if (Result.isInvalid())
return ExprError();
8030 const Expr *NullExpr = LHSExpr;
8031 const Expr *NonPointerExpr = RHSExpr;
8038 NonPointerExpr = LHSExpr;
8055 if (!findMacroSpelling(loc,
"NULL"))
8060 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
8061 << NonPointerExpr->
getType() << DiagType
8073 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8081 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
8115 bool IsBlockPointer =
false;
8119 IsBlockPointer =
true;
8144 ResultAddrSpace = LAddrSpace;
8146 ResultAddrSpace = RAddrSpace;
8148 S.
Diag(
Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8155 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
8170 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8172 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8180 lhptee, rhptee,
false,
false,
8183 if (CompositeTy.
isNull()) {
8200 S.
Diag(
Loc, diag::ext_typecheck_cond_incompatible_pointers)
8211 QualType ResultTy = [&, ResultAddrSpace]() {
8217 .withCVRQualifiers(MergedCVRQual);
8246 S.
Diag(
Loc, diag::err_typecheck_cond_incompatible_operands)
8299 bool IsIntFirstExpr) {
8301 !Int.get()->getType()->isIntegerType())
8304 Expr *Expr1 = IsIntFirstExpr ? Int.get() : PointerExpr;
8305 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.get();
8307 S.
Diag(
Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8311 CK_IntegralToPointer);
8345 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8351 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8357 if (LHSType == RHSType)
8366 return handleIntegerConversion<doIntegralCast, doIntegralCast>
8367 (S, LHS, RHS, LHSType, RHSType,
false);
8401 llvm::raw_svector_ostream OS(Str);
8402 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
8403 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8404 << CondTy << OS.str();
8425 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8443 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
8444 << CondTy << VecResTy;
8449 QualType RVE = RV->getElementType();
8452 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8453 << CondTy << VecResTy;
8479 bool IsBoolVecLang =
8503 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
8504 QualType Ty = CE->getCallee()->getType();
8531 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
8542 "should only occur in error-recovery path.");
8553 Cond = UsualUnaryConversions(Cond.
get());
8562 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
8569 UsualArithmeticConversions(LHS, RHS, QuestionLoc, ACK_Conditional);
8577 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
8586 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
8593 if (getLangOpts().
OpenCL &&
8605 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8611 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
8612 RHS = ImpCastExprToType(RHS.
get(), ResTy, PrepareScalarCast(RHS, ResTy));
8621 if (LHSRT->getDecl() == RHSRT->getDecl())
8644 LHS = ImpCastExprToType(LHS.
get(), ResTy, CK_ToVoid);
8645 RHS = ImpCastExprToType(RHS.
get(), ResTy, CK_ToVoid);
8662 ObjC().FindCompositeObjCPointerType(LHS, RHS, QuestionLoc);
8665 if (!compositeType.
isNull())
8666 return compositeType;
8691 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
8700 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8714 Self.Diag(
Loc, Note)
8719 Self.Diag(
Loc, Note) << ParenRange;
8739 const Expr **RHSExprs) {
8744 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
8745 E = MTE->getSubExpr();
8750 if (
const auto *OP = dyn_cast<BinaryOperator>(E);
8752 *
Opcode = OP->getOpcode();
8753 *RHSExprs = OP->getRHS();
8758 if (
const auto *Call = dyn_cast<CXXOperatorCallExpr>(E)) {
8759 if (Call->getNumArgs() != 2)
8765 if (OO < OO_Plus || OO > OO_Arrow ||
8766 OO == OO_PlusPlus || OO == OO_MinusMinus)
8772 *RHSExprs = Call->getArg(1);
8788 if (
const auto *OP = dyn_cast<BinaryOperator>(E))
8789 return OP->isComparisonOp() || OP->isLogicalOp();
8790 if (
const auto *OP = dyn_cast<UnaryOperator>(E))
8791 return OP->getOpcode() == UO_LNot;
8805 Expr *Condition,
const Expr *LHSExpr,
8806 const Expr *RHSExpr) {
8808 const Expr *CondRHS;
8819 ? diag::warn_precedence_bitwise_conditional
8820 : diag::warn_precedence_conditional;
8822 Self.Diag(OpLoc, DiagID)
8828 Self.PDiag(diag::note_precedence_silence)
8833 Self.PDiag(diag::note_precedence_conditional_first),
8844 auto GetNullability = [](
QualType Ty) {
8845 std::optional<NullabilityKind>
Kind = Ty->getNullability();
8855 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
8863 MergedKind = RHSKind;
8870 MergedKind = RHSKind;
8872 MergedKind = LHSKind;
8878 if (GetNullability(ResTy) == MergedKind)
8900 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
8901 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
8902 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
8915 CondExpr = CondResult.
get();
8916 LHSExpr = LHSResult.
get();
8917 RHSExpr = RHSResult.
get();
8923 Expr *commonExpr =
nullptr;
8925 commonExpr = CondExpr;
8930 ExprResult result = CheckPlaceholderExpr(commonExpr);
8932 commonExpr = result.
get();
8943 ExprResult commonRes = UsualUnaryConversions(commonExpr);
8946 commonExpr = commonRes.
get();
8953 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
8956 commonExpr = MatExpr.
get();
8964 LHSExpr = CondExpr = opaqueValue;
8970 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
8971 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
8972 VK, OK, QuestionLoc);
8986 return new (Context)
8988 RHS.get(), result, VK, OK);
8991 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
8992 ColonLoc, result, VK, OK);
8997 unsigned FromAttributes = 0, ToAttributes = 0;
8998 if (
const auto *FromFn =
9002 if (
const auto *ToFn =
9007 return FromAttributes != ToAttributes;
9015 if (
const auto *ToFn =
9017 if (
const auto *FromFn =
9036 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9037 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9040 const Type *lhptee, *rhptee;
9042 std::tie(lhptee, lhq) =
9043 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
9044 std::tie(rhptee, rhq) =
9045 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
9105 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
9128 if (ltrans == rtrans) {
9142 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
9144 std::tie(lhptee, lhq) =
9145 cast<PointerType>(lhptee)->getPointeeType().split().asPair();
9146 std::tie(rhptee, rhq) =
9147 cast<PointerType>(rhptee)->getPointeeType().split().asPair();
9160 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
9162 if (lhptee == rhptee)
9188 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9189 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9210 if (LQuals != RQuals)
9239 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9240 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9281 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
9288 return VT->getElementType().getCanonicalType() == ElementType;
9321 if (LHSType == RHSType) {
9328 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9329 if (AT->isGNUAutoType()) {
9337 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
9339 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
9340 if (result != Compatible)
9342 if (
Kind != CK_NoOp && ConvertRHS)
9343 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
9344 Kind = CK_NonAtomicToAtomic;
9357 Kind = CK_LValueBitCast;
9360 return Incompatible;
9367 return Incompatible;
9371 RHS = prepareVectorSplat(LHSType, RHS.
get());
9372 Kind = CK_VectorSplat;
9390 if (isLaxVectorConversion(RHSType, LHSType)) {
9395 anyAltivecTypes(RHSType, LHSType) &&
9398 << RHSType << LHSType;
9400 return IncompatibleVectors;
9411 isLaxVectorConversion(RHSType, LHSType)) {
9417 << RHSType << LHSType;
9419 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
9444 return Incompatible;
9450 return Incompatible;
9456 return Incompatible;
9462 Kind = PrepareScalarCast(RHS, LHSType);
9467 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
9469 if (isa<PointerType>(RHSType)) {
9470 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9472 if (AddrSpaceL != AddrSpaceR)
9473 Kind = CK_AddressSpaceConversion;
9484 Kind = CK_IntegralToPointer;
9485 return IntToPointer;
9490 if (isa<ObjCObjectPointerType>(RHSType)) {
9492 if (LHSPointer->getPointeeType()->isVoidType()) {
9506 return IncompatiblePointer;
9511 if (LHSPointer->getPointeeType()->isVoidType()) {
9512 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9517 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9522 return Incompatible;
9526 if (isa<BlockPointerType>(LHSType)) {
9535 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9541 Kind = CK_IntegralToPointer;
9542 return IntToBlockPointer;
9547 Kind = CK_AnyPointerToBlockPointerCast;
9553 if (RHSPT->getPointeeType()->isVoidType()) {
9554 Kind = CK_AnyPointerToBlockPointerCast;
9558 return Incompatible;
9562 if (isa<ObjCObjectPointerType>(LHSType)) {
9568 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9569 result == Compatible &&
9570 !ObjC().CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
9571 result = IncompatibleObjCWeakRef;
9577 Kind = CK_IntegralToPointer;
9578 return IntToPointer;
9583 if (isa<PointerType>(RHSType)) {
9584 Kind = CK_CPointerToObjCPointerCast;
9598 return IncompatiblePointer;
9605 maybeExtendBlockObject(RHS);
9606 Kind = CK_BlockPointerToObjCPointerCast;
9610 return Incompatible;
9618 Kind = CK_NullToPointer;
9623 if (isa<PointerType>(RHSType)) {
9625 if (LHSType == Context.
BoolTy) {
9626 Kind = CK_PointerToBoolean;
9632 Kind = CK_PointerToIntegral;
9633 return PointerToInt;
9636 return Incompatible;
9640 if (isa<ObjCObjectPointerType>(RHSType)) {
9642 if (LHSType == Context.
BoolTy) {
9643 Kind = CK_PointerToBoolean;
9649 Kind = CK_PointerToIntegral;
9650 return PointerToInt;
9653 return Incompatible;
9657 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
9665 Kind = CK_IntToOCLSampler;
9669 return Incompatible;
9687 TypeSourceInfo *unionTInfo = C.getTrivialTypeSourceInfo(UnionType);
9701 return Incompatible;
9707 for (
auto *it : UD->
fields()) {
9708 if (it->getType()->isPointerType()) {
9714 RHS = ImpCastExprToType(RHS.
get(), it->
getType(), CK_BitCast);
9721 RHS = ImpCastExprToType(RHS.
get(), it->
getType(),
9729 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
9738 return Incompatible;
9747 bool DiagnoseCFAudited,
9751 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
9757 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
9761 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
9762 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
9764 diag::warn_noderef_to_dereferenceable_pointer)
9788 return Incompatible;
9793 return Incompatible;
9795 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9796 !ObjC().CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
9797 result = IncompatibleObjCWeakRef;
9809 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
9810 RHS.
get(), LHSType,
false, DAP))
9811 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
9813 return Incompatible;
9829 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
9831 return Incompatible;
9846 if (Diagnose || ConvertRHS) {
9849 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
9866 if (Diagnose || ConvertRHS) {
9880 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
9886 CheckAssignmentConstraints(LHSType, RHS,
Kind, ConvertRHS);
9894 if (result != Incompatible && RHS.
get()->
getType() != LHSType) {
9901 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9906 return Incompatible;
9908 if (getLangOpts().ObjC &&
9909 (ObjC().CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
9911 ObjC().CheckConversionToObjCLiteral(LHSType, E, Diagnose))) {
9913 return Incompatible;
9921 RHS = ImpCastExprToType(E, Ty,
Kind);
9931 struct OriginalOperand {
9932 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(nullptr) {
9933 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
9934 Op = MTE->getSubExpr();
9935 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
9936 Op = BTE->getSubExpr();
9937 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
9938 Orig = ICE->getSubExprAsWritten();
9939 Conversion = ICE->getConversionFunction();
9943 QualType getType()
const {
return Orig->getType(); }
9952 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
9954 Diag(
Loc, diag::err_typecheck_invalid_operands)
9955 << OrigLHS.getType() << OrigRHS.getType()
9960 if (OrigLHS.Conversion) {
9961 Diag(OrigLHS.Conversion->getLocation(),
9962 diag::note_typecheck_invalid_operands_converted)
9965 if (OrigRHS.Conversion) {
9966 Diag(OrigRHS.Conversion->getLocation(),
9967 diag::note_typecheck_invalid_operands_converted)
9985 if (!(LHSNatVec && RHSNatVec)) {
9987 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
9988 Diag(
Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
9990 <<
Vector->getSourceRange();
9994 Diag(
Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10017 unsigned &DiagID) {
10026 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10031 scalarCast = CK_IntegralCast;
10036 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10039 scalarCast = CK_FloatingCast;
10042 scalarCast = CK_IntegralToFloating;
10051 if (scalarCast != CK_NoOp)
10062 assert(VecTy &&
"Expression E must be a vector");
10067 VecTy->getVectorKind());
10071 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10072 if (ICE->getSubExpr()->getType() == NewVecTy)
10073 return ICE->getSubExpr();
10083 QualType IntTy = Int->get()->getType().getUnqualifiedType();
10089 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
10098 unsigned NumBits = IntSigned
10099 ? (Result.isNegative() ? Result.getSignificantBits()
10100 : Result.getActiveBits())
10101 : Result.getActiveBits();
10108 return (IntSigned != OtherIntSigned &&
10114 return (Order < 0);
10121 QualType IntTy = Int->get()->getType().getUnqualifiedType();
10126 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
10138 llvm::APFloat::rmTowardZero);
10141 bool Ignored =
false;
10142 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
10144 if (Result != ConvertBack)
10150 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
10152 if (Bits > FloatPrec)
10165 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
10166 QualType VectorTy =
Vector->get()->getType().getUnqualifiedType();
10170 assert(!isa<ExtVectorType>(VT) &&
10171 "ExtVectorTypes should not be handled here!");
10172 VectorEltTy = VT->getElementType();
10177 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
10203 ScalarCast = CK_IntegralCast;
10207 ScalarCast = CK_FloatingToIntegral;
10221 bool CstScalar = Scalar->get()->isValueDependent() ||
10222 Scalar->get()->EvaluateAsFloat(Result, S.
Context);
10224 if (!CstScalar && Order < 0)
10230 bool Truncated =
false;
10232 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10237 ScalarCast = CK_FloatingCast;
10242 ScalarCast = CK_IntegralToFloating;
10249 if (ScalarCast != CK_NoOp)
10257 bool AllowBothBool,
10258 bool AllowBoolConversions,
10259 bool AllowBoolOperation,
10260 bool ReportInvalid) {
10261 if (!IsCompAssign) {
10262 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10266 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10277 assert(LHSVecType || RHSVecType);
10281 if (!AllowBothBool && LHSVecType &&
10284 return ReportInvalid ? InvalidOperands(
Loc, LHS, RHS) :
QualType();
10287 if (!AllowBoolOperation &&
10289 return ReportInvalid ? InvalidOperands(
Loc, LHS, RHS) :
QualType();
10296 if (LHSVecType && RHSVecType &&
10298 if (isa<ExtVectorType>(LHSVecType)) {
10299 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10304 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10311 if (AllowBoolConversions && LHSVecType && RHSVecType &&
10314 Context.
getTypeSize(RHSVecType->getElementType()))) {
10318 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10321 if (!IsCompAssign &&
10324 RHSVecType->getElementType()->isIntegerType()) {
10325 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10333 unsigned &SVEorRVV) {
10351 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
10352 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
10353 Diag(
Loc, diag::err_typecheck_sve_rvv_ambiguous)
10354 << SVEorRVV << LHSType << RHSType;
10361 unsigned &SVEorRVV) {
10366 if (FirstVecType && SecondVecType) {
10369 SecondVecType->getVectorKind() ==
10381 if (SecondVecType &&
10394 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
10395 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
10396 Diag(
Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
10397 << SVEorRVV << LHSType << RHSType;
10403 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
10405 if (isa<ExtVectorType>(LHSVecType)) {
10416 if (isa<ExtVectorType>(RHSVecType)) {
10418 LHSType, RHSVecType->getElementType(),
10431 QualType VecType = LHSVecType ? LHSType : RHSType;
10432 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
10433 QualType OtherType = LHSVecType ? RHSType : LHSType;
10434 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
10435 if (isLaxVectorConversion(OtherType, VecType)) {
10437 anyAltivecTypes(RHSType, LHSType) &&
10439 Diag(
Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
10443 if (!IsCompAssign) {
10444 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
10454 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
10462 if ((!RHSVecType && !RHSType->
isRealType()) ||
10464 Diag(
Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10465 << LHSType << RHSType
10474 if (getLangOpts().
OpenCL &&
10475 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
10476 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
10477 Diag(
Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
10486 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
10487 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
10488 QualType Scalar = LHSVecType ? RHSType : LHSType;
10490 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
10492 diag::err_typecheck_vector_not_convertable_implict_truncation)
10493 << ScalarOrVector << Scalar <<
Vector;
10500 << LHSType << RHSType
10509 if (!IsCompAssign) {
10510 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10514 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10524 unsigned DiagID = diag::err_typecheck_invalid_operands;
10525 if ((OperationKind == ACK_Arithmetic) &&
10526 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
10527 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
10548 Diag(
Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10557 Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
10566 bool ScalarOrVector =
10569 Diag(
Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
10570 << ScalarOrVector << Scalar <<
Vector;
10602 S.
Diag(
Loc, diag::warn_null_in_arithmetic_operation)
10614 S.
Diag(
Loc, diag::warn_null_in_comparison_operation)
10615 << LHSNull << NonNullType
10621 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
10622 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
10625 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
10626 RUE->getKind() != UETT_SizeOf)
10633 if (RUE->isArgumentType())
10634 RHSTy = RUE->getArgumentType().getNonReferenceType();
10636 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
10643 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
10644 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
10645 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
10649 QualType ArrayElemTy = ArrayTy->getElementType();
10655 S.
Diag(
Loc, diag::warn_division_sizeof_array)
10657 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
10658 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
10659 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
10663 S.
Diag(
Loc, diag::note_precedence_silence) << RHS;
10676 S.
PDiag(diag::warn_remainder_division_by_zero)
10682 bool IsCompAssign,
bool IsDiv) {
10688 return CheckVectorOperands(LHS, RHS,
Loc, IsCompAssign,
10689 getLangOpts().AltiVec,
10694 return CheckSizelessVectorOperands(LHS, RHS,
Loc, IsCompAssign,
10698 return CheckMatrixMultiplyOperands(LHS, RHS,
Loc, IsCompAssign);
10702 return CheckMatrixElementwiseOperands(LHS, RHS,
Loc, IsCompAssign);
10704 QualType compType = UsualArithmeticConversions(
10705 LHS, RHS,
Loc, IsCompAssign ? ACK_CompAssign : ACK_Arithmetic);
10711 return InvalidOperands(
Loc, LHS, RHS);
10727 return CheckVectorOperands(LHS, RHS,
Loc, IsCompAssign,
10728 getLangOpts().AltiVec,
10732 return InvalidOperands(
Loc, LHS, RHS);
10739 return CheckSizelessVectorOperands(LHS, RHS,
Loc, IsCompAssign,
10742 return InvalidOperands(
Loc, LHS, RHS);
10745 QualType compType = UsualArithmeticConversions(
10746 LHS, RHS,
Loc, IsCompAssign ? ACK_CompAssign : ACK_Arithmetic);
10751 return InvalidOperands(
Loc, LHS, RHS);
10760 ? diag::err_typecheck_pointer_arith_void_type
10761 : diag::ext_gnu_void_ptr)
10770 ? diag::err_typecheck_pointer_arith_void_type
10771 : diag::ext_gnu_void_ptr)
10772 << 0 << Pointer->getSourceRange();
10781 Expr *Pointer,
bool IsGNUIdiom) {
10783 S.
Diag(
Loc, diag::warn_gnu_null_ptr_arith)
10784 << Pointer->getSourceRange();
10786 S.
Diag(
Loc, diag::warn_pointer_arith_null_ptr)
10787 << S.
getLangOpts().CPlusPlus << Pointer->getSourceRange();
10793 Expr *Pointer,
bool BothNull) {
10803 S.
PDiag(diag::warn_pointer_sub_null_ptr)
10805 << Pointer->getSourceRange());
10814 ? diag::err_typecheck_pointer_arith_function_type
10815 : diag::ext_gnu_ptr_func_arith)
10827 assert(Pointer->getType()->isAnyPointerType());
10829 ? diag::err_typecheck_pointer_arith_function_type
10830 : diag::ext_gnu_ptr_func_arith)
10831 << 0 << Pointer->getType()->getPointeeType()
10833 << Pointer->getSourceRange();
10841 QualType ResType = Operand->getType();
10843 ResType = ResAtomicType->getValueType();
10849 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
10850 Operand->getSourceRange());
10863 QualType ResType = Operand->getType();
10865 ResType = ResAtomicType->getValueType();
10897 if (!isLHSPointer && !isRHSPointer)
return true;
10899 QualType LHSPointeeTy, RHSPointeeTy;
10904 if (isLHSPointer && isRHSPointer) {
10907 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10915 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
10916 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
10917 if (isLHSVoidPtr || isRHSVoidPtr) {
10925 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
10926 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
10927 if (isLHSFuncPtr || isRHSFuncPtr) {
10949 Expr* IndexExpr = RHSExpr;
10952 IndexExpr = LHSExpr;
10955 bool IsStringPlusInt = StrExpr &&
10961 Self.Diag(OpLoc, diag::warn_string_plus_int)
10965 if (IndexExpr == RHSExpr) {
10967 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
10972 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
10978 const Expr *StringRefExpr = LHSExpr;
10983 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
10984 StringRefExpr = RHSExpr;
10987 if (!CharExpr || !StringRefExpr)
11007 Self.Diag(OpLoc, diag::warn_string_plus_char)
11008 << DiagRange << Ctx.
CharTy;
11010 Self.Diag(OpLoc, diag::warn_string_plus_char)
11011 << DiagRange << CharExpr->
getType();
11017 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11022 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11031 S.
Diag(
Loc, diag::err_typecheck_sub_ptr_compatible)
11045 CheckVectorOperands(LHS, RHS,
Loc, CompLHSTy,
11046 getLangOpts().AltiVec,
11047 getLangOpts().ZVector,
11050 if (CompLHSTy) *CompLHSTy = compType;
11057 CheckSizelessVectorOperands(LHS, RHS,
Loc, CompLHSTy, ACK_Arithmetic);
11059 *CompLHSTy = compType;
11066 CheckMatrixElementwiseOperands(LHS, RHS,
Loc, CompLHSTy);
11068 *CompLHSTy = compType;
11072 QualType compType = UsualArithmeticConversions(
11073 LHS, RHS,
Loc, CompLHSTy ? ACK_CompAssign : ACK_Arithmetic);
11078 if (Opc == BO_Add) {
11085 if (CompLHSTy) *CompLHSTy = compType;
11099 std::swap(PExp, IExp);
11105 return InvalidOperands(
Loc, LHS, RHS);
11110 if (!IExp->getType()->isIntegerType())
11111 return InvalidOperands(
Loc, LHS, RHS);
11119 (!IExp->isValueDependent() &&
11120 (!IExp->EvaluateAsInt(KnownVal, Context) ||
11124 Context, BO_Add, PExp, IExp);
11136 CheckArrayAccess(PExp, IExp);
11145 *CompLHSTy = LHSTy;
11160 CheckVectorOperands(LHS, RHS,
Loc, CompLHSTy,
11161 getLangOpts().AltiVec,
11162 getLangOpts().ZVector,
11165 if (CompLHSTy) *CompLHSTy = compType;
11172 CheckSizelessVectorOperands(LHS, RHS,
Loc, CompLHSTy, ACK_Arithmetic);
11174 *CompLHSTy = compType;
11181 CheckMatrixElementwiseOperands(LHS, RHS,
Loc, CompLHSTy);
11183 *CompLHSTy = compType;
11187 QualType compType = UsualArithmeticConversions(
11188 LHS, RHS,
Loc, CompLHSTy ? ACK_CompAssign : ACK_Arithmetic);
11196 if (CompLHSTy) *CompLHSTy = compType;
11230 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
11233 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11277 if (ElementSize.
isZero()) {
11278 Diag(
Loc,diag::warn_sub_ptr_zero_size_types)
11284 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11289 return InvalidOperands(
Loc, LHS, RHS);
11294 return ET->getDecl()->isScoped();
11313 if (Right.isNegative()) {
11315 S.
PDiag(diag::warn_shift_negative)
11326 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
11328 if (Right.uge(LeftSize)) {
11330 S.
PDiag(diag::warn_shift_gt_typewidth)
11361 if (Left.isNegative()) {
11363 S.
PDiag(diag::warn_shift_lhs_negative)
11369 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
11370 if (ResultBits.ule(LeftSize))
11372 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
11373 Result = Result.shl(Right);
11378 Result.toString(HexResult, 16,
false,
true);
11384 if (ResultBits - 1 == LeftSize) {
11385 S.
Diag(
Loc, diag::warn_shift_result_sets_sign_bit)
11386 << HexResult << LHSType
11391 S.
Diag(
Loc, diag::warn_shift_result_gt_typewidth)
11392 << HexResult.str() << Result.getSignificantBits() << LHSType
11404 S.
Diag(
Loc, diag::err_shift_rhs_only_vector)
11410 if (!IsCompAssign) {
11432 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11439 if (!LHSEleType->isIntegerType()) {
11440 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11445 if (!RHSEleType->isIntegerType()) {
11446 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11455 if (LHSEleType != RHSEleType) {
11457 LHSEleType = RHSEleType;
11463 }
else if (RHSVecTy) {
11468 S.
Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
11476 if (LHSBT != RHSBT &&
11478 S.
Diag(
Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
11495 bool IsCompAssign) {
11496 if (!IsCompAssign) {
11519 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
11520 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
11521 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11526 if (!LHSEleType->isIntegerType()) {
11527 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11532 if (!RHSEleType->isIntegerType()) {
11533 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11541 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11551 if (LHSEleType != RHSEleType) {
11553 LHSEleType = RHSEleType;
11555 const llvm::ElementCount VecSize =
11564 S.
Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
11570 const llvm::ElementCount VecSize =
11572 if (LHSEleType != RHSEleType) {
11574 RHSEleType = LHSEleType;
11587 bool IsCompAssign) {
11593 if (LangOpts.ZVector) {
11599 return InvalidOperands(
Loc, LHS, RHS);
11602 return InvalidOperands(
Loc, LHS, RHS);
11617 LHS = UsualUnaryConversions(LHS.
get());
11621 if (IsCompAssign) LHS = OldLHS;
11624 RHS = UsualUnaryConversions(RHS.
get());
11634 return InvalidOperands(
Loc, LHS, RHS);
11640 return InvalidOperands(
Loc, LHS, RHS);
11652 S.
Diag(
Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
11653 : diag::ext_typecheck_comparison_of_distinct_pointers)
11693 S.
Diag(
Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
11694 : diag::ext_typecheck_comparison_of_fptr_to_void)
11701 case Stmt::ObjCArrayLiteralClass:
11702 case Stmt::ObjCDictionaryLiteralClass:
11703 case Stmt::ObjCStringLiteralClass:
11704 case Stmt::ObjCBoxedExprClass:
11784 llvm_unreachable(
"Unknown Objective-C object literal kind");
11788 S.
Diag(
Loc, diag::warn_objc_string_literal_comparison)
11789 <<
Literal->getSourceRange();
11791 S.
Diag(
Loc, diag::warn_objc_literal_comparison)
11792 << LiteralKind <<
Literal->getSourceRange();
11801 S.
Diag(
Loc, diag::note_objc_literal_comparison_isequal)
11814 if (!UO || UO->
getOpcode() != UO_LNot)
return;
11824 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
11826 <<
Loc << IsBitwiseOp;
11853 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
11855 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
11856 if (Mem->isImplicitAccess())
11857 D = Mem->getMemberDecl();
11912 S.
Diag(
Loc, diag::warn_depr_array_comparison)
11927 Result = AlwaysTrue;
11932 Result = AlwaysFalse;
11935 Result = AlwaysEqual;
11938 Result = AlwaysConstant;
11942 S.
PDiag(diag::warn_comparison_always)
11950 Result = AlwaysFalse;
11953 Result = AlwaysTrue;
11957 Result = AlwaysConstant;
11961 S.
PDiag(diag::warn_comparison_always)
11967 if (isa<CastExpr>(LHSStripped))
11969 if (isa<CastExpr>(RHSStripped))
11974 Expr *LiteralString =
nullptr;
11975 Expr *LiteralStringStripped =
nullptr;
11976 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
11979 LiteralString = LHS;
11980 LiteralStringStripped = LHSStripped;
11981 }
else if ((isa<StringLiteral>(RHSStripped) ||
11982 isa<ObjCEncodeExpr>(RHSStripped)) &&
11985 LiteralString = RHS;
11986 LiteralStringStripped = RHSStripped;
11989 if (LiteralString) {
11991 S.
PDiag(diag::warn_stringcompare)
11992 << isa<ObjCEncodeExpr>(LiteralStringStripped)
12004 llvm_unreachable(
"unhandled cast kind");
12006 case CK_UserDefinedConversion:
12008 case CK_LValueToRValue:
12010 case CK_ArrayToPointerDecay:
12012 case CK_FunctionToPointerDecay:
12014 case CK_IntegralCast:
12016 case CK_FloatingCast:
12018 case CK_IntegralToFloating:
12019 case CK_FloatingToIntegral:
12021 case CK_IntegralComplexCast:
12022 case CK_FloatingComplexCast:
12023 case CK_FloatingComplexToIntegralComplex:
12024 case CK_IntegralComplexToFloatingComplex:
12026 case CK_FloatingComplexToReal:
12027 case CK_FloatingRealToComplex:
12028 case CK_IntegralComplexToReal:
12029 case CK_IntegralRealToComplex:
12031 case CK_HLSLArrayRValue:
12044 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
12071 << 0 << FromType << ToType;
12076 llvm_unreachable(
"unhandled case in switch");
12103 if (NumEnumArgs == 1) {
12105 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
12111 if (NumEnumArgs == 2) {
12120 LHSStrippedType->
castAs<
EnumType>()->getDecl()->getIntegerType();
12131 LHSType = RHSType = IntType;
12143 std::optional<ComparisonCategoryType> CCT =
12155 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
12191 int NullValue = PP.isMacroDefined(
"NULL") ? 0 : 1;
12196 if (
const auto *CL = dyn_cast<CharacterLiteral>(E.
get())) {
12197 if (CL->getValue() == 0)
12201 NullValue ?
"NULL" :
"(void *)0");
12202 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
12209 NullValue ?
"NULL" :
"(void *)0");
12219 bool IsThreeWay = Opc == BO_Cmp;
12220 bool IsOrdered = IsRelational || IsThreeWay;
12231 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
12232 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
12235 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
12239 LHS = DefaultLvalueConversion(LHS.
get());
12242 RHS = DefaultLvalueConversion(RHS.
get());
12249 CheckPtrComparisonWithNullChar(LHS, RHS);
12250 CheckPtrComparisonWithNullChar(RHS, LHS);
12256 return CheckVectorCompareOperands(LHS, RHS,
Loc, Opc);
12260 return CheckSizelessVectorCompareOperands(LHS, RHS,
Loc, Opc);
12275 return InvalidOperands(
Loc, LHS, RHS);
12284 auto computeResultTy = [&]() {
12293 std::optional<ComparisonCategoryType> CCT =
12296 return InvalidOperands(
Loc, LHS, RHS);
12298 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
12302 Diag(
Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
12308 return CheckComparisonCategoryType(
12309 *CCT,
Loc, ComparisonCategoryUsage::OperatorInExpression);
12312 if (!IsOrdered && LHSIsNull != RHSIsNull) {
12313 bool IsEquality = Opc == BO_EQ;
12315 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
12318 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
12325 bool IsError = Opc == BO_Cmp;
12327 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
12328 : getLangOpts().CPlusPlus
12329 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
12330 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
12353 *
this,
Loc, LHS, RHS, (
bool)isSFINAEContext());
12355 if (isSFINAEContext())
12358 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
12359 return computeResultTy();
12375 (IsOrdered ? 2 : 1) &&
12380 return computeResultTy();
12394 if (IsRelational) {
12398 !getLangOpts().C11) {
12399 Diag(
Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
12405 }
else if (!IsRelational &&
12409 && !LHSIsNull && !RHSIsNull)
12416 if (LCanPointeeTy != RCanPointeeTy) {
12418 if (getLangOpts().
OpenCL && !LHSIsNull && !RHSIsNull) {
12421 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
12422 << LHSType << RHSType << 0
12428 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
12430 if (LHSIsNull && !RHSIsNull)
12431 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
12433 RHS = ImpCastExprToType(RHS.
get(), LHSType,
Kind);
12435 return computeResultTy();
12447 if (!IsOrdered && LHSIsNull && RHSIsNull) {
12449 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12450 return computeResultTy();
12453 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12454 return computeResultTy();
12458 if (!getLangOpts().
CPlusPlus && !IsOrdered && (LHSIsNull || RHSIsNull)) {
12464 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12465 return computeResultTy();
12468 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12469 return computeResultTy();
12477 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12478 return computeResultTy();
12482 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12483 return computeResultTy();
12487 if (IsRelational &&
12496 if (isa<FunctionDecl>(DC))
12498 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
12499 if (CTSD->isInStdNamespace() &&
12500 llvm::StringSwitch<bool>(CTSD->getName())
12501 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
12504 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12506 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12507 return computeResultTy();
12520 return computeResultTy();
12530 if (!LHSIsNull && !RHSIsNull &&
12532 Diag(
Loc, diag::err_typecheck_comparison_of_distinct_blocks)
12536 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
12537 return computeResultTy();
12544 if (!LHSIsNull && !RHSIsNull) {
12549 Diag(
Loc, diag::err_typecheck_comparison_of_distinct_blocks)
12553 if (LHSIsNull && !RHSIsNull)
12554 LHS = ImpCastExprToType(LHS.
get(), RHSType,
12556 : CK_AnyPointerToBlockPointerCast);
12558 RHS = ImpCastExprToType(RHS.
get(), LHSType,
12560 : CK_AnyPointerToBlockPointerCast);
12561 return computeResultTy();
12570 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
12572 if (!LPtrToVoid && !RPtrToVoid &&
12580 if (LHSIsNull && !RHSIsNull) {
12582 if (getLangOpts().ObjCAutoRefCount)
12583 ObjC().CheckObjCConversion(
SourceRange(), RHSType, E,
12585 LHS = ImpCastExprToType(E, RHSType,
12586 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
12590 if (getLangOpts().ObjCAutoRefCount)
12591 ObjC().CheckObjCConversion(
SourceRange(), LHSType, E,
12595 RHS = ImpCastExprToType(E, LHSType,
12596 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
12598 return computeResultTy();
12608 if (LHSIsNull && !RHSIsNull)
12609 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
12611 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
12612 return computeResultTy();
12617 LHS = ImpCastExprToType(LHS.
get(), RHSType,
12618 CK_BlockPointerToObjCPointerCast);
12619 return computeResultTy();
12620 }
else if (!IsOrdered &&
12623 RHS = ImpCastExprToType(RHS.
get(), LHSType,
12624 CK_BlockPointerToObjCPointerCast);
12625 return computeResultTy();
12630 unsigned DiagID = 0;
12631 bool isError =
false;
12632 if (LangOpts.DebuggerSupport) {
12638 isError = getLangOpts().CPlusPlus;
12640 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
12641 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
12644 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
12646 }
else if (IsOrdered)
12647 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
12649 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
12660 LHS = ImpCastExprToType(LHS.
get(), RHSType,
12661 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
12663 RHS = ImpCastExprToType(RHS.
get(), LHSType,
12664 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
12665 return computeResultTy();
12669 if (!IsOrdered && RHSIsNull
12671 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12672 return computeResultTy();
12674 if (!IsOrdered && LHSIsNull
12676 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12677 return computeResultTy();
12680 if (getLangOpts().getOpenCLCompatibleVersion() >= 200) {
12682 return computeResultTy();
12686 return computeResultTy();
12689 if (LHSIsNull && RHSType->
isQueueT()) {
12690 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
12691 return computeResultTy();
12694 if (LHSType->
isQueueT() && RHSIsNull) {
12695 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
12696 return computeResultTy();
12700 return InvalidOperands(
Loc, LHS, RHS);
12712 if (isa<ExtVectorType>(VTy)) {
12726 "Unhandled vector element size in vector compare");
12746 "Unhandled vector element size in vector compare");
12755 const QualType ETy =
V->getSveEltType(Context);
12770 if (Opc == BO_Cmp) {
12771 Diag(
Loc, diag::err_three_way_vector_comparison);
12778 CheckVectorOperands(LHS, RHS,
Loc,
false,
12780 getLangOpts().ZVector,
12793 if (getLangOpts().AltiVec) {
12794 switch (getLangOpts().getAltivecSrcCompat()) {
12802 Diag(
Loc, diag::warn_deprecated_altivec_src_compat);
12821 CheckFloatComparison(
Loc, LHS.
get(), RHS.
get(), Opc);
12825 return GetSignedVectorType(vType);
12832 if (Opc == BO_Cmp) {
12833 Diag(
Loc, diag::err_three_way_vector_comparison);
12839 QualType vType = CheckSizelessVectorOperands(
12840 LHS, RHS,
Loc,
false, ACK_Comparison);
12855 CheckFloatComparison(
Loc, LHS.
get(), RHS.
get(), Opc);
12861 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
12862 RHSBuiltinTy->isSVEBool())
12866 return GetSignedSizelessVectorType(vType);
12881 bool Negative =
false;
12882 bool ExplicitPlus =
false;
12883 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
12884 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
12890 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
12892 if (Opc != UO_Minus && Opc != UO_Plus)
12894 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
12897 Negative = (Opc == UO_Minus);
12898 ExplicitPlus = !Negative;
12904 const llvm::APInt &LeftSideValue = LHSInt->getValue();
12906 if (LeftSideValue != 2 && LeftSideValue != 10)
12909 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
12914 llvm::StringRef ExprStr =
12919 llvm::StringRef XorStr =
12922 if (XorStr ==
"xor")
12933 RightSideValue = -RightSideValue;
12934 RHSStr =
"-" + RHSStr;
12935 }
else if (ExplicitPlus) {
12936 RHSStr =
"+" + RHSStr;
12939 StringRef LHSStrRef = LHSStr;
12940 StringRef RHSStrRef = RHSStr;
12943 if (LHSStrRef.starts_with(
"0b") || LHSStrRef.starts_with(
"0B") ||
12944 RHSStrRef.starts_with(
"0b") || RHSStrRef.starts_with(
"0B") ||
12945 LHSStrRef.starts_with(
"0x") || LHSStrRef.starts_with(
"0X") ||
12946 RHSStrRef.starts_with(
"0x") || RHSStrRef.starts_with(
"0X") ||
12947 (LHSStrRef.size() > 1 && LHSStrRef.starts_with(
"0")) ||
12948 (RHSStrRef.size() > 1 && RHSStrRef.starts_with(
"0")) ||
12949 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
12954 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
12955 int64_t RightSideIntValue = RightSideValue.getSExtValue();
12956 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
12957 std::string SuggestedExpr =
"1 << " + RHSStr;
12958 bool Overflow =
false;
12960 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
12962 if (RightSideIntValue < 64)
12963 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base)
12964 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
12966 else if (RightSideIntValue == 64)
12967 S.
Diag(
Loc, diag::warn_xor_used_as_pow)
12968 << ExprStr <<
toString(XorValue, 10,
true);
12972 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base_extra)
12973 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
12976 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
12979 S.
Diag(
Loc, diag::note_xor_used_as_pow_silence)
12980 << (
"0x2 ^ " + RHSStr) << SuggestXor;
12981 }
else if (LeftSideValue == 10) {
12982 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
12983 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base)
12984 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
12986 S.
Diag(
Loc, diag::note_xor_used_as_pow_silence)
12987 << (
"0xA ^ " + RHSStr) << SuggestXor;
12995 QualType vType = CheckVectorOperands(LHS, RHS,
Loc,
false,
13001 return InvalidOperands(
Loc, LHS, RHS);
13002 if (getLangOpts().
OpenCL &&
13003 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
13005 return InvalidOperands(
Loc, LHS, RHS);
13011 return InvalidLogicalVectorOperands(
Loc, LHS, RHS);
13013 return GetSignedVectorType(LHS.
get()->
getType());
13018 bool IsCompAssign) {
13019 if (!IsCompAssign) {
13020 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
13024 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
13035 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13044 if (LHSMatType && !RHSMatType) {
13049 return InvalidOperands(
Loc, OriginalLHS, OriginalRHS);
13052 if (!LHSMatType && RHSMatType) {
13053 LHS = tryConvertExprToType(LHS.
get(), RHSMatType->getElementType());
13056 return InvalidOperands(
Loc, OriginalLHS, OriginalRHS);
13059 return InvalidOperands(
Loc, LHS, RHS);
13064 bool IsCompAssign) {
13065 if (!IsCompAssign) {
13066 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
13070 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
13076 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13078 if (LHSMatType && RHSMatType) {
13079 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
13080 return InvalidOperands(
Loc, LHS, RHS);
13087 QualType LHSELTy = LHSMatType->getElementType(),
13090 return InvalidOperands(
Loc, LHS, RHS);
13096 return CheckMatrixElementwiseOperands(LHS, RHS,
Loc, IsCompAssign);
13118 bool IsCompAssign =
13119 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
13127 return CheckVectorOperands(LHS, RHS,
Loc, IsCompAssign,
13129 getLangOpts().ZVector,
13130 LegalBoolVecOperator,
13132 return InvalidOperands(
Loc, LHS, RHS);
13139 return CheckSizelessVectorOperands(LHS, RHS,
Loc, IsCompAssign,
13141 return InvalidOperands(
Loc, LHS, RHS);
13148 return CheckSizelessVectorOperands(LHS, RHS,
Loc, IsCompAssign,
13150 return InvalidOperands(
Loc, LHS, RHS);
13158 return InvalidOperands(
Loc, LHS, RHS);
13160 ExprResult LHSResult = LHS, RHSResult = RHS;
13161 QualType compType = UsualArithmeticConversions(
13162 LHSResult, RHSResult,
Loc, IsCompAssign ? ACK_CompAssign : ACK_BitwiseOp);
13163 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
13165 LHS = LHSResult.
get();
13166 RHS = RHSResult.
get();
13173 return InvalidOperands(
Loc, LHS, RHS);
13183 return CheckVectorLogicalOperands(LHS, RHS,
Loc);
13185 bool EnumConstantInBoolContext =
false;
13187 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
13188 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
13189 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
13190 EnumConstantInBoolContext =
true;
13194 if (EnumConstantInBoolContext)
13195 Diag(
Loc, diag::warn_enum_constant_in_bool_context);
13200 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
13201 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
13202 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
13203 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
13204 return InvalidOperands(
Loc, LHS, RHS);
13224 (Result != 0 && Result != 1)) {
13225 Diag(
Loc, diag::warn_logical_instead_of_bitwise)
13228 Diag(
Loc, diag::note_logical_instead_of_bitwise_change_operator)
13229 << (Opc == BO_LAnd ?
"&" :
"|")
13232 Opc == BO_LAnd ?
"&" :
"|");
13233 if (Opc == BO_LAnd)
13235 Diag(
Loc, diag::note_logical_instead_of_bitwise_remove_constant)
13250 return InvalidOperands(
Loc, LHS, RHS);
13253 LHS = UsualUnaryConversions(LHS.
get());
13257 RHS = UsualUnaryConversions(RHS.
get());
13263 return InvalidOperands(
Loc, LHS, RHS);
13265 return Context.
IntTy;
13274 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
13276 return InvalidOperands(
Loc, LHS, RHS);
13279 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
13281 return InvalidOperands(
Loc, LHS, RHS);
13291 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
13292 if (!ME)
return false;
13296 if (!
Base)
return false;
13297 return Base->getMethodDecl() !=
nullptr;
13316 if (
var->getType().isConstQualified())
return NCCK_None;
13317 assert(
var->hasLocalStorage() &&
"capture added 'const' to non-local?");
13325 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
13326 if (
var->isInitCapture() &&
13327 FD->getTemplateInstantiationPattern() ==
var->getDeclContext())
13329 if (DC ==
var->getDeclContext())
13335 if (!
var->isInitCapture())
13368 bool DiagnosticEmitted =
false;
13372 bool IsDereference =
false;
13373 bool NextIsDereference =
false;
13377 IsDereference = NextIsDereference;
13380 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
13381 NextIsDereference = ME->isArrow();
13382 const ValueDecl *VD = ME->getMemberDecl();
13383 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
13385 if (Field->isMutable()) {
13386 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
13391 if (!DiagnosticEmitted) {
13392 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13394 << Field->getType();
13395 DiagnosticEmitted =
true;
13398 <<
ConstMember <<
false << Field << Field->getType()
13399 << Field->getSourceRange();
13403 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
13404 if (VDecl->getType().isConstQualified()) {
13405 if (!DiagnosticEmitted) {
13406 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13408 << VDecl->getType();
13409 DiagnosticEmitted =
true;
13412 <<
ConstMember <<
true << VDecl << VDecl->getType()
13413 << VDecl->getSourceRange();
13420 dyn_cast<ArraySubscriptExpr>(E)) {
13424 dyn_cast<ExtVectorElementExpr>(E)) {
13431 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
13435 if (!DiagnosticEmitted) {
13436 S.
Diag(
Loc, diag::err_typecheck_assign_const) << ExprRange
13438 DiagnosticEmitted =
true;
13441 diag::note_typecheck_assign_const)
13445 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13447 if (
const ValueDecl *VD = DRE->getDecl()) {
13449 if (!DiagnosticEmitted) {
13450 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13452 DiagnosticEmitted =
true;
13454 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
13455 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
13458 }
else if (isa<CXXThisExpr>(E)) {
13460 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
13461 if (MD->isConst()) {
13462 if (!DiagnosticEmitted) {
13463 S.
Diag(
Loc, diag::err_typecheck_assign_const) << ExprRange
13465 DiagnosticEmitted =
true;
13467 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
13474 if (DiagnosticEmitted)
13491 bool &DiagnosticEmitted) {
13492 std::vector<const RecordType *> RecordTypeList;
13493 RecordTypeList.push_back(Ty);
13494 unsigned NextToCheckIndex = 0;
13497 while (RecordTypeList.size() > NextToCheckIndex) {
13498 bool IsNested = NextToCheckIndex > 0;
13500 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
13502 QualType FieldTy = Field->getType();
13504 if (!DiagnosticEmitted) {
13505 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13507 << IsNested << Field;
13508 DiagnosticEmitted =
true;
13510 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
13512 << FieldTy << Field->getSourceRange();
13518 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
13519 RecordTypeList.push_back(FieldRecTy);
13522 ++NextToCheckIndex;
13531 assert(Ty->
isRecordType() &&
"lvalue was not record?");
13534 bool DiagEmitted =
false;
13536 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
13539 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
13564 unsigned DiagID = 0;
13565 bool NeedType =
false;
13572 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
13574 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
13582 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
13587 if (
var->isARCPseudoStrong() &&
13588 (!
var->getTypeSourceInfo() ||
13589 !
var->getTypeSourceInfo()->getType().isConstQualified())) {
13595 ? diag::err_typecheck_arc_assign_self_class_method
13596 : diag::err_typecheck_arc_assign_self;
13599 }
else if (
var->hasAttr<ObjCExternallyRetainedAttr>() ||
13600 isa<ParmVarDecl>(
var)) {
13601 DiagID = diag::err_typecheck_arc_assign_externally_retained;
13605 DiagID = diag::err_typecheck_arr_assign_enumeration;
13609 if (
Loc != OrigLoc)
13635 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
13639 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
13643 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
13646 llvm_unreachable(
"did not take early return for MLV_Valid");
13650 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
13655 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
13657 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
13660 llvm_unreachable(
"readonly properties should be processed differently");
13662 DiagID = diag::err_readonly_message_assignment;
13665 DiagID = diag::err_no_subobject_property_setting;
13670 if (
Loc != OrigLoc)
13692 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
13693 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
13695 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->
getBase())))
13701 if (LHSDecl != RHSDecl)
13706 if (RefTy->getPointeeType().isVolatileQualified())
13709 Sema.
Diag(
Loc, diag::warn_identity_field_assign) << 0;
13719 Sema.
Diag(
Loc, diag::warn_identity_field_assign) << 1;
13740 if (getLangOpts().
OpenCL &&
13741 !getOpenCLOptions().isAvailableOption(
"cl_khr_fp16", getLangOpts()) &&
13743 Diag(
Loc, diag::err_opencl_half_load_store) << 1
13750 Diag(
Loc, diag::err_wasm_table_art) << 0;
13755 if (CompoundType.
isNull()) {
13761 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
13765 if (ConvTy == IncompatiblePointer &&
13770 ConvTy = Compatible;
13772 if (ConvTy == Compatible &&
13774 Diag(
Loc, diag::err_objc_object_assignment)
13781 RHSCheck = ICE->getSubExpr();
13782 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
13783 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
13784 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
13790 UO->getSubExpr()->getBeginLoc().
isFileID()) {
13791 Diag(
Loc, diag::warn_not_compound_assign)
13792 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
13793 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
13797 if (ConvTy == Compatible) {
13803 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
13805 ObjC().checkRetainCycles(LHSExpr, RHS.
get());
13819 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
13821 getCurFunction()->markSafeWeakUse(RHS.
get());
13823 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
13824 checkUnsafeExprAssigns(
Loc, LHSExpr, RHS.
get());
13829 ConvTy = CheckAssignmentConstraints(
Loc, LHSType, RHSType);
13832 if (DiagnoseAssignmentResult(ConvTy,
Loc, LHSType, RHSType,
13833 RHS.
get(), AA_Assigning))
13839 if (CompoundType.
isNull()) {
13844 ExprEvalContexts.back().VolatileAssignmentLHSs.push_back(LHSExpr);
13865 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
13866 if (CE->getCastKind() == CK_ToVoid) {
13872 CE->getSubExpr()->getType()->isDependentType()) {
13877 if (
const auto *CE = dyn_cast<CallExpr>(E))
13878 return CE->getCallReturnType(Context)->isVoidType();
13891 if (inTemplateInstantiation())
13901 const unsigned ForIncrementFlags =
13902 getLangOpts().C99 || getLangOpts().CPlusPlus
13906 const unsigned ScopeFlags = getCurScope()->getFlags();
13907 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
13908 (ScopeFlags & ForInitFlags) == ForInitFlags)
13913 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
13914 if (BO->getOpcode() != BO_Comma)
13916 LHS = BO->getRHS();
13923 Diag(
Loc, diag::warn_comma_operator);
13927 LangOpts.CPlusPlus ?
"static_cast<void>("
13959 diag::err_incomplete_type);
13980 ResType = ResAtomicType->getValueType();
13982 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
13992 : diag::warn_increment_bool)
13996 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
14012 S.
Diag(OpLoc, diag::ext_increment_complex)
14029 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
14040 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
14041 << IsInc << ResType;
14073 case Stmt::DeclRefExprClass:
14074 return cast<DeclRefExpr>(E)->getDecl();
14075 case Stmt::MemberExprClass:
14079 if (cast<MemberExpr>(E)->isArrow())
14083 case Stmt::ArraySubscriptExprClass: {
14086 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
14088 if (ICE->getSubExpr()->getType()->isArrayType())
14093 case Stmt::UnaryOperatorClass: {
14105 case Stmt::ParenExprClass:
14107 case Stmt::ImplicitCastExprClass:
14111 case Stmt::CXXUuidofExprClass:
14112 return cast<CXXUuidofExpr>(E)->getGuidDecl();
14121 AO_Vector_Element = 1,
14122 AO_Property_Expansion = 2,
14123 AO_Register_Variable = 3,
14124 AO_Matrix_Element = 4,
14139 const auto *DRE = cast<DeclRefExpr>(Op->
IgnoreParens());
14142 return Diag(OpLoc, diag::err_parens_pointer_member_function)
14146 if (isa<CXXDestructorDecl>(MD))
14147 return Diag(OpLoc, diag::err_typecheck_addrof_dtor)
14148 << DRE->getSourceRange();
14150 if (DRE->getQualifier())
14154 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14155 << DRE->getSourceRange();
14159 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14160 << DRE->getSourceRange()
14173 if (PTy->getKind() == BuiltinType::Overload) {
14175 if (!isa<OverloadExpr>(E)) {
14176 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
14177 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
14183 if (isa<UnresolvedMemberExpr>(Ovl))
14184 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
14185 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14193 if (PTy->getKind() == BuiltinType::UnknownAny)
14196 if (PTy->getKind() == BuiltinType::BoundMember) {
14197 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14202 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
14219 if (LangOpts.OpenCL) {
14220 auto* VarRef = dyn_cast<DeclRefExpr>(op);
14221 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
14222 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
14227 if (getLangOpts().
C99) {
14230 if (uOp->getOpcode() == UO_Deref)
14233 return uOp->getSubExpr()->getType();
14240 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
14246 unsigned AddressOfError = AO_No_Error;
14249 bool sfinae = (
bool)isSFINAEContext();
14250 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
14251 : diag::ext_typecheck_addrof_temporary)
14257 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
14258 }
else if (isa<ObjCSelectorExpr>(op)) {
14265 if (!isa<DeclRefExpr>(op)) {
14266 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14273 CheckUseOfCXXMethodAsAddressOfOperand(OpLoc, OrigOp.
get(), MD);
14279 (void)isCompleteType(OpLoc, MPTy);
14286 if (isa<PseudoObjectExpr>(op)) {
14287 AddressOfError = AO_Property_Expansion;
14289 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
14293 }
else if (
const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
14294 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl()))
14295 CheckUseOfCXXMethodAsAddressOfOperand(OpLoc, OrigOp.
get(), MD);
14300 AddressOfError = AO_Bit_Field;
14303 AddressOfError = AO_Vector_Element;
14306 AddressOfError = AO_Matrix_Element;
14310 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
14315 AddressOfError = AO_Register_Variable;
14317 }
else if (isa<MSPropertyDecl>(dcl)) {
14318 AddressOfError = AO_Property_Expansion;
14319 }
else if (isa<FunctionTemplateDecl>(dcl)) {
14321 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
14325 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
14330 diag::err_cannot_form_pointer_to_member_of_reference_type)
14338 if (isa<ParenExpr>(OrigOp.
get())) {
14343 diag::err_form_ptr_to_member_from_parenthesized_expr)
14351 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
14359 (void)isCompleteType(OpLoc, MPTy);
14365 llvm_unreachable(
"Unknown/unexpected decl type");
14368 if (AddressOfError != AO_No_Error) {
14388 Diag(OpLoc, diag::err_wasm_ca_reference)
14393 Diag(OpLoc, diag::err_wasm_table_pr)
14399 CheckAddressOfPackedMember(op);
14405 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
14411 const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
14415 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
14418 FD->ModifiedNonNullParams.insert(Param);
14424 bool IsAfterAmp =
false) {
14428 Op = ConvResult.
get();
14432 if (isa<CXXReinterpretCastExpr>(Op)) {
14440 Result = PT->getPointeeType();
14444 Result = OPT->getPointeeType();
14448 if (PR.
get() != Op)
14452 if (Result.isNull()) {
14453 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
14458 if (Result->isVoidType()) {
14464 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
14467 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
14475 if (!S.
getLangOpts().CPlusPlus && Result.isCForbiddenLValueType())
14484 default: llvm_unreachable(
"Unknown binop!");
14485 case tok::periodstar: Opc = BO_PtrMemD;
break;
14486 case tok::arrowstar: Opc = BO_PtrMemI;
break;
14487 case tok::star: Opc = BO_Mul;
break;
14488 case tok::slash: Opc = BO_Div;
break;
14489 case tok::percent: Opc = BO_Rem;
break;
14490 case tok::plus: Opc = BO_Add;
break;
14491 case tok::minus: Opc = BO_Sub;
break;
14492 case tok::lessless: Opc = BO_Shl;
break;
14493 case tok::greatergreater: Opc = BO_Shr;
break;
14494 case tok::lessequal: Opc = BO_LE;
break;
14495 case tok::less: Opc = BO_LT;
break;
14496 case tok::greaterequal: Opc = BO_GE;
break;
14497 case tok::greater: Opc = BO_GT;
break;
14498 case tok::exclaimequal: Opc = BO_NE;
break;
14499 case tok::equalequal: Opc = BO_EQ;
break;
14500 case tok::spaceship: Opc = BO_Cmp;
break;
14501 case tok::amp: Opc = BO_And;
break;
14502 case tok::caret: Opc = BO_Xor;
break;
14503 case tok::pipe: Opc = BO_Or;
break;
14504 case tok::ampamp: Opc = BO_LAnd;
break;
14505 case tok::pipepipe: Opc = BO_LOr;
break;
14506 case tok::equal: Opc = BO_Assign;
break;
14507 case tok::starequal: Opc = BO_MulAssign;
break;
14508 case tok::slashequal: Opc = BO_DivAssign;
break;
14509 case tok::percentequal: Opc = BO_RemAssign;
break;
14510 case tok::plusequal: Opc = BO_AddAssign;
break;
14511 case tok::minusequal: Opc = BO_SubAssign;
break;
14512 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
14513 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
14514 case tok::ampequal: Opc = BO_AndAssign;
break;
14515 case tok::caretequal: Opc = BO_XorAssign;
break;
14516 case tok::pipeequal: Opc = BO_OrAssign;
break;
14517 case tok::comma: Opc = BO_Comma;
break;
14526 default: llvm_unreachable(
"Unknown unary op!");
14527 case tok::plusplus: Opc = UO_PreInc;
break;
14528 case tok::minusminus: Opc = UO_PreDec;
break;
14529 case tok::amp: Opc = UO_AddrOf;
break;
14530 case tok::star: Opc = UO_Deref;
break;
14531 case tok::plus: Opc = UO_Plus;
break;
14532 case tok::minus: Opc = UO_Minus;
break;
14533 case tok::tilde: Opc = UO_Not;
break;
14534 case tok::exclaim: Opc = UO_LNot;
break;
14535 case tok::kw___real: Opc = UO_Real;
break;
14536 case tok::kw___imag: Opc = UO_Imag;
break;
14537 case tok::kw___extension__: Opc = UO_Extension;
break;
14553 if (!isa<ParmVarDecl>(SelfAssigned))
14555 const auto *Method =
14556 dyn_cast_or_null<CXXMethodDecl>(getCurFunctionDecl(
true));
14569 llvm::find_if(
Parent->fields(),
14571 return F->getDeclName() == Name;
14573 return (Field !=
Parent->field_end()) ? *Field :
nullptr;
14588 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
14589 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
14590 if (!LHSDeclRef || !RHSDeclRef ||
14598 if (LHSDecl != RHSDecl)
14603 if (RefTy->getPointeeType().isVolatileQualified())
14606 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
14607 : diag::warn_self_assignment_overloaded)
14612 Diag << 1 << SelfAssignField
14625 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
14630 ObjCPointerExpr = LHS;
14634 ObjCPointerExpr = RHS;
14642 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
14643 unsigned Diag = diag::warn_objc_pointer_masking;
14651 StringRef SelArg0 = S.getNameForSlot(0);
14652 if (SelArg0.starts_with(
"performSelector"))
14653 Diag = diag::warn_objc_pointer_masking_performSelector;
14664 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
14665 return DRE->getDecl();
14666 if (
auto *ME = dyn_cast<MemberExpr>(E))
14667 return ME->getMemberDecl();
14668 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
14669 return IRE->getDecl();
14684 "Result must be a vector of half or short");
14687 "both operands expected to be a half vector");
14699 ResultTy, VK, OK, OpLoc, FPFeatures,
14700 BinOpResTy, BinOpResTy);
14704 BinOpResTy, VK, OK, OpLoc, FPFeatures);
14708 static std::pair<ExprResult, ExprResult>
14718 RHS,
nullptr,
false,
14719 [Opc, LHS](
Expr *E) {
14720 if (Opc != BO_Assign)
14727 return std::make_pair(LHS, RHS);
14734 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType ||
14738 auto HasVectorOfHalfType = [&Ctx](
Expr *E) {
14748 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
14753 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
14762 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
14775 if (Init.isInvalid())
14777 RHSExpr = Init.get();
14787 bool ConvertHalfVec =
false;
14790 if (!LHS.
isUsable() || !RHS.isUsable())
14793 if (getLangOpts().
OpenCL) {
14800 if (BO_Assign == Opc)
14801 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
14803 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
14813 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
14818 checkTypeSupport(LHSExpr->
getType(), OpLoc,
nullptr);
14819 checkTypeSupport(RHSExpr->
getType(), OpLoc,
nullptr);
14823 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType(), Opc);
14829 if (!ResultTy.
isNull()) {
14831 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
14846 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
14848 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
14849 if (VD->hasLocalStorage() && getCurScope()->isDeclScope(VD))
14850 BE->getBlockDecl()->setCanAvoidCopyToHeap();
14854 NTCUC_Assignment, NTCUK_Copy);
14860 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
14861 Opc == BO_PtrMemI);
14865 ConvertHalfVec =
true;
14866 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
14870 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
14873 ConvertHalfVec =
true;
14874 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
14877 ConvertHalfVec =
true;
14878 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
14882 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
14888 ConvertHalfVec =
true;
14889 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
14891 if (
const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
14892 BI && BI->isComparisonOp())
14893 Diag(OpLoc, diag::warn_consecutive_comparison);
14898 ConvertHalfVec =
true;
14899 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
14902 ConvertHalfVec =
true;
14903 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
14911 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
14915 ConvertHalfVec =
true;
14916 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
14920 ConvertHalfVec =
true;
14921 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
14922 Opc == BO_DivAssign);
14923 CompLHSTy = CompResultTy;
14926 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14929 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
14930 CompLHSTy = CompResultTy;
14933 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14936 ConvertHalfVec =
true;
14937 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
14940 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14943 ConvertHalfVec =
true;
14944 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
14947 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14951 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
14952 CompLHSTy = CompResultTy;
14955 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14962 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
14963 CompLHSTy = CompResultTy;
14966 CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy, Opc);
14970 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
14971 VK = RHS.get()->getValueKind();
14972 OK = RHS.get()->getObjectKind();
14984 (Opc == BO_Comma ||
isVector(RHS.get()->getType(), Context.
HalfTy) ==
14986 "both sides are half vectors or neither sides are");
14991 CheckArrayAccess(LHS.
get());
14992 CheckArrayAccess(RHS.get());
14995 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
14996 &Context.
Idents.
get(
"object_setClass"),
14998 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
14999 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
15002 "object_setClass(")
15015 if (CompResultTy.
isNull()) {
15016 if (ConvertHalfVec)
15018 OpLoc, CurFPFeatureOverrides());
15020 VK, OK, OpLoc, CurFPFeatureOverrides());
15034 CompLHSTy = UsualUnaryConversions(LHS.
get()).get()->getType();
15036 if (ConvertHalfVec)
15038 OpLoc, CurFPFeatureOverrides());
15041 Context, LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, OpLoc,
15042 CurFPFeatureOverrides(), CompLHSTy, CompResultTy);
15058 if (isLeftComp == isRightComp)
15063 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
15064 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
15065 if (isLeftBitwise || isRightBitwise)
15077 Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
15080 Self.PDiag(diag::note_precedence_silence) << OpStr,
15081 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
15083 Self.PDiag(diag::note_precedence_bitwise_first)
15095 Self.Diag(Bop->
getOperatorLoc(), diag::warn_logical_and_in_logical_or)
15098 Self.PDiag(diag::note_precedence_silence)
15107 if (Bop->getOpcode() == BO_LAnd) {
15110 if (!isa<StringLiteral>(Bop->getLHS()->IgnoreParenImpCasts()))
15112 }
else if (Bop->getOpcode() == BO_LOr) {
15113 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
15116 if (RBop->getOpcode() == BO_LAnd &&
15117 isa<StringLiteral>(RBop->getRHS()->IgnoreParenImpCasts()))
15128 if (Bop->getOpcode() == BO_LAnd) {
15131 if (!isa<StringLiteral>(Bop->getRHS()->IgnoreParenImpCasts()))
15143 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
15144 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
15146 << Bop->getSourceRange() << OpLoc;
15148 S.
PDiag(diag::note_precedence_silence)
15149 << Bop->getOpcodeStr(),
15150 Bop->getSourceRange());
15158 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
15159 StringRef Op = Bop->getOpcodeStr();
15160 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
15161 << Bop->getSourceRange() << OpLoc <<
Shift << Op;
15163 S.
PDiag(diag::note_precedence_silence) << Op,
15164 Bop->getSourceRange());
15180 if (
Kind != OO_LessLess &&
Kind != OO_GreaterGreater)
15183 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
15185 << (
Kind == OO_LessLess);
15187 S.
PDiag(diag::note_precedence_silence)
15188 << (
Kind == OO_LessLess ?
"<<" :
">>"),
15191 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
15205 if ((Opc == BO_Or || Opc == BO_Xor) &&
15213 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
15219 || Opc == BO_Shr) {
15236 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
15237 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
15242 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
15248 if (OverOp !=
OO_None && OverOp != OO_Equal)
15249 LookupOverloadedOperatorName(OverOp, S, Functions);
15254 LookupOverloadedOperatorName(ExtraOp, S, Functions);
15302 LHSExpr = LHS.
get();
15303 RHSExpr = RHS.
get();
15314 if (pty->getKind() == BuiltinType::PseudoObject &&
15316 return PseudoObject().checkAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
15319 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload) {
15325 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
15327 RHSExpr = resolvedRHS.
get();
15340 if (Opc == BO_LT && inTemplateInstantiation() &&
15341 (pty->getKind() == BuiltinType::BoundMember ||
15342 pty->getKind() == BuiltinType::Overload)) {
15343 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
15344 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
15345 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
15346 return isa<FunctionTemplateDecl>(ND);
15348 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
15349 : OE->getNameLoc(),
15350 diag::err_template_kw_missing)
15351 << OE->getName().getAsString() <<
"";
15356 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
15358 LHSExpr = LHS.
get();
15365 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
15371 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
15375 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
15379 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
15381 RHSExpr = resolvedRHS.
get();
15393 if (getLangOpts().RecoveryAST &&
15397 "Should only occur in error-recovery path.");
15403 Context, LHSExpr, RHSExpr, Opc,
15405 OpLoc, CurFPFeatureOverrides());
15420 ResultType = Context.
IntTy;
15423 ResultType = RHSExpr->
getType();
15431 CurFPFeatureOverrides());
15435 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
15455 bool CanOverflow =
false;
15457 bool ConvertHalfVec =
false;
15458 if (getLangOpts().
OpenCL || getLangOpts().SYCLIsDevice) {
15466 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15473 if (Opc == UO_AddrOf)
15474 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
15475 if (Opc == UO_Deref)
15476 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
15490 Opc == UO_PreInc || Opc == UO_PostInc,
15491 Opc == UO_PreInc || Opc == UO_PreDec);
15495 resultType = CheckAddressOfOperand(Input, OpLoc);
15496 CheckAddressOfNoDeref(InputExpr);
15500 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
15509 CanOverflow = Opc == UO_Minus &&
15511 Input = UsualUnaryConversions(Input.
get());
15521 if (ConvertHalfVec)
15538 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15542 Input = UsualUnaryConversions(Input.
get());
15549 Diag(OpLoc, diag::ext_integer_complement_complex)
15558 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15561 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15568 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
15575 Input = ImpCastExprToType(Input.
get(), Context.
FloatTy, CK_FloatingCast)
15577 resultType = Context.
FloatTy;
15583 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15592 Input = ImpCastExprToType(Input.
get(), Context.
BoolTy,
15593 ScalarTypeToBooleanCastKind(resultType));
15599 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15609 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15613 resultType = GetSignedVectorType(resultType);
15619 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15623 resultType = GetSignedVectorType(resultType);
15626 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15648 Input = DefaultLvalueConversion(Input.
get());
15660 "the co_await expression must be non-dependant before "
15661 "building operator co_await");
15672 if (Opc != UO_AddrOf && Opc != UO_Deref)
15673 CheckArrayAccess(Input.
get());
15677 OpLoc, CanOverflow, CurFPFeatureOverrides());
15679 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
15680 !isa<ArrayType>(UO->getType().getDesugaredType(Context)) &&
15681 !isUnevaluatedContext())
15682 ExprEvalContexts.back().PossibleDerefs.insert(UO);
15685 if (ConvertHalfVec)
15694 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15695 if (!DRE->getQualifier())
15702 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
15705 return Method->isImplicitObjectMemberFunction();
15711 if (!ULE->getQualifier())
15716 if (Method->isImplicitObjectMemberFunction())
15737 if (pty->getKind() == BuiltinType::PseudoObject &&
15739 return PseudoObject().checkIncDec(S, OpLoc, Opc, Input);
15742 if (Opc == UO_Extension)
15743 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
15747 if (Opc == UO_AddrOf &&
15748 (pty->getKind() == BuiltinType::Overload ||
15749 pty->getKind() == BuiltinType::UnknownAny ||
15750 pty->getKind() == BuiltinType::BoundMember))
15751 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
15754 ExprResult Result = CheckPlaceholderExpr(Input);
15755 if (Result.isInvalid())
return ExprError();
15756 Input = Result.get();
15761 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
15766 LookupOverloadedOperatorName(OverOp, S, Functions);
15768 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
15771 return CreateBuiltinUnaryOp(OpLoc, Opc, Input, IsAfterAmp);
15776 Expr *Input,
bool IsAfterAmp) {
15789 if (getCurFunction())
15790 getCurFunction()->AddrLabels.push_back(Res);
15796 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
15798 setFunctionHasBranchProtectedScope();
15805 DiscardCleanupsInEvaluationContext();
15806 PopExpressionEvaluationContext();
15811 return BuildStmtExpr(LPLoc, SubStmt, RPLoc, getTemplateDepth(S));
15816 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
15819 if (hasAnyUnrecoverableErrorsInThisFunction())
15820 DiscardCleanupsInEvaluationContext();
15821 assert(!Cleanup.exprNeedsCleanups() &&
15822 "cleanups within StmtExpr not correctly bound!");
15823 PopExpressionEvaluationContext();
15832 bool StmtExprMayBindToTemp =
false;
15835 if (
const auto *LastStmt =
15837 if (
const Expr *
Value = LastStmt->getExprStmt()) {
15838 StmtExprMayBindToTemp =
true;
15846 Expr *ResStmtExpr =
15847 new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc, TemplateDepth);
15848 if (StmtExprMayBindToTemp)
15849 return MaybeBindToTemporary(ResStmtExpr);
15850 return ResStmtExpr;
15859 ER = DefaultFunctionArrayConversion(ER.
get());
15873 auto *
Cast = dyn_cast<ImplicitCastExpr>(E);
15874 if (
Cast &&
Cast->getCastKind() == CK_ARCConsumeObject)
15875 return Cast->getSubExpr();
15878 return PerformCopyInitialization(
15896 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
15897 << ArgTy << TypeRange);
15902 && RequireCompleteType(BuiltinLoc, ArgTy,
15903 diag::err_offsetof_incomplete_type, TypeRange))
15906 bool DidWarnAboutNonPOD =
false;
15911 if (OC.isBrackets) {
15916 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
15922 ExprResult IdxRval = DefaultLvalueConversion(
static_cast<Expr*
>(OC.U.E));
15936 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
15937 Exprs.push_back(Idx);
15945 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
15951 if (RequireCompleteType(OC.LocStart, CurrentType,
15952 diag::err_offsetof_incomplete_type))
15958 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
15970 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
15972 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
15973 : diag::ext_offsetof_non_pod_type;
15975 if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
15976 Diag(BuiltinLoc, DiagID)
15977 <<
SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
15978 DidWarnAboutNonPOD =
true;
15983 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
15984 LookupQualifiedName(R, RD);
15989 MemberDecl = IndirectMemberDecl->getAnonField();
15997 Diag(BuiltinLoc, diag::err_no_member)
15998 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart, OC.LocEnd);
16007 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
16015 if (IndirectMemberDecl)
16016 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
16023 if (Paths.getDetectedVirtual()) {
16024 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
16035 if (IndirectMemberDecl) {
16036 for (
auto *FI : IndirectMemberDecl->chain()) {
16037 assert(isa<FieldDecl>(FI));
16039 cast<FieldDecl>(FI), OC.LocEnd));
16042 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
16048 Comps, Exprs, RParenLoc);
16059 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
16066 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
16074 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
16079 bool CondIsTrue =
false;
16085 ExprResult CondICE = VerifyIntegerConstantExpression(
16086 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
16089 CondExpr = CondICE.
get();
16090 CondIsTrue = condEval.getZExtValue();
16093 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
16095 resType = ActiveExpr->
getType();
16100 return new (Context)
ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr,
16101 resType, VK, OK, RPLoc, CondIsTrue);
16112 if (LangOpts.CPlusPlus) {
16114 Decl *ManglingContextDecl;
16115 std::tie(MCtx, ManglingContextDecl) =
16116 getCurrentMangleNumberContext(
Block->getDeclContext());
16119 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
16123 PushBlockScope(CurScope,
Block);
16124 CurContext->addDecl(
Block);
16126 PushDeclContext(CurScope,
Block);
16128 CurContext =
Block;
16130 getCurBlock()->HasImplicitReturnType =
true;
16134 PushExpressionEvaluationContext(
16135 ExpressionEvaluationContext::PotentiallyEvaluated);
16141 "block-id should have no identifier!");
16150 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
16163 "GetTypeForDeclarator made a non-function block signature");
16179 unsigned Size = Result.getFullDataSize();
16191 QualType RetTy = Fn->getReturnType();
16193 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
16209 if (ExplicitSignature) {
16210 for (
unsigned I = 0, E = ExplicitSignature.
getNumParams(); I != E; ++I) {
16215 if (!getLangOpts().C23)
16218 Params.push_back(Param);
16224 for (
const auto &I : Fn->param_types()) {
16227 Params.push_back(Param);
16232 if (!Params.empty()) {
16239 ProcessDeclAttributes(CurScope, CurBlock->
TheDecl, ParamInfo);
16243 AI->setOwningFunction(CurBlock->
TheDecl);
16246 if (AI->getIdentifier()) {
16247 CheckShadow(CurBlock->
TheScope, AI);
16249 PushOnScopeChains(AI, CurBlock->
TheScope);
16252 if (AI->isInvalidDecl())
16261 DiscardCleanupsInEvaluationContext();
16262 PopExpressionEvaluationContext();
16266 PopFunctionScopeInfo();
16274 if (!LangOpts.Blocks)
16275 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
16278 if (hasAnyUnrecoverableErrorsInThisFunction())
16279 DiscardCleanupsInEvaluationContext();
16280 assert(!Cleanup.exprNeedsCleanups() &&
16281 "cleanups within block not correctly bound!");
16282 PopExpressionEvaluationContext();
16284 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
16288 deduceClosureReturnType(*BSI);
16294 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
16302 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
16305 if (isa<FunctionNoProtoType>(FTy)) {
16336 if (getCurFunction()->NeedsScopeChecking() &&
16337 !PP.isCodeCompletionEnabled())
16338 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
16340 BD->
setBody(cast<CompoundStmt>(Body));
16342 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
16343 DiagnoseUnguardedAvailabilityViolations(BD);
16350 computeNRVO(Body, BSI);
16354 checkNonTrivialCUnion(RetTy, BD->
getCaretLocation(), NTCUC_FunctionReturn,
16355 NTCUK_Destruct|NTCUK_Copy);
16367 Expr *CopyExpr =
nullptr;
16376 if (isa<ParmVarDecl>(Var))
16377 FinalizeVarWithDestructor(Var,
Record);
16385 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
16389 ExprResult Result = BuildDeclarationNameExpr(
16395 if (!Result.isInvalid() &&
16396 !Result.get()->getType().isConstQualified()) {
16397 Result = ImpCastExprToType(Result.get(),
16398 Result.get()->getType().withConst(),
16402 if (!Result.isInvalid()) {
16403 Result = PerformCopyInitialization(
16406 Loc, Result.get());
16412 if (!Result.isInvalid() &&
16413 !cast<CXXConstructExpr>(Result.get())->getConstructor()
16415 Result = MaybeCreateExprWithCleanups(Result);
16416 CopyExpr = Result.get();
16423 Captures.push_back(NewCap);
16435 if (Result->getBlockDecl()->hasCaptures()) {
16437 ExprCleanupObjects.push_back(Result->getBlockDecl());
16438 Cleanup.setExprNeedsCleanups(
true);
16442 for (
const auto &CI : Result->getBlockDecl()->captures()) {
16445 setFunctionHasBranchProtectedScope();
16451 if (getCurFunction())
16452 getCurFunction()->addBlock(BD);
16456 {Result}, Result->getType());
16463 GetTypeFromParser(Ty, &TInfo);
16464 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
16470 Expr *OrigExpr = E;
16474 if (getLangOpts().
CUDA && getLangOpts().CUDAIsDevice) {
16475 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
16484 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
16486 targetDiag(E->
getBeginLoc(), diag::err_va_arg_in_device);
16510 ExprResult Result = UsualUnaryConversions(E);
16511 if (Result.isInvalid())
16520 if (Init.isInvalid())
16522 E = Init.getAs<
Expr>();
16536 diag::err_first_argument_to_va_arg_not_of_type_va_list)
16541 diag::err_second_parameter_to_va_arg_incomplete,
16547 diag::err_second_parameter_to_va_arg_abstract,
16554 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
16555 : diag::warn_second_parameter_to_va_arg_not_pod)
16588 UnderlyingType = ET->getDecl()->getIntegerType();
16611 if (!PromoteType.
isNull())
16613 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
16620 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc,
T, IsMS);
16629 Ty = Context.
IntTy;
16635 llvm_unreachable(
"I don't know size of pointer!");
16652 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
16661 S.
Diag(
Loc, diag::err_std_source_location_impl_not_found);
16669 S.
Diag(
Loc, diag::err_std_source_location_impl_malformed);
16673 unsigned Count = 0;
16675 StringRef Name = F->getName();
16677 if (Name ==
"_M_file_name") {
16678 if (F->getType() !=
16682 }
else if (Name ==
"_M_function_name") {
16683 if (F->getType() !=
16687 }
else if (Name ==
"_M_line") {
16688 if (!F->getType()->isIntegerType())
16691 }
else if (Name ==
"_M_column") {
16692 if (!F->getType()->isIntegerType())
16701 S.
Diag(
Loc, diag::err_std_source_location_impl_malformed);
16727 if (!StdSourceLocationImplDecl) {
16728 StdSourceLocationImplDecl =
16730 if (!StdSourceLocationImplDecl)
16738 return BuildSourceLocExpr(
Kind, ResultTy, BuiltinLoc, RPLoc, CurContext);
16745 return new (Context)
16750 const Expr *SrcExpr) {
16759 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
16772 bool *Complained) {
16774 *Complained =
false;
16777 bool CheckInferredResultType =
false;
16779 unsigned DiagKind = 0;
16781 bool MayHaveConvFixit =
false;
16782 bool MayHaveFunctionDiff =
false;
16788 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
16793 DiagKind = diag::err_typecheck_convert_pointer_int;
16796 DiagKind = diag::ext_typecheck_convert_pointer_int;
16799 MayHaveConvFixit =
true;
16803 DiagKind = diag::err_typecheck_convert_int_pointer;
16806 DiagKind = diag::ext_typecheck_convert_int_pointer;
16809 MayHaveConvFixit =
true;
16811 case IncompatibleFunctionPointerStrict:
16813 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
16815 MayHaveConvFixit =
true;
16817 case IncompatibleFunctionPointer:
16819 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
16822 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
16825 MayHaveConvFixit =
true;
16827 case IncompatiblePointer:
16828 if (Action == AA_Passing_CFAudited) {
16829 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
16831 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
16834 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
16838 if (CheckInferredResultType) {
16844 MayHaveConvFixit =
true;
16846 case IncompatiblePointerSign:
16848 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
16851 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
16854 case FunctionVoidPointer:
16856 DiagKind = diag::err_typecheck_convert_pointer_void_func;
16859 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
16862 case IncompatiblePointerDiscardsQualifiers: {
16871 DiagKind = diag::err_typecheck_incompatible_address_space;
16874 DiagKind = diag::err_typecheck_incompatible_ownership;
16878 llvm_unreachable(
"unknown error case for discarding qualifiers!");
16881 case CompatiblePointerDiscardsQualifiers:
16892 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
16895 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
16898 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
16902 case IncompatibleNestedPointerQualifiers:
16905 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
16907 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
16910 case IncompatibleNestedPointerAddressSpaceMismatch:
16911 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
16914 case IntToBlockPointer:
16915 DiagKind = diag::err_int_to_block_pointer;
16918 case IncompatibleBlockPointer:
16919 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
16922 case IncompatibleObjCQualifiedId: {
16926 for (
auto *srcProto : srcOPT->
quals()) {
16932 IFace = IFaceT->getDecl();
16937 for (
auto *dstProto : dstOPT->
quals()) {
16943 IFace = IFaceT->getDecl();
16945 if (getLangOpts().CPlusPlus) {
16946 DiagKind = diag::err_incompatible_qualified_id;
16949 DiagKind = diag::warn_incompatible_qualified_id;
16953 case IncompatibleVectors:
16954 if (getLangOpts().CPlusPlus) {
16955 DiagKind = diag::err_incompatible_vectors;
16958 DiagKind = diag::warn_incompatible_vectors;
16961 case IncompatibleObjCWeakRef:
16962 DiagKind = diag::err_arc_weak_unavailable_assign;
16968 *Complained =
true;
16972 DiagKind = diag::err_typecheck_convert_incompatible;
16974 MayHaveConvFixit =
true;
16976 MayHaveFunctionDiff =
true;
16983 case AA_Initializing:
16985 FirstType = DstType;
16986 SecondType = SrcType;
16991 case AA_Passing_CFAudited:
16992 case AA_Converting:
16996 FirstType = SrcType;
16997 SecondType = DstType;
17003 if (Action == AA_Passing_CFAudited)
17004 ActionForDiag = AA_Passing;
17006 FDiag << FirstType << SecondType << ActionForDiag
17009 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
17010 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
17020 if (!ConvHints.
isNull()) {
17025 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
17027 if (MayHaveFunctionDiff)
17028 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
17031 if ((DiagKind == diag::warn_incompatible_qualified_id ||
17032 DiagKind == diag::err_incompatible_qualified_id) &&
17034 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
17041 if (CheckInferredResultType)
17042 ObjC().EmitRelatedResultTypeNote(SrcExpr);
17044 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
17045 ObjC().EmitRelatedResultTypeNoteForReturn(DstType);
17048 *Complained =
true;
17059 return S.
Diag(
Loc, diag::err_ice_not_integral)
17067 return VerifyIntegerConstantExpression(E, Result, Diagnoser, CanFold);
17078 IDDiagnoser(
unsigned DiagID)
17084 } Diagnoser(DiagID);
17086 return VerifyIntegerConstantExpression(E, Result, Diagnoser, CanFold);
17092 return diagnoseNotICE(S,
Loc);
17119 BaseDiagnoser(BaseDiagnoser) {}
17128 return S.
Diag(
Loc, diag::err_ice_incomplete_type) <<
T;
17133 return S.
Diag(
Loc, diag::err_ice_explicit_conversion) <<
T << ConvTy;
17144 return S.
Diag(
Loc, diag::err_ice_ambiguous_conversion) <<
T;
17155 llvm_unreachable(
"conversion functions are permitted");
17157 } ConvertDiagnoser(Diagnoser);
17159 Converted = PerformContextualImplicitConversion(DiagLoc, E,
17163 E = Converted.
get();
17168 if (isa<RecoveryExpr>(E))
17180 ExprResult RValueExpr = DefaultLvalueConversion(E);
17184 E = RValueExpr.
get();
17191 if (!isa<ConstantExpr>(E))
17199 EvalResult.
Diag = &Notes;
17207 if (!isa<ConstantExpr>(E))
17213 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
17222 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17223 diag::note_invalid_subexpr_in_const_expr) {
17224 DiagLoc = Notes[0].first;
17228 if (!Folded || !CanFold) {
17232 Diag(Note.first, Note.second);
17240 Diag(Note.first, Note.second);
17250 class TransformToPE :
public TreeTransform<TransformToPE> {
17254 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
17257 bool AlwaysRebuild() {
return true; }
17258 bool ReplacingOriginal() {
return true; }
17268 if (isa<FieldDecl>(E->
getDecl()) &&
17269 !SemaRef.isUnevaluatedContext())
17271 diag::err_invalid_non_static_member_use)
17274 return BaseTransform::TransformDeclRefExpr(E);
17282 return BaseTransform::TransformUnaryOperator(E);
17290 return SkipLambdaBody(E, Body);
17296 assert(isUnevaluatedContext() &&
17297 "Should only transform unevaluated expressions");
17298 ExprEvalContexts.back().Context =
17299 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
17300 if (isUnevaluatedContext())
17302 return TransformToPE(*this).TransformExpr(E);
17306 assert(isUnevaluatedContext() &&
17307 "Should only transform unevaluated expressions");
17308 ExprEvalContexts.back().Context = parentEvaluationContext().Context;
17309 if (isUnevaluatedContext())
17311 return TransformToPE(*this).TransformType(TInfo);
17318 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
17319 LambdaContextDecl, ExprContext);
17324 ExprEvalContexts.back().InDiscardedStatement =
17325 parentEvaluationContext().isDiscardedStatementContext();
17331 const auto &Prev = parentEvaluationContext();
17332 ExprEvalContexts.back().InImmediateFunctionContext =
17333 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
17335 ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
17336 Prev.InImmediateEscalatingFunctionContext;
17339 if (!MaybeODRUseExprs.empty())
17340 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
17347 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
17348 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
17355 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
17356 if (E->getOpcode() == UO_Deref)
17357 return CheckPossibleDeref(S, E->getSubExpr());
17358 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
17359 return CheckPossibleDeref(S, E->getBase());
17360 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
17361 return CheckPossibleDeref(S, E->getBase());
17362 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
17366 Inner = Ptr->getPointeeType();
17368 Inner = Arr->getElementType();
17372 if (Inner->hasAttr(attr::NoDeref))
17382 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
17389 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
17408 if (BO->getOpcode() == BO_Assign) {
17409 auto &LHSs = ExprEvalContexts.back().VolatileAssignmentLHSs;
17410 llvm::erase(LHSs, BO->getLHS());
17417 ExprEvalContexts.back().InImmediateEscalatingFunctionContext &&
17418 "Cannot mark an immediate escalating expression outside of an "
17419 "immediate escalating context");
17421 Call && Call->getCallee()) {
17422 if (
auto *DeclRef =
17423 dyn_cast<DeclRefExpr>(Call->getCallee()->IgnoreImplicit()))
17424 DeclRef->setIsImmediateEscalating(
true);
17425 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(E->
IgnoreImplicit())) {
17426 Ctr->setIsImmediateEscalating(
true);
17427 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreImplicit())) {
17428 DeclRef->setIsImmediateEscalating(
true);
17430 assert(
false &&
"expected an immediately escalating expression");
17433 FI->FoundImmediateEscalatingExpression =
true;
17437 if (isUnevaluatedContext() || !E.
isUsable() || !
Decl ||
17438 !
Decl->isImmediateFunction() || isAlwaysConstantEvaluatedContext() ||
17439 isCheckingDefaultArgumentOrInitializer() ||
17440 RebuildingImmediateInvocation || isImmediateFunctionContext())
17448 if (
auto *DeclRef =
17449 dyn_cast<DeclRefExpr>(Call->getCallee()->IgnoreImplicit()))
17450 ExprEvalContexts.back().ReferenceToConsteval.erase(DeclRef);
17458 auto CheckConstantExpressionAndKeepResult = [&]() {
17461 Eval.
Diag = &Notes;
17464 if (Res && Notes.empty()) {
17465 Cached = std::move(Eval.
Val);
17472 ExprEvalContexts.back().InImmediateEscalatingFunctionContext &&
17473 !CheckConstantExpressionAndKeepResult()) {
17474 MarkExpressionAsImmediateEscalating(E.
get());
17478 if (Cleanup.exprNeedsCleanups()) {
17495 Cleanup.cleanupsHaveSideEffects(), {});
17499 getASTContext(), E.
get(),
17508 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
17516 Eval.
Diag = &Notes;
17520 if (!Result || !Notes.empty()) {
17523 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
17526 if (
auto *Call = dyn_cast<CallExpr>(InnerExpr))
17527 FD = cast<FunctionDecl>(Call->getCalleeDecl());
17528 else if (
auto *Call = dyn_cast<CXXConstructExpr>(InnerExpr))
17529 FD = Call->getConstructor();
17530 else if (
auto *
Cast = dyn_cast<CastExpr>(InnerExpr))
17531 FD = dyn_cast_or_null<FunctionDecl>(
Cast->getConversionFunction());
17534 "could not find an immediate function in this expression");
17541 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
17543 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
17547 for (
auto &Note : Notes)
17548 SemaRef.
Diag(Note.first, Note.second);
17559 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
17563 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
17566 4>::reverse_iterator Current)
17567 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
17569 auto It = std::find_if(CurrentII, IISet.rend(),
17571 return Elem.getPointer() == E;
17577 if (It == IISet.rend()) {
17579 CurrentII->setInt(1);
17586 return Base::TransformConstantExpr(E);
17587 RemoveImmediateInvocation(E);
17588 return Base::TransformExpr(E->
getSubExpr());
17594 return Base::TransformCXXOperatorCallExpr(E);
17606 if (
auto *CE = dyn_cast<ConstantExpr>(Init))
17607 if (CE->isImmediateInvocation())
17608 RemoveImmediateInvocation(CE);
17609 return Base::TransformInitializer(Init, NotCopyInit);
17620 bool AlwaysRebuild() {
return false; }
17621 bool ReplacingOriginal() {
return true; }
17622 bool AllowSkippingCXXConstructExpr() {
17623 bool Res = AllowSkippingFirstCXXConstructExpr;
17624 AllowSkippingFirstCXXConstructExpr =
true;
17627 bool AllowSkippingFirstCXXConstructExpr =
true;
17637 if (isa<CXXConstructExpr>(It->getPointer()->IgnoreImplicit()))
17638 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
17640 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
17646 It->getPointer()->setSubExpr(Res.
get());
17681 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
17682 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
17685 return DRSet.size();
17688 Visitor.TraverseStmt(
17698 if (DR->isImmediateEscalating())
17700 auto *FD = cast<FunctionDecl>(DR->getDecl());
17702 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
17704 ND = MD->getParent();
17711 bool ImmediateEscalating =
false;
17712 bool IsPotentiallyEvaluated =
17722 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
17723 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
17727 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
17729 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
17731 if (FD->isImmediateEscalating() && !FD->isConsteval())
17747 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
17755 D = diag::err_lambda_unevaluated_operand;
17761 D = diag::err_lambda_in_constant_expression;
17762 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
17765 D = diag::err_lambda_in_invalid_context;
17767 llvm_unreachable(
"Couldn't infer lambda error message.");
17769 for (
const auto *L : Rec.
Lambdas)
17770 Diag(L->getBeginLoc(), D);
17776 auto &PrevRecord = parentEvaluationContext();
17778 PrevRecord.InLifetimeExtendingContext &&
17780 PrevRecord.ForRangeLifetimeExtendTemps.append(
17784 WarnOnPendingNoDerefs(Rec);
17791 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
17800 ExprCleanupObjects.end());
17802 CleanupVarDeclMarking();
17812 ExprEvalContexts.pop_back();
17815 ExprEvalContexts.back().NumTypos += NumTypos;
17819 ExprCleanupObjects.erase(
17820 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
17821 ExprCleanupObjects.end());
17823 MaybeODRUseExprs.clear();
17827 ExprResult Result = CheckPlaceholderExpr(E);
17828 if (Result.isInvalid())
17833 return TransformToPotentiallyEvaluated(E);
17864 llvm_unreachable(
"Invalid context");
17873 if (!TT.isOSWindows() || !TT.isX86())
17911 : FD(FD), Param(Param) {}
17918 CCName =
"stdcall";
17921 CCName =
"fastcall";
17924 CCName =
"vectorcall";
17927 llvm_unreachable(
"CC does not need mangling");
17930 S.
Diag(
Loc, diag::err_cconv_incomplete_param_type)
17936 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
17942 enum class OdrUseContext {
17958 OdrUseContext Result;
17973 Result = OdrUseContext::FormallyOdrUsed;
17979 Result = OdrUseContext::FormallyOdrUsed;
17984 return OdrUseContext::Dependent;
17990 if (!
Func->isConstexpr())
17993 if (
Func->isImplicitlyInstantiable() || !
Func->isUserProvided())
17995 auto *CCD = dyn_cast<CXXConstructorDecl>(
Func);
17996 return CCD && CCD->getInheritedConstructor();
18002 bool MightBeOdrUse) {
18003 assert(
Func &&
"No function?");
18005 Func->setReferenced();
18009 bool IsRecursiveCall = CurContext ==
Func;
18018 OdrUseContext OdrUse =
18021 OdrUse = OdrUseContext::FormallyOdrUsed;
18025 if (
Func->isTrivial() && !
Func->hasAttr<DLLExportAttr>() &&
18027 if (
auto *Constructor = dyn_cast<CXXConstructorDecl>(
Func))
18028 if (Constructor->isDefaultConstructor())
18029 OdrUse = OdrUseContext::FormallyOdrUsed;
18030 if (isa<CXXDestructorDecl>(
Func))
18031 OdrUse = OdrUseContext::FormallyOdrUsed;
18038 bool NeededForConstantEvaluation =
18063 bool NeedDefinition =
18064 !IsRecursiveCall &&
18066 (NeededForConstantEvaluation && !
Func->isPureVirtual()));
18073 if (NeedDefinition &&
18075 Func->getMemberSpecializationInfo()))
18076 checkSpecializationReachability(
Loc,
Func);
18078 if (getLangOpts().
CUDA)
18082 if (NeedDefinition && !
Func->getBody()) {
18085 dyn_cast<CXXConstructorDecl>(
Func)) {
18086 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
18087 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
18088 if (Constructor->isDefaultConstructor()) {
18089 if (Constructor->isTrivial() &&
18090 !Constructor->hasAttr<DLLExportAttr>())
18092 DefineImplicitDefaultConstructor(
Loc, Constructor);
18093 }
else if (Constructor->isCopyConstructor()) {
18094 DefineImplicitCopyConstructor(
Loc, Constructor);
18095 }
else if (Constructor->isMoveConstructor()) {
18096 DefineImplicitMoveConstructor(
Loc, Constructor);
18098 }
else if (Constructor->getInheritedConstructor()) {
18099 DefineInheritingConstructor(
Loc, Constructor);
18102 dyn_cast<CXXDestructorDecl>(
Func)) {
18103 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
18104 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
18105 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
18107 DefineImplicitDestructor(
Loc, Destructor);
18109 if (Destructor->isVirtual() && getLangOpts().AppleKext)
18110 MarkVTableUsed(
Loc, Destructor->getParent());
18112 if (MethodDecl->isOverloadedOperator() &&
18113 MethodDecl->getOverloadedOperator() == OO_Equal) {
18114 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
18115 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
18116 if (MethodDecl->isCopyAssignmentOperator())
18117 DefineImplicitCopyAssignment(
Loc, MethodDecl);
18118 else if (MethodDecl->isMoveAssignmentOperator())
18119 DefineImplicitMoveAssignment(
Loc, MethodDecl);
18121 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
18122 MethodDecl->getParent()->isLambda()) {
18124 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
18126 DefineImplicitLambdaToBlockPointerConversion(
Loc, Conversion);
18128 DefineImplicitLambdaToFunctionPointerConversion(
Loc, Conversion);
18129 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
18130 MarkVTableUsed(
Loc, MethodDecl->getParent());
18133 if (
Func->isDefaulted() && !
Func->isDeleted()) {
18136 DefineDefaultedComparison(
Loc,
Func, DCK);
18141 if (
Func->isImplicitlyInstantiable()) {
18143 Func->getTemplateSpecializationKindForInstantiation();
18145 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
18146 if (FirstInstantiation) {
18147 PointOfInstantiation =
Loc;
18148 if (
auto *MSI =
Func->getMemberSpecializationInfo())
18149 MSI->setPointOfInstantiation(
Loc);
18152 Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
18157 PointOfInstantiation =
Loc;
18161 Func->isConstexpr()) {
18162 if (isa<CXXRecordDecl>(
Func->getDeclContext()) &&
18163 cast<CXXRecordDecl>(
Func->getDeclContext())->isLocalClass() &&
18164 CodeSynthesisContexts.size())
18165 PendingLocalImplicitInstantiations.push_back(
18166 std::make_pair(
Func, PointOfInstantiation));
18167 else if (
Func->isConstexpr())
18171 InstantiateFunctionDefinition(PointOfInstantiation,
Func);
18173 Func->setInstantiationIsPending(
true);
18174 PendingInstantiations.push_back(
18175 std::make_pair(
Func, PointOfInstantiation));
18177 Consumer.HandleCXXImplicitFunctionInstantiation(
Func);
18182 for (
auto *i :
Func->redecls()) {
18183 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
18184 MarkFunctionReferenced(
Loc, i, MightBeOdrUse);
18196 Constructor->isImmediateFunction()
18197 ? ExpressionEvaluationContext::ImmediateFunctionContext
18198 : ExpressionEvaluationContext::PotentiallyEvaluated,
18201 if (Init->isInClassMemberInitializer())
18203 MarkDeclarationsReferencedInExpr(Init->getInit());
18219 ResolveExceptionSpec(
Loc, FPT);
18224 if (LangOpts.OffloadImplicitHostDeviceTemplates && LangOpts.CUDAIsDevice &&
18225 !getASTContext().CUDAImplicitHostDeviceFunUsedByDevice.count(
Func))
18226 CUDA().RecordImplicitHostDeviceFuncUsedByDevice(
Func);
18231 if (!
Func->isDefined()) {
18232 if (mightHaveNonExternalLinkage(
Func))
18233 UndefinedButUsed.insert(std::make_pair(
Func->getCanonicalDecl(),
Loc));
18234 else if (
Func->getMostRecentDecl()->isInlined() &&
18235 !LangOpts.GNUInline &&
18236 !
Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
18237 UndefinedButUsed.insert(std::make_pair(
Func->getCanonicalDecl(),
Loc));
18238 else if (isExternalWithNoLinkageType(
Func))
18239 UndefinedButUsed.insert(std::make_pair(
Func->getCanonicalDecl(),
Loc));
18255 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(
Func)) {
18257 if (
Parent->getNumVBases() > 0 && !Dtor->getBody())
18258 CheckCompleteDestructorVariant(
Loc, Dtor);
18262 Func->markUsed(Context);
18275 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
18278 VarDecl *Var =
V->getPotentiallyDecomposedVarDecl();
18279 assert(Var &&
"expected a capturable variable");
18289 QualType CaptureType, DeclRefType;
18295 DeclRefType, FunctionScopeIndexToStopAt);
18298 auto *FD = dyn_cast_or_null<FunctionDecl>(SemaRef.
CurContext);
18311 << llvm::to_underlying(UserTarget);
18314 ? diag::note_cuda_const_var_unpromoted
18315 : diag::note_cuda_host_var);
18318 !Var->
hasAttr<CUDASharedAttr>() &&
18333 else if (SemaRef.
LangOpts.GPURelocatableDeviceCode &&
18334 (!FD || (!FD->getDescribedFunctionTemplate() &&
18346 unsigned CapturingScopeIndex) {
18357 if (isa<ParmVarDecl>(
var) &&
18358 isa<TranslationUnitDecl>(VarDC))
18371 unsigned ValueKind = isa<BindingDecl>(
var) ? 1 : 0;
18373 if (isa<CXXMethodDecl>(VarDC) &&
18374 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
18376 }
else if (isa<FunctionDecl>(VarDC)) {
18378 }
else if (isa<BlockDecl>(VarDC)) {
18382 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
18384 S.
Diag(
var->getLocation(), diag::note_entity_declared_at)
18393 bool &SubCapturesAreNested,
18399 SubCapturesAreNested =
true;
18412 !(isa<LambdaScopeInfo>(CSI) &&
18413 !cast<LambdaScopeInfo>(CSI)->lambdaCaptureShouldBeConst()) &&
18414 !(isa<CapturedRegionScopeInfo>(CSI) &&
18415 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
18427 const bool Diagnose,
18447 assert((isa<VarDecl, BindingDecl>(Var)) &&
18448 "Only variables and structured bindings can be captured");
18450 bool IsBlock = isa<BlockScopeInfo>(CSI);
18451 bool IsLambda = isa<LambdaScopeInfo>(CSI);
18459 S.
Diag(
Loc, diag::err_lambda_capture_anonymous_var);
18468 S.
Diag(
Loc, diag::err_ref_vm_type);
18476 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
18479 S.
Diag(
Loc, diag::err_ref_flexarray_type);
18481 S.
Diag(
Loc, diag::err_lambda_capture_flexarray_type) << Var;
18487 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
18490 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
18492 S.
Diag(
Loc, diag::err_capture_block_variable) << Var << !IsLambda;
18501 S.
Diag(
Loc, diag::err_opencl_block_ref_block);
18505 if (isa<BindingDecl>(Var)) {
18510 }
else if (Diagnose && S.
getLangOpts().CPlusPlus) {
18512 ? diag::warn_cxx17_compat_capture_binding
18513 : diag::ext_capture_binding)
18526 const bool Nested,
Sema &S,
bool Invalid) {
18527 bool ByRef =
false;
18533 if (BuildAndDiagnose) {
18534 S.
Diag(
Loc, diag::err_ref_array_type);
18545 if (BuildAndDiagnose) {
18546 S.
Diag(
Loc, diag::err_arc_autoreleasing_capture)
18562 if (BuildAndDiagnose) {
18564 S.
Diag(
Loc, diag::warn_block_capture_autoreleasing);
18565 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
18570 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
18579 DeclRefType = CaptureType;
18583 if (BuildAndDiagnose)
18585 CaptureType, Invalid);
18593 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
18595 bool IsTopScope,
Sema &S,
bool Invalid) {
18620 CaptureType = DeclRefType;
18623 if (BuildAndDiagnose)
18624 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
18634 const bool RefersToCapturedVariable,
18637 Sema &S,
bool Invalid) {
18639 bool ByRef =
false;
18648 S.
Diag(
Loc, diag::err_wasm_ca_reference) << 0;
18679 if (!RefType->getPointeeType()->isFunctionType())
18686 if (BuildAndDiagnose) {
18687 S.
Diag(
Loc, diag::err_arc_autoreleasing_capture) << 1;
18697 if (!Invalid && BuildAndDiagnose) {
18701 diag::err_capture_of_incomplete_or_sizeless_type,
18705 diag::err_capture_of_abstract_type))
18726 if (BuildAndDiagnose)
18727 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
18728 Loc, EllipsisLoc, CaptureType, Invalid);
18739 if (
T.isTriviallyCopyableType(Context))
18743 if (!(RD = RD->getDefinition()))
18745 if (RD->hasSimpleCopyConstructor())
18747 if (RD->hasUserDeclaredCopyConstructor())
18749 if (Ctor->isCopyConstructor())
18750 return !Ctor->isDeleted();
18770 if (ShouldOfferCopyFix) {
18774 FixBuffer.assign({Separator, Var->
getName()});
18775 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
18780 FixBuffer.assign({Separator,
"&", Var->
getName()});
18781 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
18793 return !C.isThisCapture() && !C.isInitCapture();
18802 if (ShouldOfferCopyFix) {
18803 bool CanDefaultCopyCapture =
true;
18812 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &C) {
18813 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
18815 FixBuffer.assign({
"=", Separator});
18816 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
18825 return !C.isInitCapture() && C.isReferenceCapture() &&
18826 !C.isThisCapture();
18828 FixBuffer.assign({
"&", Separator});
18829 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
18838 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
18848 if (CapturingFunctionScopes == 0 && (!BuildAndDiagnose || VarDC == DC))
18851 const auto *VD = dyn_cast<VarDecl>(Var);
18853 if (VD->isInitCapture())
18858 assert(VD &&
"Cannot capture a null variable");
18860 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
18861 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
18864 if (FunctionScopeIndexToStopAt) {
18865 unsigned FSIndex = FunctionScopes.size() - 1;
18866 while (FSIndex != MaxFunctionScopesIndex) {
18874 bool IsGlobal = !VD->hasLocalStorage();
18875 if (IsGlobal && !(LangOpts.OpenMP &&
18876 OpenMP().isOpenMPCapturedDecl(Var,
true,
18877 MaxFunctionScopesIndex)))
18880 if (isa<VarDecl>(Var))
18891 CaptureType = Var->
getType();
18893 bool Nested =
false;
18894 bool Explicit = (
Kind != TryCapture_Implicit);
18895 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
18899 if (!FunctionScopes.empty())
18900 LSI = dyn_cast_or_null<LambdaScopeInfo>(
18901 FunctionScopes[FunctionScopesIndex]);
18903 bool IsInScopeDeclarationContext =
18914 if (IsInScopeDeclarationContext &&
18915 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
18921 !IsInScopeDeclarationContext
18924 BuildAndDiagnose, *
this);
18930 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
18949 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
18950 Parm && Parm->getDeclContext() == DC)
18958 if (BuildAndDiagnose) {
18961 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
18976 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
18977 QTy = PVD->getOriginalType();
18981 if (getLangOpts().OpenMP) {
18982 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
18988 if (isa<BindingDecl>(Var)) {
18989 if (BuildAndDiagnose) {
18990 Diag(ExprLoc, diag::err_capture_binding_openmp) << Var;
18996 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
19001 if (IsOpenMPPrivateDecl != OMPC_unknown &&
19004 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
19005 QTy = PVD->getOriginalType();
19007 E = OpenMP().getNumberOfConstructScopes(RSI->OpenMPLevel);
19009 auto *OuterRSI = cast<CapturedRegionScopeInfo>(
19010 FunctionScopes[FunctionScopesIndex - I]);
19011 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
19012 "Wrong number of captured regions associated with the "
19013 "OpenMP construct.");
19018 IsOpenMPPrivateDecl != OMPC_private &&
19019 OpenMP().isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel,
19020 RSI->OpenMPCaptureLevel);
19023 IsGlobal && OpenMP().isOpenMPGlobalCapturedDecl(
19024 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
19030 OpenMP().adjustOpenMPTargetScopeIndex(FunctionScopesIndex,
19033 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
19034 (IsGlobal && !IsGlobalCap)) {
19035 Nested = !IsTargetCap;
19050 if (BuildAndDiagnose) {
19051 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
19053 auto *LSI = cast<LambdaScopeInfo>(CSI);
19073 FunctionScopesIndex--;
19074 if (IsInScopeDeclarationContext)
19076 }
while (!VarDC->
Equals(DC));
19083 bool Invalid =
false;
19084 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
19097 if (Invalid && !BuildAndDiagnose)
19101 Invalid = !
captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
19102 DeclRefType, Nested, *
this, Invalid);
19106 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
19107 Kind, I == N - 1, *
this, Invalid);
19113 DeclRefType, Nested,
Kind, EllipsisLoc,
19114 I == N - 1, *
this, Invalid);
19118 if (Invalid && !BuildAndDiagnose)
19128 return tryCaptureVariable(Var,
Loc,
Kind, EllipsisLoc,
19130 DeclRefType,
nullptr);
19137 false, CaptureType,
19138 DeclRefType,
nullptr);
19147 false, CaptureType,
19148 DeclRefType,
nullptr))
19151 return DeclRefType;
19159 class CopiedTemplateArgs {
19163 template<
typename RefExpr>
19164 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
19166 E->copyTemplateArgumentsInto(TemplateArgStorage);
19169 #ifdef __has_cpp_attribute
19170 #
if __has_cpp_attribute(clang::lifetimebound)
19171 [[clang::lifetimebound]]
19175 return HasArgs ? &TemplateArgStorage :
nullptr;
19201 auto Rebuild = [&](
Expr *Sub) {
19206 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
19209 auto *VD = dyn_cast<VarDecl>(D);
19232 llvm_unreachable(
"unexpected non-odr-use-reason");
19236 if (VD->getType()->isReferenceType())
19238 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
19239 if (RD->hasMutableFields())
19241 if (!VD->isUsableInConstantExpressions(S.
Context))
19246 if (VD->getType()->isReferenceType())
19254 auto MarkNotOdrUsed = [&] {
19257 LSI->markVariableExprAsNonODRUsed(E);
19264 case Expr::DeclRefExprClass: {
19265 auto *DRE = cast<DeclRefExpr>(E);
19266 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
19272 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
19273 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
19274 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
19275 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
19278 case Expr::FunctionParmPackExprClass: {
19279 auto *FPPE = cast<FunctionParmPackExpr>(E);
19283 if (IsPotentialResultOdrUsed(D))
19294 case Expr::ArraySubscriptExprClass: {
19295 auto *ASE = cast<ArraySubscriptExpr>(E);
19300 if (!
Base.isUsable())
19302 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
19303 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
19306 ASE->getRBracketLoc());
19309 case Expr::MemberExprClass: {
19310 auto *ME = cast<MemberExpr>(E);
19313 if (isa<FieldDecl>(ME->getMemberDecl())) {
19315 if (!
Base.isUsable())
19318 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
19319 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
19320 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
19321 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
19322 ME->getObjectKind(), ME->isNonOdrUse());
19325 if (ME->getMemberDecl()->isCXXInstanceMember())
19330 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
19336 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
19337 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
19338 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
19339 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
19342 case Expr::BinaryOperatorClass: {
19343 auto *BO = cast<BinaryOperator>(E);
19344 Expr *LHS = BO->getLHS();
19345 Expr *RHS = BO->getRHS();
19347 if (BO->getOpcode() == BO_PtrMemD) {
19349 if (!Sub.isUsable())
19351 BO->setLHS(Sub.get());
19353 }
else if (BO->getOpcode() == BO_Comma) {
19355 if (!Sub.isUsable())
19357 BO->setRHS(Sub.get());
19365 case Expr::ParenExprClass: {
19366 auto *PE = cast<ParenExpr>(E);
19368 if (!Sub.isUsable())
19370 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
19375 case Expr::ConditionalOperatorClass: {
19376 auto *CO = cast<ConditionalOperator>(E);
19386 LHS = CO->getLHS();
19388 RHS = CO->getRHS();
19390 CO->getCond(), LHS.
get(), RHS.
get());
19395 case Expr::UnaryOperatorClass: {
19396 auto *UO = cast<UnaryOperator>(E);
19397 if (UO->getOpcode() != UO_Extension)
19400 if (!Sub.isUsable())
19402 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
19409 case Expr::GenericSelectionExprClass: {
19410 auto *GSE = cast<GenericSelectionExpr>(E);
19413 bool AnyChanged =
false;
19414 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
19415 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
19419 AssocExprs.push_back(AssocExpr.
get());
19422 AssocExprs.push_back(OrigAssocExpr);
19426 void *ExOrTy =
nullptr;
19427 bool IsExpr = GSE->isExprPredicate();
19429 ExOrTy = GSE->getControllingExpr();
19431 ExOrTy = GSE->getControllingType();
19433 GSE->getGenericLoc(), GSE->getDefaultLoc(),
19434 GSE->getRParenLoc(), IsExpr, ExOrTy,
19435 GSE->getAssocTypeSourceInfos(), AssocExprs)
19443 case Expr::ChooseExprClass: {
19444 auto *CE = cast<ChooseExpr>(E);
19454 if (!LHS.
get() && !RHS.
get())
19457 LHS = CE->getLHS();
19459 RHS = CE->getRHS();
19462 RHS.
get(), CE->getRParenLoc());
19466 case Expr::ConstantExprClass: {
19467 auto *CE = cast<ConstantExpr>(E);
19469 if (!Sub.isUsable())
19476 case Expr::ImplicitCastExprClass: {
19477 auto *ICE = cast<ImplicitCastExpr>(E);
19481 switch (ICE->getCastKind()) {
19483 case CK_DerivedToBase:
19484 case CK_UncheckedDerivedToBase: {
19485 ExprResult Sub = Rebuild(ICE->getSubExpr());
19486 if (!Sub.isUsable())
19490 ICE->getValueKind(), &Path);
19515 NTCUK_Destruct|NTCUK_Copy);
19525 if (Result.isInvalid())
19527 return Result.get() ? Result : E;
19531 Res = CorrectDelayedTyposInExpr(Res);
19540 return CheckLValueToRValueConversionOperand(Res.
get());
19547 std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
19549 for (
Expr *E : LocalMaybeODRUseExprs) {
19550 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
19552 DRE->getLocation(), *
this);
19553 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
19556 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
19560 llvm_unreachable(
"Unexpected expression");
19564 assert(MaybeODRUseExprs.empty() &&
19565 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
19574 const bool RefersToEnclosingScope =
19577 if (RefersToEnclosingScope) {
19592 assert(E &&
"Capture variable should be used in an expression.");
19602 llvm::DenseMap<const VarDecl *, int> &RefsMinusAssignments) {
19603 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
19604 isa<FunctionParmPackExpr>(E)) &&
19605 "Invalid Expr argument to DoMarkVarDeclReferenced");
19616 bool UsableInConstantExpr =
19620 RefsMinusAssignments.insert({Var, 0}).first->getSecond()++;
19628 bool NeededForConstantEvaluation =
19631 bool NeedDefinition =
19634 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
19635 "Can't instantiate a partial template specialization.");
19641 !isa<VarTemplateSpecializationDecl>(Var))
19652 bool TryInstantiating =
19656 if (TryInstantiating) {
19659 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
19660 if (FirstInstantiation) {
19661 PointOfInstantiation =
Loc;
19663 MSI->setPointOfInstantiation(PointOfInstantiation);
19669 if (UsableInConstantExpr) {
19678 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
19679 DRE->setDecl(DRE->getDecl());
19680 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(E))
19681 ME->setMemberDecl(ME->getMemberDecl());
19682 }
else if (FirstInstantiation) {
19684 .push_back(std::make_pair(Var, PointOfInstantiation));
19686 bool Inserted =
false;
19688 auto Iter = llvm::find_if(
19690 return P.first == Var;
19692 if (
Iter != I.end()) {
19705 if (isa<VarTemplateSpecializationDecl>(Var) && !Inserted)
19707 .push_back(std::make_pair(Var, PointOfInstantiation));
19731 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
19732 if (DRE->isNonOdrUse())
19734 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
19735 if (ME->isNonOdrUse())
19742 assert((!E || isa<FunctionParmPackExpr>(E) ||
19744 "missing non-odr-use marking for unevaluated decl ref");
19747 case OdrUseContext::FormallyOdrUsed:
19761 case OdrUseContext::Dependent:
19780 QualType CaptureType, DeclRefType;
19786 }
else if (OdrUse == OdrUseContext::Dependent) {
19805 auto *
ID = dyn_cast<DeclRefExpr>(E);
19806 if (!
ID ||
ID->isTypeDependent() || !
ID->refersToEnclosingVariableOrCapture())
19813 auto IsDependent = [&]() {
19815 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
19819 if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.
CurContext) &&
19820 LSI->AfterParameterList)
19823 const auto *MD = LSI->CallOperator;
19824 if (MD->getType().isNull())
19828 if (!Ty || !MD->isExplicitObjectMemberFunction() ||
19832 if (
auto *C = LSI->CaptureMap.count(D) ? &LSI->getCapture(D) :
nullptr) {
19833 if (C->isCopyCapture())
19844 ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
19850 bool MightBeOdrUse,
19851 llvm::DenseMap<const VarDecl *, int> &RefsMinusAssignments) {
19855 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
19874 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
19881 bool IsVirtualCall = MD->
isVirtual() &&
19883 if (!IsVirtualCall)
19902 bool OdrUse =
true;
19904 if (Method->isVirtual() &&
19905 !Method->getDevirtualizedMethod(
Base, getLangOpts().AppleKext))
19908 if (
auto *FD = dyn_cast<FunctionDecl>(E->
getDecl())) {
19909 if (!isUnevaluatedContext() && !isConstantEvaluatedContext() &&
19910 !isImmediateFunctionContext() &&
19911 !isCheckingDefaultArgumentOrInitializer() &&
19912 FD->isImmediateFunction() && !RebuildingImmediateInvocation &&
19913 !FD->isDependentContext())
19914 ExprEvalContexts.back().ReferenceToConsteval.insert(E);
19917 RefsMinusAssignments);
19928 bool MightBeOdrUse =
true;
19931 if (Method->isPureVirtual())
19932 MightBeOdrUse =
false;
19937 RefsMinusAssignments);
19944 RefsMinusAssignments);
19952 bool MightBeOdrUse) {
19953 if (MightBeOdrUse) {
19954 if (
auto *VD = dyn_cast<VarDecl>(D)) {
19955 MarkVariableReferenced(
Loc, VD);
19959 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
19960 MarkFunctionReferenced(
Loc, FD, MightBeOdrUse);
19987 bool MarkReferencedDecls::TraverseTemplateArgument(
20001 return Inherited::TraverseTemplateArgument(Arg);
20005 MarkReferencedDecls Marker(*
this,
Loc);
20006 Marker.TraverseType(
T);
20012 class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
20015 bool SkipLocalVariables;
20018 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
20020 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
20026 void Visit(
Expr *E) {
20027 if (llvm::is_contained(StopAt, E))
20029 Inherited::Visit(E);
20039 if (SkipLocalVariables) {
20041 if (VD->hasLocalStorage())
20065 bool SkipLocalVariables,
20067 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(E);
20077 if (!Stmts.empty() && getCurFunctionOrMethodDecl()) {
20078 if (!FunctionScopes.empty())
20079 FunctionScopes.back()->PossiblyUnreachableDiags.push_back(
20089 if (
auto *VD = dyn_cast_or_null<VarDecl>(
20090 ExprEvalContexts.back().ManglingContextDecl)) {
20091 if (VD->isConstexpr() ||
20092 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
20121 if (ExprEvalContexts.back().isDiscardedStatementContext())
20124 switch (ExprEvalContexts.back().Context) {
20125 case ExpressionEvaluationContext::Unevaluated:
20126 case ExpressionEvaluationContext::UnevaluatedList:
20127 case ExpressionEvaluationContext::UnevaluatedAbstract:
20128 case ExpressionEvaluationContext::DiscardedStatement:
20132 case ExpressionEvaluationContext::ConstantEvaluated:
20133 case ExpressionEvaluationContext::ImmediateFunctionContext:
20137 case ExpressionEvaluationContext::PotentiallyEvaluated:
20138 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
20139 return DiagIfReachable(
Loc, Stmts, PD);
20147 return DiagRuntimeBehavior(
20158 if (ExprEvalContexts.back().ExprContext ==
20159 ExpressionEvaluationContextRecord::EK_Decltype) {
20160 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
20164 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
20170 : FD(FD), CE(CE) { }
20174 S.
Diag(
Loc, diag::err_call_incomplete_return)
20179 S.
Diag(
Loc, diag::err_call_function_incomplete_return)
20184 } Diagnoser(FD, CE);
20186 if (RequireCompleteType(
Loc, ReturnType, Diagnoser))
20197 unsigned diagnostic = diag::warn_condition_is_assignment;
20198 bool IsOrAssign =
false;
20201 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
20204 IsOrAssign = Op->getOpcode() == BO_OrAssign;
20212 if (ObjC().isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
20213 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20217 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20220 Loc = Op->getOperatorLoc();
20222 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
20225 IsOrAssign = Op->getOperator() == OO_PipeEqual;
20226 Loc = Op->getOperatorLoc();
20228 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
20238 Diag(
Loc, diag::note_condition_assign_silence)
20243 Diag(
Loc, diag::note_condition_or_assign_to_comparison)
20246 Diag(
Loc, diag::note_condition_assign_to_comparison)
20264 if (opE->getOpcode() == BO_EQ &&
20265 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
20271 Diag(
Loc, diag::note_equality_comparison_silence)
20274 Diag(
Loc, diag::note_equality_comparison_to_assign)
20280 bool IsConstexpr) {
20281 DiagnoseAssignmentAsCondition(E);
20282 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
20283 DiagnoseEqualityWithExtraParens(parenE);
20285 ExprResult result = CheckPlaceholderExpr(E);
20291 return CheckCXXBooleanCondition(E, IsConstexpr);
20293 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
20300 Diag(
Loc, diag::err_typecheck_statement_requires_scalar)
20321 Cond = CheckBooleanCondition(
Loc, SubExpr);
20324 case ConditionKind::ConstexprIf:
20325 Cond = CheckBooleanCondition(
Loc, SubExpr,
true);
20328 case ConditionKind::Switch:
20329 Cond = CheckSwitchCondition(
Loc, SubExpr);
20334 {SubExpr}, PreferredConditionType(CK));
20336 return ConditionError();
20341 return ConditionError();
20344 CK == ConditionKind::ConstexprIf);
20350 struct RebuildUnknownAnyFunction
20351 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
20355 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
20358 llvm_unreachable(
"unexpected statement!");
20369 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
20370 ExprResult SubResult = Visit(E->getSubExpr());
20373 Expr *SubExpr = SubResult.
get();
20374 E->setSubExpr(SubExpr);
20382 return rebuildSugarExpr(E);
20386 return rebuildSugarExpr(E);
20393 Expr *SubExpr = SubResult.
get();
20402 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
20408 !(isa<CXXMethodDecl>(VD) &&
20409 cast<CXXMethodDecl>(VD)->isInstance()))
20420 return resolveDecl(E, E->
getDecl());
20428 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
20429 if (Result.isInvalid())
return ExprError();
20438 struct RebuildUnknownAnyExpr
20439 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
20450 llvm_unreachable(
"unexpected statement!");
20464 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
20465 ExprResult SubResult = Visit(E->getSubExpr());
20467 Expr *SubExpr = SubResult.
get();
20468 E->setSubExpr(SubExpr);
20476 return rebuildSugarExpr(E);
20480 return rebuildSugarExpr(E);
20518 return resolveDecl(E, E->
getDecl());
20529 FK_FunctionPointer,
20536 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
20537 Kind = FK_MemberFunction;
20541 Kind = FK_FunctionPointer;
20544 Kind = FK_BlockPointer;
20550 unsigned diagID = diag::err_func_returning_array_function;
20551 if (
Kind == FK_BlockPointer)
20552 diagID = diag::err_block_returning_array_function;
20588 if (ParamTypes.empty() && Proto->
isVariadic()) {
20590 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
20593 ParamTypes = ArgTypes;
20604 case FK_MemberFunction:
20608 case FK_FunctionPointer:
20612 case FK_BlockPointer:
20618 ExprResult CalleeResult = Visit(CalleeExpr);
20629 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
20637 Method->setReturnType(DestType);
20649 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
20659 if (!Result.isUsable())
return ExprError();
20663 }
else if (E->
getCastKind() == CK_LValueToRValue) {
20667 assert(isa<BlockPointerType>(E->
getType()));
20675 if (!Result.isUsable())
return ExprError();
20680 llvm_unreachable(
"Unhandled cast type!");
20695 if (Result.isInvalid())
return ExprError();
20713 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
20717 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
20719 false , FD->hasPrototype(),
20722 if (FD->getQualifier())
20726 for (
const auto &AI : FT->param_types()) {
20730 Params.push_back(Param);
20732 NewFD->setParams(Params);
20739 if (MD->isInstance()) {
20749 }
else if (isa<VarDecl>(VD)) {
20753 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
20781 diag::err_typecheck_cast_to_incomplete))
20796 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
20812 assert(!
arg->hasPlaceholderType());
20819 return PerformCopyInitialization(entity, callLoc,
arg);
20824 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
20827 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
20828 E = call->getCallee();
20829 diagID = diag::err_uncasted_call_of_unknown_any;
20837 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
20838 loc = ref->getLocation();
20839 d = ref->getDecl();
20840 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
20841 loc = mem->getMemberLoc();
20842 d = mem->getMemberDecl();
20844 diagID = diag::err_uncasted_call_of_unknown_any;
20845 loc = msg->getSelectorStartLoc();
20846 d = msg->getMethodDecl();
20848 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
20849 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
20872 ExprResult Result = CorrectDelayedTyposInExpr(E);
20873 if (!Result.isUsable())
return ExprError();
20878 if (!placeholderType)
return E;
20880 switch (placeholderType->
getKind()) {
20881 case BuiltinType::UnresolvedTemplate: {
20882 auto *ULE = cast<UnresolvedLookupExpr>(E);
20887 const bool IsTypeAliasTemplateDecl = isa<TypeAliasTemplateDecl>(Temp);
20890 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
20892 <<
Loc.getSourceRange() << IsTypeAliasTemplateDecl;
20894 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
20896 << IsTypeAliasTemplateDecl;
20898 << IsTypeAliasTemplateDecl;
20904 case BuiltinType::Overload: {
20908 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
20914 if (resolveAndFixAddressOfSingleOverloadCandidate(Result))
20918 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
20924 case BuiltinType::BoundMember: {
20929 if (isa<CXXPseudoDestructorExpr>(BME)) {
20930 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
20931 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
20932 if (ME->getMemberNameInfo().getName().getNameKind() ==
20934 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
20936 tryToRecoverWithCall(result, PD,
20942 case BuiltinType::ARCUnbridgedCast: {
20943 Expr *realCast = ObjC().stripARCUnbridgedCast(E);
20944 ObjC().diagnoseARCUnbridgedCast(realCast);
20949 case BuiltinType::UnknownAny:
20953 case BuiltinType::PseudoObject:
20954 return PseudoObject().checkRValue(E);
20956 case BuiltinType::BuiltinFn: {
20960 auto *FD = cast<FunctionDecl>(DRE->
getDecl());
20961 unsigned BuiltinID = FD->getBuiltinID();
20962 if (BuiltinID == Builtin::BI__noop) {
20964 CK_BuiltinFnToFnPtr)
20977 ? diag::err_use_of_unaddressable_function
20978 : diag::warn_cxx20_compat_use_of_unaddressable_function);
20979 if (FD->isImplicitlyInstantiable()) {
20984 InstantiateFunctionDefinition(E->
getBeginLoc(), FD,
20994 return BuildDeclRefExpr(
21006 case BuiltinType::IncompleteMatrixIdx:
21010 diag::err_matrix_incomplete_index);
21014 case BuiltinType::ArraySection:
21016 << cast<ArraySectionExpr>(E)->isOMPArraySection();
21020 case BuiltinType::OMPArrayShaping:
21023 case BuiltinType::OMPIterator:
21027 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
21028 case BuiltinType::Id:
21029 #include "clang/Basic/OpenCLImageTypes.def"
21030 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
21031 case BuiltinType::Sampled##Id:
21032 #define IMAGE_WRITE_TYPE(Type, Id, Ext)
21033 #define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
21034 #include "clang/Basic/OpenCLImageTypes.def"
21035 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
21036 case BuiltinType::Id:
21037 #include "clang/Basic/OpenCLExtensionTypes.def"
21038 #define SVE_TYPE(Name, Id, SingletonId) \
21039 case BuiltinType::Id:
21040 #include "clang/Basic/AArch64SVEACLETypes.def"
21041 #define PPC_VECTOR_TYPE(Name, Id, Size) \
21042 case BuiltinType::Id:
21043 #include "clang/Basic/PPCTypes.def"
21044 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21045 #include "clang/Basic/RISCVVTypes.def"
21046 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21047 #include "clang/Basic/WebAssemblyReferenceTypes.def"
21048 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
21049 #define PLACEHOLDER_TYPE(Id, SingletonId)
21050 #include "clang/AST/BuiltinTypes.def"
21054 llvm_unreachable(
"invalid placeholder type!");
21070 if (isSFINAEContext())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static bool isObjCPointer(const MemRegion *R)
Defines enum values for all the target-independent builtin functions.
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
This file declares semantic analysis for CUDA constructs.
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
static void HandleImmediateInvocations(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec)
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int, QualType FloatTy)
Test if a (constant) integer Int can be casted to floating point type FloatTy without losing precisio...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema::TryCaptureKind Kind, bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the captured region.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing?
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, const Expr *LHSExpr, const Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D, bool AcceptInvalid)
Diagnoses obvious problems with the use of the given declaration as an expression.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator",...
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
static CXXRecordDecl * LookupStdSourceLocationImpl(Sema &S, SourceLocation Loc)
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
In Microsoft mode, if we are inside a template class whose parent class has dependent base classes,...
static bool isCapturingReferenceToHostVarInCUDADeviceLambda(const Sema &S, VarDecl *VD)
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy, unsigned &DiagID)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(Sema &SemaRef, ValueDecl *D, Expr *E)
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool isVariableCapturable(CapturingScopeInfo *CSI, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
static NamedDecl * getDeclFromExpr(Expr *E)
static bool IgnoreCommaOperand(const Expr *E, const ASTContext &Context)
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc, bool IsAfterAmp=false)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static bool ExprLooksBoolean(const Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef)
Are we in a context that is potentially constant evaluated per C++20 [expr.const]p12?
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
static bool checkCondition(Sema &S, const Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
static Decl * getPredefinedExprDecl(DeclContext *DC)
getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used to determine the value o...
static bool checkForArray(const Expr *E)
static void DiagnosedUnqualifiedCallsToStdFunctions(Sema &S, const CallExpr *Call)
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type.
static void DoMarkPotentialCapture(Sema &SemaRef, SourceLocation Loc, ValueDecl *Var, Expr *E)
static std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
static void EvaluateAndDiagnoseImmediateInvocation(Sema &SemaRef, Sema::ImmediateInvocationCandidate Candidate)
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
static bool IsArithmeticBinaryExpr(const Expr *E, BinaryOperatorKind *Opcode, const Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptionsOverride FPFeatures)
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static void diagnoseSubtractionOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool BothNull)
Diagnose invalid subraction on a null pointer.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
static bool IsInvalidCmseNSCallConversion(Sema &S, QualType FromType, QualType ToType)
static void RemoveNestedImmediateInvocation(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec, SmallVector< Sema::ImmediateInvocationCandidate, 4 >::reverse_iterator It)
static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *SubExpr)
Look for bitwise op in the left or right hand of a bitwise op with lower precedence and emit a diagno...
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usual...
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
Diagnose some forms of syntactically-obvious tautological comparison.
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, const Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128, __ibm128 and long double if there is no support for ...
static void MarkVarDeclODRUsed(ValueDecl *V, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Directly mark a variable odr-used.
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
static bool funcHasParameterSizeMangling(Sema &S, FunctionDecl *FD)
Return true if this function has a calling convention that requires mangling in the size of the param...
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector)
Attempt to convert and splat Scalar into a vector whose types matches Vector following GCC conversion...
static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the lambda.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
static OdrUseContext isOdrUseContext(Sema &SemaRef)
Are we within a context in which references to resolved functions or to variables result in odr-use?
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, ValueDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S, bool Invalid)
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
static void diagnoseUncapturableValueReferenceOrBinding(Sema &S, SourceLocation loc, ValueDecl *var)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
static bool IsReadonlyMessage(Expr *E, Sema &S)
static void buildLambdaCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI, ValueDecl *Var)
Create up to 4 fix-its for explicit reference and value capture of Var or default capture.
static void tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(Sema &S, const UnresolvedMemberExpr *const UME, SourceLocation CallLoc)
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType, SourceLocation Loc)
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static bool CheckVectorElementsTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
static QualType getDependentArraySubscriptType(Expr *LHS, Expr *RHS, const ASTContext &Ctx)
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
static void checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc, Sema::ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
static unsigned GetFixedPointRank(QualType Ty)
Return the rank of a given fixed point or integer type.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer,...
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS, const ExprResult &XorRHS, const SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
static bool IsArithmeticOp(BinaryOperatorKind Opc)
static bool handleComplexIntegerToFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Convert complex integers to complex floats and real integers to real floats as required for complex a...
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type.
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
static QualType handleComplexFloatConversion(Sema &S, ExprResult &Shorter, QualType ShorterType, QualType LongerType, bool PromotePrecision)
static void DoMarkBindingDeclReferenced(Sema &SemaRef, SourceLocation Loc, BindingDecl *BD, Expr *E)
static PredefinedIdentKind getPredefinedExprKind(tok::TokenKind Kind)
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, QualType RHSTy)
handleFixedPointConversion - Fixed point operations between fixed point types and integers or other f...
static QualType handleComplexConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool canCaptureVariableByCopy(ValueDecl *Var, const ASTContext &Context)
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, Expr *E0, Expr *E1=nullptr)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
static bool isObjCObjectLiteral(ExprResult &E)
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
static bool isLegalBoolVectorBinaryOp(BinaryOperatorKind Opc)
static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, NonOdrUseReason NOUR)
Walk the set of potential results of an expression and mark them all as non-odr-uses if they satisfy ...
static void CheckCompleteParameterTypesForMangler(Sema &S, FunctionDecl *FD, SourceLocation Loc)
Require that all of the parameter types of function be complete.
static bool isScopedEnumerationType(QualType T)
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
This file declares semantic analysis for expressions involving.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
tok::TokenKind ContextKind
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
C Language Family Type Representation.
__DEVICE__ int max(int __a, int __b)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
CanQualType ARCUnbridgedCastTy
unsigned getIntWidth(QualType T) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
DeclarationNameTable DeclarationNames
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getRecordType(const RecordDecl *Decl) const
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
bool typesAreBlockPointerCompatible(QualType, QualType)
const LangOptions & getLangOpts() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
CanQualType BoundMemberTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
CanQualType PseudoObjectTy
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
llvm::DenseSet< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
CanQualType UnsignedLongLongTy
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
const TargetInfo & getTargetInfo() const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
CanQualType IncompleteMatrixIdxTy
QualType getCorrespondingUnsignedType(QualType T) const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const TargetInfo * getAuxTargetInfo() const
QualType getCorrespondingSignedType(QualType T) const
QualType getWideCharType() const
Return the type of wide characters.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
unsigned char getFixedPointScale(QualType Ty) const
QualType adjustStringLiteralBaseType(QualType StrLTy) const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
bool isDependenceAllowed() const
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
TranslationUnitDecl * getTranslationUnitDecl() const
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
AddrLabelExpr - The GNU address of label extension, representing &&label.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for arrays.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Attr - This represents one attribute.
SourceRange getRange() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isComparisonOp(Opcode Opc)
bool isComparisonOp() const
StringRef getOpcodeStr() const
bool isRelationalOp() const
SourceLocation getOperatorLoc() const
bool isCompoundAssignmentOp() const
bool isMultiplicativeOp() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
bool isEqualityOp() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
bool isAdditiveOp() const
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, const Expr *LHS, const Expr *RHS)
Return true if a binary operator using the specified opcode and operands would match the 'p = (i8*)nu...
bool isAssignmentOp() const
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static bool isBitwiseOp(Opcode Opc)
A binding in a decomposition declaration.
A class which contains all the information about a particular captured value.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
ArrayRef< ParmVarDecl * > parameters() const
void setSignatureAsWritten(TypeSourceInfo *Sig)
void setBlockMissingReturnType(bool val=true)
void setIsVariadic(bool value)
SourceLocation getCaretLocation() const
void setBody(CompoundStmt *B)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
This class is used for builtin types like 'int'.
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a call to a C++ constructor.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Represents a C++ base or member initializer.
A default argument (C++ [dcl.fct.default]).
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
Expr * getExpr()
Get the initialization expression that will be used.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
A call to an overloaded operator written using operator syntax.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
SourceRange getSourceRange() const
Represents a C++ struct/union/class.
bool isStandardLayout() const
Determine whether this class is standard-layout per C++ [class]p7.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
bool hasDefinition() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr ** getArgs()
Retrieve the call arguments.
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
void computeDependence()
Compute and set dependence bits.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
const char * getCastKindName() const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
unsigned getValue() const
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
Stmt * getStmtExprResult()
ConditionalOperator - The ?: ternary operator.
Represents the canonical version of C arrays with a specified constant size.
llvm::APInt getSize() const
Return the constant array size as an APInt.
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
static ConstantResultStorageKind getStorageKind(const APValue &Value)
void MoveIntoResult(APValue &Value, const ASTContext &Context)
SourceLocation getBeginLoc() const LLVM_READONLY
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
bool isImmediateInvocation() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void setTypoName(const IdentifierInfo *II)
void setTypoNNS(NestedNameSpecifier *NNS)
Wrapper for source info for pointers decayed from arrays and functions.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setDecl(ValueDecl *NewD)
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameInfo getNameInfo() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
SourceLocation getLocation() const
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
bool isInvalidDecl() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getLocation() const
void setReferenced(bool R=true)
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getDeclContext()
The name of a declaration.
std::string getAsString() const
Retrieve the human-readable string for this name.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
@ CXXConversionFunctionName
bool isIdentifier() const
Predicate functions for querying what type of name this is.
SourceLocation getBeginLoc() const LLVM_READONLY
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Information about one declarator, including the parsed type information and the identifier.
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInvalidType() const
const IdentifierInfo * getIdentifier() const
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
RAII object that enters a new expression evaluation context.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
ExplicitCastExpr - An explicit cast written in the source code.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreConversionOperatorSingleStep() LLVM_READONLY
Skip conversion operators.
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
@ NPCK_ZeroLiteral
Expression is a Null pointer constant built from a literal zero.
@ NPCK_CXX11_nullptr
Expression is a C++11 nullptr.
@ NPCK_NotNull
Expression is not a Null pointer constant.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
QualType getEnumCoercedType(const ASTContext &Ctx) const
If this expression is an enumeration constant, return the enumeration type under which said constant ...
@ ImmediateInvocation
An immediate invocation.
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
@ MLV_DuplicateVectorComponents
@ MLV_InvalidMessageExpression
@ MLV_ConstQualifiedField
@ MLV_SubObjCPropertySetting
bool isOrdinaryOrBitFieldObject() const
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
bool isFPConstrained() const
RoundingMode getRoundingMode() const
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
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.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
FullExpr - Represents a "full-expression" node.
const Expr * getSubExpr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Represents a function declaration or definition.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isImmediateFunction() const
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
QualType getReturnType() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
ArrayRef< ParmVarDecl * > parameters() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
size_t param_size() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
QualType getCallResultType() const
Determine the type of an expression that calls this function.
const ParmVarDecl * getParamDecl(unsigned i) const
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Represents a prototype with parameter type info, e.g.
ArrayRef< QualType > getParamTypes() const
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isParamConsumed(unsigned I) const
ArrayRef< QualType > param_types() const
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
Declaration of a template function.
unsigned getNumParams() const
SourceLocation getLocalRangeEnd() const
ParmVarDecl * getParam(unsigned i) const
TypeLoc getReturnLoc() const
SourceLocation getLocalRangeBegin() const
A class which abstracts out some details necessary for making a call.
bool getCmseNSCall() const
ExtInfo withNoReturn(bool noReturn) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
bool getCmseNSCallAttr() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Represents a field injected from an anonymous union/struct into the parent scope.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
void setParameterCFAudited()
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_Extended
Use extended type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Source
Use the declared type for fp arithmetic.
@ None
Permit no implicit vector bitcasts.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
bool isSubscriptPointerArithmetic() const
bool isSignedOverflowDefined() const
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by i) escaping '\' and " characters and ii) ...
Represents the results of name lookup.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
DeclClass * getAsSingle() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
MS property subscript expression.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
std::string getQualifiedNameAsString(bool WithGlobalNsPrefix=false) const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool isExternallyVisible() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber,...
Represents an ObjC class declaration.
bool hasDefinition() const
Determine whether this class has been defined.
ivar_iterator ivar_begin() const
ObjCInterfaceDecl * getSuperClass() const
Interfaces are the core concept in Objective-C for object oriented design.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getLocation() const
SourceLocation getOpLoc() const
const Expr * getBase() const
SourceLocation getEndLoc() const LLVM_READONLY
An expression that sends a message to the given Objective-C object or class.
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
QualType getReturnType() const
bool isClassMethod() const
ArrayRef< ParmVarDecl * > parameters() const
Represents a pointer to an Objective C object.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Represents a class type in Objective C.
Represents one property declaration in an Objective-C interface.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Represents an Objective-C protocol declaration.
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
Helper class for OffsetOfExpr.
static OpaquePtr getFromOpaquePtr(void *P)
void * getAsOpaquePtr() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
ParenExpr - This represents a parethesized expression, e.g.
const Expr * getSubExpr() const
SourceLocation getBeginLoc() const LLVM_READONLY
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
Expr * getExpr(unsigned Init)
Represents a parameter to a function.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
static std::string ComputeName(PredefinedIdentKind IK, const Decl *CurrentDecl, bool ForceElaboratedPrinting=false)
IdentifierTable & getIdentifierTable()
bool isMacroDefined(StringRef Id)
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isAddressSpaceOverlapping(QualType T) const
Returns true if address space qualifiers overlap with T address space qualifiers.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
QualType withCVRQualifiers(unsigned CVR) const
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
void removeAddressSpace()
void setAddressSpace(LangAS space)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
Represents a struct/union/class.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
static RecoveryExpr * Create(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs)
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
@ Sycl
SYCL specific diagnostic.
@ Esimd
ESIMD specific diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
@ CVT_Host
Emitted on device side with a shadow variable on host side.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
const DeclContext * getCurObjCLexicalContext() const
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void tryCaptureOpenMPLambdas(ValueDecl *V)
Function tries to capture lambda's captured variables in the OpenMP region before the original lambda...
OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, unsigned CapLevel) const
Check if the specified variable is used in 'private' clause.
VarDecl * isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo=false, unsigned StopAt=0)
Check if the specified variable is used in one of the private clauses (private, firstprivate,...
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, unsigned OpenMPCaptureLevel) const
Return true if the provided declaration VD should be captured by reference.
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
static bool isTypeDecoratedWithDeclAttribute(QualType Ty)
@ KernelNonConstStaticDataVariable
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Abstract base class used for diagnosing integer constant expression violations.
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
virtual SemaDiagnosticBuilder diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T)
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
const FieldDecl * getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned)
Returns a field in a CXXRecordDecl that has the same name as the decl SelfAssigned when inside a CXXM...
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ExprResult ActOnConstantExpression(ExprResult Res)
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
@ NTCUC_LValueToRValueVolatile
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool areVectorTypesSameSize(QualType srcType, QualType destType)
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
void ActOnStartStmtExpr()
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
void ActOnStmtExprError()
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
QualType GetSignedSizelessVectorType(QualType V)
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
Preprocessor & getPreprocessor() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool CheckCaseExpression(Expr *E)
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
void CleanupVarDeclMarking()
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
void PopExpressionEvaluationContext()
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
SourceRange getExprRange(Expr *E) const
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
void MarkExpressionAsImmediateEscalating(Expr *E)
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
const LangOptions & LangOpts
const LangOptions & getLangOpts() const
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
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...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
SourceManager & getSourceManager() const
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
@ ACK_CompAssign
A compound assignment expression.
@ ACK_Conditional
A conditional (?:) operator.
@ ACK_Comparison
A comparison.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
@ TryCapture_ExplicitByRef
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
bool CheckVecStepExpr(Expr *E)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
MaybeODRUseExprSet MaybeODRUseExprs
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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)
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
ASTContext & getASTContext() const
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
QualType GetSignedVectorType(QualType V)
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ 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),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
FPOptions & getCurFPFeatures()
void DiscardCleanupsInEvaluationContext()
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
SourceManager & SourceMgr
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
DiagnosticsEngine & Diags
NamespaceDecl * getStdNamespace() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector,...
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter,...
QualType CheckSizelessVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
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.
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
ExprResult ActOnStmtExprResult(ExprResult E)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
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 BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
sema::FunctionScopeInfo * getCurFunction() const
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
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...
@ LOLR_Error
The lookup resulted in an error.
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
DiagnosticsEngine & getDiagnostics() const
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
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...
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getBeginLoc() const
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
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.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
void setToType(unsigned Idx, QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
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
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
uint32_t getCodeUnit(size_t i) const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
StringRef getString() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
virtual size_t getMaxBitIntWidth() const
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
IntType getSizeType() const
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
virtual bool supportsExtendIntArgs() const
Whether the option -fextend-arguments={32,64} is supported on the target.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
void setKind(tok::TokenKind K)
tok::TokenKind getKind() const
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
void setIdentifierInfo(IdentifierInfo *II)
Represents a declaration of a type.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFixedPointOrIntegerType() const
Return true if this is a fixed point or integer type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isFunctionPointerType() const
bool isArithmeticType() const
bool isConstantMatrixType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isScalarType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isExtVectorType() const
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAnyComplexType() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
const BuiltinType * getAsPlaceholderType() const
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool isMemberPointerType() const
bool isAtomicType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCIdType() const
bool isMatrixType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isObjCObjectType() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isVectorType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
bool isFloatingType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isSubscriptableVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isSizelessVectorType() const
Returns true for all scalable vector types.
Simple class containing the result of Sema::CorrectTypo.
DeclClass * getCorrectionDeclAs() const
std::string getAsString(const LangOptions &LO) const
IdentifierInfo * getCorrectionAsIdentifierInfo() const
SourceRange getCorrectionRange() const
void WillReplaceSpecifier(bool ForceReplacement)
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isOverloaded() const
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
Expr * getSubExpr() const
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
bool isIncrementDecrementOp() const
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represents a C++ unqualified-id that has been parsed.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
A set of unresolved declarations.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Represents a call to the builtin function __builtin_va_arg.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
VarDecl * getPotentiallyDecomposedVarDecl()
Represents a variable declaration or definition.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
const Expr * getInit() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
bool isInline() const
Whether this variable is (C++1z) inline.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
@ TLS_None
Not a TLS variable.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
Retains information about a block that is currently being parsed.
Scope * TheScope
TheScope - This is the scope for the block itself, which contains arguments etc.
QualType FunctionType
BlockType - The function type of the block, if one was given.
bool isBlockCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void markUsed(bool IsODRUse)
bool isThisCapture() const
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool isCopyCapture() const
ValueDecl * getVariable() const
Retains information about a captured region.
unsigned short OpenMPLevel
unsigned short CapRegionKind
The kind of captured region.
unsigned short OpenMPCaptureLevel
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
Capture & getCapture(ValueDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured.
bool HasImplicitReturnType
Capture & getCXXThisCapture()
Retrieve the capture of C++ 'this', if it has been captured.
llvm::DenseMap< ValueDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Retains information about a function, method, or block that is currently being parsed.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
bool lambdaCaptureShouldBeConst() const
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas.
void addPotentialThisCapture(SourceLocation Loc)
CXXRecordDecl * Lambda
The class that describes the lambda.
unsigned NumExplicitCaptures
The number of captures in the Captures list that are explicit captures.
bool AfterParameterList
Indicate that we parsed the parameter list at which point the mutability of the lambda is known.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Defines the clang::TargetInfo interface.
constexpr XRayInstrMask None
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
constexpr Variable var(Literal L)
Returns the variable of L.
uint32_t Literal
Literals are represented as positive integers.
bool This(InterpState &S, CodePtr OpPC)
bool InitField(InterpState &S, CodePtr OpPC, uint32_t I)
1) Pops the value from the stack 2) Peeks a pointer from the stack 3) Pushes the value to field I of ...
bool Cast(InterpState &S, CodePtr OpPC)
std::string toString(const til::SExpr *E)
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OR_Success
Overload resolution succeeded.
bool isTargetAddressSpace(LangAS AS)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_VectorComponent
A vector component is an element or range of elements on a vector.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
@ OK_MatrixComponent
A matrix component is a single element of a matrix.
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
unsigned toTargetAddressSpace(LangAS AS)
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
bool isLambdaCallOperator(const CXXMethodDecl *MD)
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
bool isFunctionLocalStringLiteralMacro(tok::TokenKind K, const LangOptions &LO)
Return true if the token corresponds to a function local predefined macro, which expands to a string ...
ActionResult< Expr * > ExprResult
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
ActionResult< Stmt * > StmtResult
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
const FunctionProtoType * T
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
@ None
No keyword precedes the qualified type name.
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
@ NOUR_None
This is an odr-use.
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
Represents an element in a path from a derived class to a base class.
The class facilities generation and storage of conversion FixIts.
OverloadFixItKind Kind
The type of fix applied.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
unsigned HasTrailingReturn
FunctionType::ExtInfo ExtInfo
bool HasFormOfMemberPointer
OverloadExpr * Expression
Data structure used to record current or nested expression evaluation contexts.
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
bool isUnevaluated() const
llvm::SmallPtrSet< DeclRefExpr *, 4 > ReferenceToConsteval
Set of DeclRefExprs referencing a consteval function when used in a context not already known to be i...
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
bool isImmediateFunctionContext() const
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
MaybeODRUseExprSet SavedMaybeODRUseExprs
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
bool isConstantEvaluated() const
ExpressionEvaluationContext Context
The expression evaluation context.
bool InImmediateEscalatingFunctionContext
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Abstract class used to diagnose incomplete types.
Location information for a TemplateArgument.