68#include "llvm/ADT/STLExtras.h"
69#include "llvm/ADT/StringExtras.h"
70#include "llvm/IR/DerivedTypes.h"
71#include "llvm/Support/ConvertUTF.h"
72#include "llvm/Support/SaveAndRestore.h"
73#include "llvm/Support/TimeProfiler.h"
74#include "llvm/Support/TypeSize.h"
99 if (TreatUnavailableAsInvalid &&
117 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
120 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
121 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
123 if (DC && !DC->
hasAttr<UnusedAttr>())
124 S.
Diag(Loc, diag::warn_used_but_marked_unused) << D;
132 if (
Decl->isDefaulted()) {
143 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
144 if (Ctor && Ctor->isInheritingConstructor())
155 if (I->getStorageClass() !=
SC_None)
206 DiagID = diag::warn_c2y_compat_internal_in_extern_inline;
207 else if ((UsedFn && (UsedFn->
isInlined() || UsedFn->
hasAttr<ConstAttr>())) ||
209 DiagID = diag::ext_internal_in_extern_inline_quiet;
211 DiagID = diag::ext_internal_in_extern_inline;
213 S.
Diag(Loc, DiagID) << !UsedFn << D;
225 Diag(DeclBegin, diag::note_convert_inline_to_static)
232 bool ObjCPropertyAccess,
233 bool AvoidPartialAvailabilityChecks,
235 bool SkipTrailingRequiresClause) {
242 for (
const auto &[DiagLoc, PD] : Pos->second) {
256 Diag(Loc, diag::ext_main_used);
264 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
267 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
276 if (FD->isDeleted()) {
277 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
278 if (Ctor && Ctor->isInheritingConstructor())
279 Diag(Loc, diag::err_deleted_inherited_ctor_use)
281 << Ctor->getInheritedConstructor().getConstructor()->getParent();
284 Diag(Loc, diag::err_deleted_function_use)
285 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
299 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
308 diag::err_reference_to_function_with_unsatisfied_constraints)
326 if (
auto *
Concept = dyn_cast<ConceptDecl>(D);
330 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
332 if (MD->getParent()->isLambda() &&
335 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
336 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
341 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
343 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
344 return MD->findPropertyDecl();
358 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
361 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
374 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
380 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
381 Diag(Loc, diag::err_use_of_empty_using_if_exists);
382 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
387 AvoidPartialAvailabilityChecks, ClassReceiver);
393 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
396 PP.getLastFPEvalPragmaLocation().isValid() &&
397 PP.getCurrentFPEvalMethod() !=
getLangOpts().getFPEvalMethod())
399 diag::err_type_available_only_in_default_eval_method)
403 if (
auto *VD = dyn_cast<ValueDecl>(D))
408 if (!
Context.getTargetInfo().isTLSSupported())
409 if (
const auto *VD = dyn_cast<VarDecl>(D))
411 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
422 const SentinelAttr *
Attr = D->
getAttr<SentinelAttr>();
427 unsigned NumFormalParams;
431 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
433 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
434 NumFormalParams = MD->param_size();
435 CalleeKind = CK_Method;
436 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
437 NumFormalParams = FD->param_size();
438 CalleeKind = CK_Function;
439 if (FD->hasCXXExplicitFunctionObjectParameter())
441 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
448 CalleeKind = CK_Function;
451 CalleeKind = CK_Block;
456 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
457 NumFormalParams = proto->getNumParams();
468 unsigned NullPos =
Attr->getNullPos();
469 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
470 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
473 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
477 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
484 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
489 if (
Context.isSentinelNullExpr(SentinelExpr))
497 std::string NullValue;
498 if (CalleeKind == CK_Method &&
PP.isMacroDefined(
"nil"))
501 NullValue =
"nullptr";
502 else if (
PP.isMacroDefined(
"NULL"))
505 NullValue =
"(void*) 0";
508 Diag(Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
510 Diag(MissingNilLoc, diag::warn_missing_sentinel)
535 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
539 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
544 CK_FunctionToPointerDecay).
get();
559 CK_ArrayToPointerDecay);
575 if (UO && UO->getOpcode() == UO_Deref &&
576 UO->getSubExpr()->getType()->isPointerType()) {
578 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
581 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
583 !UO->getType().isVolatileQualified()) {
585 S.
PDiag(diag::warn_indirection_through_null)
586 << UO->getSubExpr()->getSourceRange());
588 S.
PDiag(diag::note_indirection_through_null));
608 BaseType = BaseType->getPointeeType();
620 if (ObjectSetClass) {
664 assert(!
T.isNull() &&
"r-value conversion on typeless expression?");
668 if (
T->canDecayToPointerType())
676 (
T->isDependentType() && !
T->isAnyPointerType() &&
677 !
T->isMemberPointerType()))
701 &
Context.Idents.get(
"object_getClass"),
707 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
724 if (
T.hasQualifiers())
725 T =
T.getUnqualifiedType();
732 if (
T->isMemberPointerType() &&
733 Context.getTargetInfo().getCXXABI().isMicrosoft())
744 Cleanup.setExprNeedsCleanups(
true);
747 Cleanup.setExprNeedsCleanups(
true);
754 CastKind CK =
T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
762 T =
Atomic->getValueType().getUnqualifiedType();
787 CK_FunctionToPointerDecay);
801 assert(!Ty.
isNull() &&
"UsualUnaryFPConversions - missing type");
807 PP.getLastFPEvalPragmaLocation().isValid())) {
808 switch (EvalMethod) {
810 llvm_unreachable(
"Unrecognized float evaluation method");
813 llvm_unreachable(
"Float evaluation method should be set by now");
821 CK_FloatingComplexCast)
830 CK_FloatingComplexCast)
862 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
886 if (
Context.isPromotableIntegerType(Ty)) {
901 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
913 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
914 BTy->
getKind() == BuiltinType::Float)) {
917 if (BTy->
getKind() == BuiltinType::Half) {
928 Context.getTypeSizeInChars(BTy) <
934 assert(8 ==
Context.getTypeSizeInChars(
Context.LongLongTy).getQuantity() &&
935 "Unexpected typesize for LongLongTy");
989 if (
Context.getTargetInfo().getTriple().isWasm() &&
1004 if (!
Record->hasNonTrivialCopyConstructor() &&
1005 !
Record->hasNonTrivialMoveConstructor() &&
1006 !
Record->hasNonTrivialDestructor())
1039 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1046 PDiag(diag::warn_pass_class_arg_to_vararg)
1054 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1061 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1065 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1078 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1080 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1119 if (
Call.isInvalid())
1124 if (Comma.isInvalid())
1131 diag::err_call_incomplete_argument))
1149 if (SkipCast)
return false;
1156 CK_IntegralComplexToFloatingComplex);
1174 bool PromotePrecision) {
1179 if (PromotePrecision) {
1184 if (LongerIsComplex)
1196 QualType RHSType,
bool IsCompAssign) {
1221 bool ConvertFloat,
bool ConvertInt) {
1226 CK_IntegralToFloating);
1237 CK_IntegralComplexToFloatingComplex);
1242 CK_FloatingRealToComplex);
1251 QualType RHSType,
bool IsCompAssign) {
1261 else if (!IsCompAssign)
1263 return LHSFloat ? LHSType : RHSType;
1268 if (LHSFloat && RHSFloat) {
1275 assert(order < 0 &&
"illegal float comparison");
1309 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1315 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1316 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1317 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1318 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1335 CK_IntegralComplexCast);
1341template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1344 QualType RHSType,
bool IsCompAssign) {
1349 if (LHSSigned == RHSSigned) {
1352 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1354 }
else if (!IsCompAssign)
1355 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1357 }
else if (order != (LHSSigned ? 1 : -1)) {
1361 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1363 }
else if (!IsCompAssign)
1364 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1371 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1373 }
else if (!IsCompAssign)
1374 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1383 RHS = (*doRHSCast)(S, RHS.
get(), result);
1385 LHS = (*doLHSCast)(S, LHS.
get(), result);
1395 bool IsCompAssign) {
1399 if (LHSComplexInt && RHSComplexInt) {
1404 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1409 if (LHSComplexInt) {
1413 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1416 CK_IntegralRealToComplex);
1421 assert(RHSComplexInt);
1426 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1431 CK_IntegralRealToComplex);
1439 bool IsCompAssign) {
1441 const auto *LhsOBT = LHSType->
getAs<OverflowBehaviorType>();
1442 const auto *RhsOBT = RHSType->
getAs<OverflowBehaviorType>();
1445 "Non-integer type conversion not supported for OverflowBehaviorTypes");
1448 LhsOBT && LhsOBT->getBehaviorKind() ==
1449 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1451 RhsOBT && RhsOBT->getBehaviorKind() ==
1452 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1454 LhsOBT && LhsOBT->getBehaviorKind() ==
1455 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1457 RhsOBT && RhsOBT->getBehaviorKind() ==
1458 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1460 QualType LHSUnderlyingType = LhsOBT ? LhsOBT->getUnderlyingType() : LHSType;
1461 QualType RHSUnderlyingType = RhsOBT ? RhsOBT->getUnderlyingType() : RHSType;
1463 std::optional<OverflowBehaviorType::OverflowBehaviorKind> DominantBehavior;
1464 if (LHSHasTrap || RHSHasTrap)
1465 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Trap;
1466 else if (LHSHasWrap || RHSHasWrap)
1467 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1469 QualType LHSConvType = LHSUnderlyingType;
1470 QualType RHSConvType = RHSUnderlyingType;
1471 if (DominantBehavior) {
1472 if (!LhsOBT || LhsOBT->getBehaviorKind() != *DominantBehavior)
1476 LHSConvType = LHSType;
1478 if (!RhsOBT || RhsOBT->getBehaviorKind() != *DominantBehavior)
1482 RHSConvType = RHSType;
1486 S, LHS, RHS, LHSConvType, RHSConvType, IsCompAssign);
1494 assert(BTy &&
"Expected a builtin type.");
1496 switch (BTy->getKind()) {
1497 case BuiltinType::ShortFract:
1498 case BuiltinType::UShortFract:
1499 case BuiltinType::SatShortFract:
1500 case BuiltinType::SatUShortFract:
1502 case BuiltinType::Fract:
1503 case BuiltinType::UFract:
1504 case BuiltinType::SatFract:
1505 case BuiltinType::SatUFract:
1507 case BuiltinType::LongFract:
1508 case BuiltinType::ULongFract:
1509 case BuiltinType::SatLongFract:
1510 case BuiltinType::SatULongFract:
1512 case BuiltinType::ShortAccum:
1513 case BuiltinType::UShortAccum:
1514 case BuiltinType::SatShortAccum:
1515 case BuiltinType::SatUShortAccum:
1517 case BuiltinType::Accum:
1518 case BuiltinType::UAccum:
1519 case BuiltinType::SatAccum:
1520 case BuiltinType::SatUAccum:
1522 case BuiltinType::LongAccum:
1523 case BuiltinType::ULongAccum:
1524 case BuiltinType::SatLongAccum:
1525 case BuiltinType::SatULongAccum:
1528 if (BTy->isInteger())
1530 llvm_unreachable(
"Unexpected fixed point or integer type");
1542 "Expected at least one of the operands to be a fixed point type");
1545 "Special fixed point arithmetic operation conversions are only "
1546 "applied to ints or other fixed point types");
1568 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1591 REnum = R->isUnscopedEnumerationType();
1593 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1597 ? diag::warn_arith_conv_enum_float_cxx20
1598 : diag::warn_arith_conv_enum_float)
1601 }
else if (!IsCompAssign && LEnum && REnum &&
1602 !
Context.hasSameUnqualifiedType(L, R)) {
1607 DiagID = diag::warn_conv_mixed_enum_types_cxx26;
1608 else if (!L->
castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage() ||
1609 !R->castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage()) {
1614 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1615 : diag::warn_arith_conv_mixed_anon_enum_types;
1620 ? diag::warn_conditional_mixed_enum_types_cxx20
1621 : diag::warn_conditional_mixed_enum_types;
1626 ? diag::warn_comparison_mixed_enum_types_cxx20
1627 : diag::warn_comparison_mixed_enum_types;
1630 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1631 : diag::warn_arith_conv_mixed_enum_types;
1634 << (int)ACK << L << R;
1652 auto IsSingleCodeUnitCP = [](
const QualType &
T,
const llvm::APSInt &
Value) {
1653 if (
T->isChar8Type())
1654 return llvm::IsSingleCodeUnitUTF8Codepoint(
Value.getExtValue());
1655 if (
T->isChar16Type())
1656 return llvm::IsSingleCodeUnitUTF16Codepoint(
Value.getExtValue());
1657 assert(
T->isChar32Type());
1658 return llvm::IsSingleCodeUnitUTF32Codepoint(
Value.getExtValue());
1671 if (LHSSuccess != RHSuccess) {
1673 if (IsSingleCodeUnitCP(LHSType, Res.
Val.
getInt()) &&
1674 IsSingleCodeUnitCP(RHSType, Res.
Val.
getInt()))
1678 if (!LHSSuccess || !RHSuccess) {
1679 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types)
1685 llvm::APSInt LHSValue(32);
1687 llvm::APSInt RHSValue(32);
1690 bool LHSSafe = IsSingleCodeUnitCP(LHSType, LHSValue);
1691 bool RHSSafe = IsSingleCodeUnitCP(RHSType, RHSValue);
1692 if (LHSSafe && RHSSafe)
1695 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types_constant)
1705 SemaRef.
Diag(Loc, diag::warn_arith_conv_mixed_unicode_types)
1739 LHSType = AtomicLHS->getValueType();
1742 if (
Context.hasSameType(LHSType, RHSType))
1743 return Context.getCommonSugaredType(LHSType, RHSType);
1751 QualType LHSUnpromotedType = LHSType;
1752 if (
Context.isPromotableIntegerType(LHSType))
1753 LHSType =
Context.getPromotedIntegerType(LHSType);
1755 if (!LHSBitfieldPromoteTy.
isNull())
1756 LHSType = LHSBitfieldPromoteTy;
1761 if (
Context.hasSameType(LHSType, RHSType))
1762 return Context.getCommonSugaredType(LHSType, RHSType);
1809 bool PredicateIsExpr,
void *ControllingExprOrType,
1811 unsigned NumAssocs = ArgTypes.size();
1812 assert(NumAssocs == ArgExprs.size());
1815 for (
unsigned i = 0; i < NumAssocs; ++i) {
1824 if (!PredicateIsExpr) {
1828 assert(ControllingType &&
"couldn't get the type out of the parser");
1829 ControllingExprOrType = ControllingType;
1833 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1845 const auto *TOBT =
T->getAs<OverflowBehaviorType>();
1846 const auto *UOBT =
U.getCanonicalType()->getAs<OverflowBehaviorType>();
1850 if (TOBT->getBehaviorKind() == UOBT->getBehaviorKind())
1852 UOBT->getUnderlyingType());
1864 bool PredicateIsExpr,
void *ControllingExprOrType,
1866 unsigned NumAssocs = Types.size();
1867 assert(NumAssocs == Exprs.size());
1868 assert(ControllingExprOrType &&
1869 "Must have either a controlling expression or a controlling type");
1871 Expr *ControllingExpr =
nullptr;
1873 if (PredicateIsExpr) {
1880 reinterpret_cast<Expr *
>(ControllingExprOrType));
1883 ControllingExpr = R.get();
1886 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1887 if (!ControllingType)
1891 bool TypeErrorFound =
false,
1892 IsResultDependent = ControllingExpr
1895 ContainsUnexpandedParameterPack =
1905 diag::warn_side_effects_unevaluated_context);
1907 for (
unsigned i = 0; i < NumAssocs; ++i) {
1908 if (Exprs[i]->containsUnexpandedParameterPack())
1909 ContainsUnexpandedParameterPack =
true;
1912 if (Types[i]->
getType()->containsUnexpandedParameterPack())
1913 ContainsUnexpandedParameterPack =
true;
1915 if (Types[i]->
getType()->isDependentType()) {
1916 IsResultDependent =
true;
1933 if (ControllingExpr && Types[i]->
getType()->isIncompleteType())
1934 D =
LangOpts.C2y ? diag::compat_c2y_assoc_type_incomplete
1935 : diag::compat_pre_c2y_assoc_type_incomplete;
1936 else if (ControllingExpr && !Types[i]->
getType()->isObjectType())
1937 D = diag::err_assoc_type_nonobject;
1938 else if (Types[i]->
getType()->isVariablyModifiedType())
1939 D = diag::err_assoc_type_variably_modified;
1940 else if (ControllingExpr) {
1959 unsigned Reason = 0;
1968 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1969 diag::warn_unreachable_association)
1970 << QT << (Reason - 1);
1974 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1975 << Types[i]->getTypeLoc().getSourceRange() << Types[i]->getType();
1977 D, Types[i]->getTypeLoc().getBeginLoc()) >=
1979 TypeErrorFound =
true;
1984 for (
unsigned j = i+1; j < NumAssocs; ++j)
1985 if (Types[j] && !Types[j]->
getType()->isDependentType() &&
1988 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1989 diag::err_assoc_compatible_types)
1990 << Types[j]->getTypeLoc().getSourceRange()
1991 << Types[j]->getType()
1992 << Types[i]->getType();
1993 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1994 diag::note_compat_assoc)
1995 << Types[i]->getTypeLoc().getSourceRange()
1996 << Types[i]->getType();
1997 TypeErrorFound =
true;
2007 if (IsResultDependent) {
2008 if (ControllingExpr)
2010 Types, Exprs, DefaultLoc, RParenLoc,
2011 ContainsUnexpandedParameterPack);
2013 Exprs, DefaultLoc, RParenLoc,
2014 ContainsUnexpandedParameterPack);
2018 unsigned DefaultIndex = std::numeric_limits<unsigned>::max();
2022 for (
unsigned i = 0; i < NumAssocs; ++i) {
2030 QualType AssocQT = Types[i]->getType();
2036 CompatIndices.push_back(i);
2040 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
2044 if (ControllingExpr)
2053 return std::make_pair(SR, QT);
2059 if (CompatIndices.size() > 1) {
2060 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2063 << SR << P.second << (unsigned)CompatIndices.size();
2064 for (
unsigned I : CompatIndices) {
2065 Diag(Types[I]->getTypeLoc().getBeginLoc(),
2066 diag::note_compat_assoc)
2067 << Types[I]->getTypeLoc().getSourceRange()
2068 << Types[I]->getType();
2076 if (DefaultIndex == std::numeric_limits<unsigned>::max() &&
2077 CompatIndices.size() == 0) {
2078 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2080 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR << P.second;
2089 unsigned ResultIndex =
2090 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
2092 if (ControllingExpr) {
2094 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
2095 ContainsUnexpandedParameterPack, ResultIndex);
2098 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
2099 ContainsUnexpandedParameterPack, ResultIndex);
2105 llvm_unreachable(
"unexpected TokenKind");
2106 case tok::kw___func__:
2108 case tok::kw___FUNCTION__:
2110 case tok::kw___FUNCDNAME__:
2112 case tok::kw___FUNCSIG__:
2114 case tok::kw_L__FUNCTION__:
2116 case tok::kw_L__FUNCSIG__:
2118 case tok::kw___PRETTY_FUNCTION__:
2129 auto tryAdjustLambdaContext = [&S, &LSI](
DeclContext *&DC) {
2134 assert(LSI != E &&
"Should be in a lambda scope info");
2135 if (dyn_cast<LambdaScopeInfo>(*LSI)->BeforeCompoundStatement)
2141 tryAdjustLambdaContext(DC);
2145 tryAdjustLambdaContext(DC);
2148 return cast_or_null<Decl>(DC);
2166 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
2169 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2170 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
2171 if (ArgTy[ArgIdx]->isArrayType())
2192 std::vector<Token> ExpandedToks;
2198 if (Literal.hadError)
2202 for (
const Token &
Tok : StringToks)
2203 StringTokLocs.push_back(
Tok.getLocation());
2207 false, {}, StringTokLocs);
2209 if (!Literal.getUDSuffix().empty()) {
2212 Literal.getUDSuffixOffset());
2213 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2233 CurrentDecl =
Context.getTranslationUnitDecl();
2235 std::vector<Token> ExpandedToks;
2236 ExpandedToks.reserve(Toks.size());
2240 ExpandedToks.emplace_back(
Tok);
2244 Diag(
Tok.getLocation(), diag::ext_predef_outside_function);
2246 Diag(
Tok.getLocation(), diag::ext_string_literal_from_predefined)
2249 llvm::raw_svector_ostream
OS(Str);
2250 Token &Exp = ExpandedToks.emplace_back();
2252 if (
Tok.getKind() == tok::kw_L__FUNCTION__ ||
2253 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2255 Exp.
setKind(tok::wide_string_literal);
2257 Exp.
setKind(tok::string_literal);
2263 PP.CreateString(
OS.str(), Exp,
Tok.getLocation(),
Tok.getEndLoc());
2265 return ExpandedToks;
2270 assert(!StringToks.empty() &&
"Must have at least one string!");
2273 std::vector<Token> ExpandedToks;
2279 if (Literal.hadError)
2283 for (
const Token &
Tok : StringToks)
2284 StringTokLocs.push_back(
Tok.getLocation());
2288 if (Literal.isWide()) {
2289 CharTy =
Context.getWideCharType();
2291 }
else if (Literal.isUTF8()) {
2295 CharTy =
Context.UnsignedCharTy;
2297 }
else if (Literal.isUTF16()) {
2300 }
else if (Literal.isUTF32()) {
2303 }
else if (Literal.isPascal()) {
2304 CharTy =
Context.UnsignedCharTy;
2316 ? diag::warn_cxx20_compat_utf8_string
2317 : diag::warn_c23_compat_utf8_string);
2323 auto RemovalDiag =
PDiag(diag::note_cxx20_c23_compat_utf8_string_remove_u8);
2325 for (
const Token &
Tok : StringToks) {
2326 if (
Tok.getKind() == tok::utf8_string_literal) {
2328 RemovalDiagLoc =
Tok.getLocation();
2335 Diag(RemovalDiagLoc, RemovalDiag);
2339 Context.getStringLiteralArrayType(CharTy, Literal.GetNumStringChars());
2343 Context, Literal.GetString(), Kind, Literal.Pascal, StrTy, StringTokLocs);
2344 if (Literal.getUDSuffix().empty())
2351 Literal.getUDSuffixOffset());
2355 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2362 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
2367 Context.getArrayDecayedType(StrTy), SizeType
2377 llvm::APInt Len(
Context.getIntWidth(SizeType), Literal.GetNumStringChars());
2380 Expr *Args[] = { Lit, LenArg };
2397 unsigned CharBits =
Context.getIntWidth(CharTy);
2399 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2406 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2416 llvm_unreachable(
"unexpected literal operator lookup result");
2420 llvm_unreachable(
"unexpected literal operator lookup result");
2452 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2455 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2456 if (!Referee || !Referee->hasGlobalStorage() ||
2457 Referee->hasAttr<CUDADeviceAttr>())
2463 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2464 if (MD && MD->getParent()->isLambda() &&
2465 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2487 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2488 if (VD->getType()->isReferenceType() &&
2491 VD->isUsableInConstantExpressions(
Context))
2510 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2538 const auto *FD = dyn_cast<FieldDecl>(D);
2539 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2540 FD = IFD->getAnonField();
2544 if (FD->isBitField())
2550 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2551 if (
const auto *BE = BD->getBinding())
2563 if (II->hasMacroDefinition()) {
2573 std::optional<Token> NextTok =
2575 if (NextTok && NextTok->is(tok::l_paren))
2577 SemaRef.
Diag(TypoLoc,
2578 diag::err_undeclared_var_use_suggest_func_like_macro)
2581 diag::note_function_like_macro_requires_parens)
2605 NameInfo =
Context.getNameForTemplate(TName, TNameLoc);
2606 TemplateArgs = &Buffer;
2609 TemplateArgs =
nullptr;
2617 bool isDefaultArgument =
2621 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2622 bool isInstance = CurMethod && CurMethod->isInstance() &&
2623 R.getNamingClass() == CurMethod->getParent() &&
2631 unsigned DiagID = diag::err_found_in_dependent_base;
2632 unsigned NoteID = diag::note_member_declared_at;
2633 if (R.getRepresentativeDecl()->getDeclContext()->Equals(R.getNamingClass())) {
2634 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2635 : diag::err_found_later_in_class;
2637 DiagID = diag::ext_found_in_dependent_base;
2638 NoteID = diag::note_dependent_member_use;
2643 Diag(R.getNameLoc(), DiagID)
2644 << R.getLookupName()
2650 Diag(R.getNameLoc(), DiagID) << R.getLookupName();
2654 Diag(D->getLocation(), NoteID);
2663 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
2664 Diag(R.getNameLoc(), diag::err_member_call_without_object) << 0;
2677 SourceRange NameRange = R.getLookupNameInfo().getSourceRange();
2679 unsigned diagnostic = diag::err_undeclared_var_use;
2680 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2684 diagnostic = diag::err_undeclared_use;
2685 diagnostic_suggest = diag::err_undeclared_use_suggest;
2696 if (ExplicitTemplateArgs) {
2708 R.suppressDiagnostics();
2719 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2734 if (S && (Corrected =
2735 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
2738 bool DroppedSpecifier =
2742 bool AcceptableWithRecovery =
false;
2743 bool AcceptableWithoutRecovery =
false;
2752 dyn_cast<FunctionTemplateDecl>(CD))
2756 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2757 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2763 ND = Best->FoundDecl;
2764 Corrected.setCorrectionDecl(ND);
2768 Corrected.setCorrectionDecl(ND);
2779 R.setNamingClass(
Record);
2796 AcceptableWithoutRecovery =
true;
2799 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2801 ? diag::note_implicit_param_decl
2802 : diag::note_previous_decl;
2805 PDiag(NoteID), AcceptableWithRecovery);
2808 PDiag(diag::err_no_member_suggest)
2810 << DroppedSpecifier << NameRange,
2811 PDiag(NoteID), AcceptableWithRecovery);
2821 return !AcceptableWithRecovery;
2832 Diag(R.getNameLoc(), diag::err_no_member)
2838 Diag(R.getNameLoc(), diagnostic) << Name << NameRange;
2859 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2867 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2868 DB << NameInfo.
getName() << RD;
2870 if (!ThisType.
isNull()) {
2873 Context,
nullptr, ThisType,
true,
2875 nullptr, NameInfo, TemplateArgs);
2891 bool IsAddressOfOperand,
2893 bool IsInlineAsmIdentifier) {
2894 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2895 "cannot be direct & operand and have a trailing lparen");
2929 llvm::none_of(S->
decls(), [&](
Decl *D) {
2930 return isa<ParmVarDecl>(D) &&
2931 cast<ParmVarDecl>(D)->getDeclName() == NameInfo.getName();
2937 if (
auto *VD = dyn_cast<ValueDecl>(R.getFoundDecl())) {
2951 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2959 false, TemplateKWLoc,
2963 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2965 IsAddressOfOperand, TemplateArgs);
2969 !IvarLookupFollowUp);
2973 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2975 IsAddressOfOperand, TemplateArgs);
2979 if (IvarLookupFollowUp) {
2989 if (R.isAmbiguous())
2994 if (R.empty() && HasTrailingLParen && II &&
2997 if (D) R.addDecl(D);
3004 if (R.empty() && !ADL) {
3007 TemplateKWLoc, TemplateArgs))
3012 if (IsInlineAsmIdentifier)
3020 "Typo correction callback misconfigured");
3034 assert(!R.empty() &&
3035 "DiagnoseEmptyLookup returned false but added no results");
3042 ExprResult E(
ObjC().LookupInObjCMethod(R, S, Ivar->getIdentifier()));
3052 assert(!R.empty() || ADL);
3082 if (TemplateArgs || TemplateKWLoc.
isValid()) {
3091 "There should only be one declaration found.");
3106 if (R.isAmbiguous())
3109 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
3119 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
3120 if (CD->isInvalidDecl() || CD->isBeingDefined())
3130 if (
auto *TagD = dyn_cast<TagDecl>(TD)) {
3137 TL.setNameLoc(NameInfo.
getLoc());
3138 }
else if (
auto *TypedefD = dyn_cast<TypedefNameDecl>(TD)) {
3146 ET =
SemaRef.Context.getTypeDeclType(TD);
3154 unsigned DiagID = diag::err_typename_missing;
3156 DiagID = diag::ext_typename_missing;
3158 auto D =
Diag(Loc, DiagID);
3189 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3197 bool PointerConversions =
false;
3199 DestRecordType =
Context.getCanonicalTagType(RD);
3201 DestRecordType =
Context.getAddrSpaceQualType(
3202 DestRecordType, FromPtrType
3207 DestType =
Context.getPointerType(DestRecordType);
3209 PointerConversions =
true;
3211 DestType = DestRecordType;
3212 FromRecordType = FromType;
3214 }
else if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
Member)) {
3215 if (!
Method->isImplicitObjectMemberFunction())
3218 DestType =
Method->getThisType().getNonReferenceType();
3219 DestRecordType =
Method->getFunctionObjectParameterType();
3223 PointerConversions =
true;
3225 FromRecordType = FromType;
3226 DestType = DestRecordType;
3231 if (FromAS != DestAS) {
3233 Context.removeAddrSpaceQualType(FromRecordType);
3235 Context.getAddrSpaceQualType(FromRecordTypeWithoutAS, DestAS);
3236 if (PointerConversions)
3237 FromTypeWithDestAS =
Context.getPointerType(FromTypeWithDestAS);
3251 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3279 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3289 FromLoc, FromRange, &BasePath))
3292 if (PointerConversions)
3293 QType =
Context.getPointerType(QType);
3295 VK, &BasePath).
get();
3298 FromRecordType = QRecordType;
3302 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3309 FromLoc, FromRange, &BasePath,
3318 DestType =
Context.getQualifiedType(DestType, FromTypeQuals);
3326 bool HasTrailingLParen) {
3328 if (!HasTrailingLParen)
3346 if (D->isCXXClassMember())
3357 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3364 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3366 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3381 bool AcceptInvalid) {
3406 assert(R.isSingleResult() &&
"Expected only a single result");
3407 const auto *FD = dyn_cast<FunctionDecl>(R.getFoundDecl());
3409 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3414 bool AcceptInvalidDecl) {
3417 if (!NeedsADL && R.isSingleResult() &&
3421 R.getRepresentativeDecl(),
nullptr,
3435 R.suppressDiagnostics();
3439 R.getLookupNameInfo(), NeedsADL, R.begin(), R.end(),
3448 bool AcceptInvalidDecl) {
3449 assert(D &&
"Cannot refer to a NULL declaration");
3451 "Cannot refer unambiguously to a function template");
3470 Diag(Loc, diag::err_ref_non_value) << D << SS.
getRange();
3485 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3491 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3492 IndirectField && !IndirectField->isCXXClassMember())
3504 type =
type.getNonPackExpansionType();
3508#define ABSTRACT_DECL(kind)
3509#define VALUE(type, base)
3510#define DECL(type, base) case Decl::type:
3511#include "clang/AST/DeclNodes.inc"
3512 llvm_unreachable(
"invalid value decl kind");
3515 case Decl::ObjCAtDefsField:
3516 llvm_unreachable(
"forming non-member reference to ivar?");
3520 case Decl::EnumConstant:
3521 case Decl::UnresolvedUsingValue:
3522 case Decl::OMPDeclareReduction:
3523 case Decl::OMPDeclareMapper:
3532 case Decl::IndirectField:
3533 case Decl::ObjCIvar:
3535 "building reference to field in C?");
3545 case Decl::NonTypeTemplateParm: {
3547 type = reftype->getPointeeType();
3557 if (
type->isRecordType()) {
3558 type =
type.getUnqualifiedType().withConst();
3571 case Decl::VarTemplateSpecialization:
3572 case Decl::VarTemplatePartialSpecialization:
3573 case Decl::Decomposition:
3575 case Decl::OMPCapturedExpr:
3578 type->isVoidType()) {
3584 case Decl::ImplicitParam:
3585 case Decl::ParmVar: {
3595 if (!CapturedType.
isNull())
3596 type = CapturedType;
3601 case Decl::Function: {
3603 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
3640 case Decl::CXXDeductionGuide:
3641 llvm_unreachable(
"building reference to deduction guide");
3643 case Decl::MSProperty:
3645 case Decl::TemplateParamObject:
3651 case Decl::UnnamedGlobalConstant:
3655 case Decl::CXXMethod:
3660 dyn_cast<FunctionProtoType>(VD->getType()))
3661 if (proto->getReturnType() ==
Context.UnknownAnyTy) {
3674 case Decl::CXXConversion:
3675 case Decl::CXXDestructor:
3676 case Decl::CXXConstructor:
3688 if (VD->isInvalidDecl() && E)
3695 Target.resize(CharByteWidth * (Source.size() + 1));
3696 char *ResultPtr = &
Target[0];
3697 const llvm::UTF8 *ErrorPtr;
3699 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3709 Diag(Loc, diag::ext_predef_outside_function);
3710 currentDecl =
Context.getTranslationUnitDecl();
3720 bool ForceElaboratedPrinting =
3724 unsigned Length = Str.length();
3726 llvm::APInt LengthI(32, Length + 1);
3730 Context.adjustStringLiteralBaseType(
Context.WideCharTy.withConst());
3734 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3740 ResTy =
Context.adjustStringLiteralBaseType(
Context.CharTy.withConst());
3741 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3760 StringRef ThisTok =
PP.getSpelling(
Tok, CharBuffer, &
Invalid);
3766 if (Literal.hadError())
3770 if (Literal.isWide())
3776 else if (Literal.isUTF16())
3778 else if (Literal.isUTF32())
3787 if (Literal.isWide())
3789 else if (Literal.isUTF16())
3791 else if (Literal.isUTF32())
3793 else if (Literal.isUTF8())
3799 if (Literal.getUDSuffix().empty())
3809 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3814 Lit,
Tok.getLocation());
3818 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
3820 llvm::APInt(IntSize, Val,
true),
3842 using llvm::APFloat;
3843 APFloat Val(Format);
3846 if (RM == llvm::RoundingMode::Dynamic)
3847 RM = llvm::RoundingMode::NearestTiesToEven;
3848 APFloat::opStatus result = Literal.GetFloatValue(Val, RM);
3852 if ((result & APFloat::opOverflow) ||
3853 ((result & APFloat::opUnderflow) && Val.isZero())) {
3854 unsigned diagnostic;
3856 if (result & APFloat::opOverflow) {
3857 diagnostic = diag::warn_float_overflow;
3858 APFloat::getLargest(Format).toString(buffer);
3860 diagnostic = diag::warn_float_underflow;
3861 APFloat::getSmallest(Format).toString(buffer);
3864 S.
Diag(Loc, diagnostic) << Ty << buffer.str();
3867 bool isExact = (result == APFloat::opOK);
3872 assert(E &&
"Invalid expression");
3879 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3883 llvm::APSInt ValueAPS;
3894 bool ValueIsPositive =
3895 AllowZero ? ValueAPS.isNonNegative() : ValueAPS.isStrictlyPositive();
3896 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3898 <<
toString(ValueAPS, 10) << ValueIsPositive;
3908 if (
Tok.getLength() == 1 ||
Tok.getKind() == tok::binary_data) {
3909 const uint8_t Val =
PP.getSpellingOfSingleCharacterNumericConstant(
Tok);
3918 SpellingBuffer.resize(
Tok.getLength() + 1);
3922 StringRef TokSpelling =
PP.getSpelling(
Tok, SpellingBuffer, &
Invalid);
3927 PP.getSourceManager(),
PP.getLangOpts(),
3928 PP.getTargetInfo(),
PP.getDiagnostics());
3929 if (Literal.hadError)
3932 if (Literal.hasUDSuffix()) {
3940 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3943 if (Literal.isFloatingLiteral()) {
3947 CookedTy =
Context.LongDoubleTy;
3952 CookedTy =
Context.UnsignedLongLongTy;
3956 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
3968 !Literal.isImaginary)) {
3977 if (Literal.isFloatingLiteral()) {
3980 llvm::APInt ResultVal(
Context.getTargetInfo().getLongLongWidth(), 0);
3981 if (Literal.GetIntegerValue(ResultVal))
3982 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3994 unsigned Length = Literal.getUDSuffixOffset();
4001 false, StrTy, TokLoc);
4012 bool CharIsUnsigned =
Context.CharTy->isUnsignedIntegerType();
4013 llvm::APSInt
Value(CharBits, CharIsUnsigned);
4014 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
4015 Value = TokSpelling[I];
4023 llvm_unreachable(
"unexpected literal operator lookup result");
4029 if (Literal.isFixedPointLiteral()) {
4032 if (Literal.isAccum) {
4033 if (Literal.isHalf) {
4035 }
else if (Literal.isLong) {
4040 }
else if (Literal.isFract) {
4041 if (Literal.isHalf) {
4043 }
else if (Literal.isLong) {
4050 if (Literal.isUnsigned) Ty =
Context.getCorrespondingUnsignedType(Ty);
4052 bool isSigned = !Literal.isUnsigned;
4053 unsigned scale =
Context.getFixedPointScale(Ty);
4054 unsigned bit_width =
Context.getTypeInfo(Ty).Width;
4056 llvm::APInt Val(bit_width, 0, isSigned);
4057 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
4058 bool ValIsZero = Val.isZero() && !Overflowed;
4060 auto MaxVal =
Context.getFixedPointMax(Ty).getValue();
4061 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
4067 else if (Val.ugt(MaxVal) || Overflowed)
4068 Diag(
Tok.getLocation(), diag::err_too_large_for_fixed_point);
4071 Tok.getLocation(), scale);
4072 }
else if (Literal.isFloatingLiteral()) {
4074 if (Literal.isHalf){
4079 Diag(
Tok.getLocation(), diag::err_half_const_requires_fp16);
4082 }
else if (Literal.isFloat)
4084 else if (Literal.isLong)
4086 else if (Literal.isFloat16)
4088 else if (Literal.isFloat128)
4105 Diag(
Tok.getLocation(), diag::warn_double_const_requires_fp64)
4110 }
else if (!Literal.isIntegerLiteral()) {
4116 if (Literal.isSizeT) {
4120 Diag(
Tok.getLocation(), diag::err_cxx23_size_t_suffix);
4128 if (Literal.isBitInt)
4129 PP.Diag(
Tok.getLocation(),
4132 : diag::ext_c23_bitint_suffix);
4141 unsigned BitsNeeded =
Context.getTargetInfo().getIntMaxTWidth();
4142 if (Literal.isBitInt)
4143 BitsNeeded = llvm::APInt::getSufficientBitsNeeded(
4144 Literal.getLiteralDigits(), Literal.getRadix());
4145 if (Literal.MicrosoftInteger) {
4146 if (Literal.MicrosoftInteger == 128 &&
4147 !
Context.getTargetInfo().hasInt128Type())
4148 PP.Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4149 << Literal.isUnsigned;
4150 BitsNeeded = std::max<unsigned>(BitsNeeded, Literal.MicrosoftInteger);
4153 llvm::APInt ResultVal(BitsNeeded, 0);
4155 if (Literal.GetIntegerValue(ResultVal)) {
4157 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4159 Ty =
Context.UnsignedLongLongTy;
4160 assert(
Context.getTypeSize(Ty) == ResultVal.getBitWidth() &&
4161 "long long is not intmax_t?");
4168 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
4175 Literal.isLong =
true;
4176 Literal.isLongLong =
false;
4183 if (Literal.MicrosoftInteger) {
4184 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
4188 Width = Literal.MicrosoftInteger;
4189 Ty =
Context.getIntTypeForBitwidth(Width,
4190 !Literal.isUnsigned);
4194 ResultVal = ResultVal.zextOrTrunc(Width);
4199 if (Literal.isBitInt) {
4202 Width = std::max(ResultVal.getActiveBits(), 1u) +
4203 (Literal.isUnsigned ? 0u : 1u);
4207 unsigned int MaxBitIntWidth =
4208 Context.getTargetInfo().getMaxBitIntWidth();
4209 if (Width > MaxBitIntWidth) {
4210 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4211 << Literal.isUnsigned;
4212 Width = MaxBitIntWidth;
4219 ResultVal = ResultVal.zextOrTrunc(Width);
4220 Ty =
Context.getBitIntType(Literal.isUnsigned, Width);
4224 if (Literal.isSizeT) {
4225 assert(!Literal.MicrosoftInteger &&
4226 "size_t literals can't be Microsoft literals");
4227 unsigned SizeTSize =
Context.getTargetInfo().getTypeWidth(
4228 Context.getTargetInfo().getSizeType());
4231 if (ResultVal.isIntN(SizeTSize)) {
4233 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4234 Ty =
Context.getSignedSizeType();
4235 else if (AllowUnsigned)
4241 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
4244 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
4247 if (ResultVal.isIntN(IntSize)) {
4249 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4251 else if (AllowUnsigned)
4258 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
4259 unsigned LongSize =
Context.getTargetInfo().getLongWidth();
4262 if (ResultVal.isIntN(LongSize)) {
4264 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4266 else if (AllowUnsigned)
4271 const unsigned LongLongSize =
4272 Context.getTargetInfo().getLongLongWidth();
4276 ? diag::warn_old_implicitly_unsigned_long_cxx
4278 ext_old_implicitly_unsigned_long_cxx
4279 : diag::warn_old_implicitly_unsigned_long)
4280 << (LongLongSize > LongSize ? 0
4289 if (Ty.
isNull() && !Literal.isSizeT) {
4290 unsigned LongLongSize =
Context.getTargetInfo().getLongLongWidth();
4293 if (ResultVal.isIntN(LongLongSize)) {
4297 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4298 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4300 else if (AllowUnsigned)
4301 Ty =
Context.UnsignedLongLongTy;
4302 Width = LongLongSize;
4308 ? diag::warn_cxx98_compat_longlong
4309 : diag::ext_cxx11_longlong);
4311 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
4319 if (Literal.isSizeT)
4320 Diag(
Tok.getLocation(), diag::err_size_t_literal_too_large)
4321 << Literal.isUnsigned;
4324 diag::ext_integer_literal_too_large_for_signed);
4325 Ty =
Context.UnsignedLongLongTy;
4326 Width =
Context.getTargetInfo().getLongLongWidth();
4329 if (ResultVal.getBitWidth() != Width)
4330 ResultVal = ResultVal.trunc(Width);
4336 if (Literal.isImaginary) {
4342 Diag(
Tok.getLocation(), diag::ext_gnu_imaginary_constant);
4344 DiagCompat(
Tok.getLocation(), diag_compat::imaginary_constant);
4350 assert(E &&
"ActOnParenExpr() missing expr");
4353 !E->
isLValue() && ExprTy->hasFloatingRepresentation())
4365 if (!(
T->isArithmeticType() ||
T->isVoidType() ||
T->isVectorType())) {
4366 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
4371 assert((
T->isVoidType() || !
T->isIncompleteType()) &&
4372 "Scalar types should always be complete");
4380 if (!
T->isVectorType() && !
T->isSizelessVectorType())
4381 return S.
Diag(Loc, diag::err_builtin_non_vector_type)
4383 <<
"__builtin_vectorelements" <<
T << ArgRange;
4385 if (
auto *FD = dyn_cast<FunctionDecl>(S.
CurContext)) {
4386 if (
T->isSVESizelessBuiltinType()) {
4387 llvm::StringMap<bool> CallerFeatureMap;
4402 if (!
T->isFunctionType() && !
T->isFunctionPointerType() &&
4403 !
T->isFunctionReferenceType() && !
T->isMemberFunctionPointerType()) {
4404 S.
Diag(Loc, diag::err_ptrauth_type_disc_undiscriminated) <<
T << ArgRange;
4414 UnaryExprOrTypeTrait TraitKind) {
4420 if (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4421 TraitKind == UETT_PreferredAlignOf) {
4424 if (
T->isFunctionType()) {
4425 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
4432 if (
T->isVoidType()) {
4433 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4434 : diag::ext_sizeof_alignof_void_type;
4445 UnaryExprOrTypeTrait TraitKind) {
4449 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
4450 <<
T << (TraitKind == UETT_SizeOf)
4467 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4468 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4471 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4473 << ICE->getSubExpr()->getType();
4477 UnaryExprOrTypeTrait ExprKind) {
4479 assert(!ExprTy->isReferenceType());
4481 bool IsUnevaluatedOperand =
4482 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4483 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4484 ExprKind == UETT_VecStep || ExprKind == UETT_CountOf);
4485 if (IsUnevaluatedOperand) {
4501 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4503 if (ExprKind == UETT_VecStep)
4507 if (ExprKind == UETT_VectorElements)
4518 if (
Context.getTargetInfo().getTriple().isWasm() &&
4529 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4532 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4537 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4544 assert(!ExprTy->isReferenceType());
4546 if (ExprTy->isFunctionType()) {
4556 if (ExprKind == UETT_CountOf) {
4561 Diag(E->
getExprLoc(), diag::err_countof_arg_not_array_type) << ExprType;
4571 if (ExprKind == UETT_SizeOf) {
4572 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4573 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4574 QualType OType = PVD->getOriginalType();
4579 Diag(PVD->getLocation(), diag::note_declared_at);
4587 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4604 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4611 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4613 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4614 D = ME->getMemberDecl();
4634 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4637 if (!FD->getParent()->isCompleteDefinition()) {
4638 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4647 if (!FD->getType()->isReferenceType())
4666 assert(
T->isVariablyModifiedType());
4667 assert(CSI !=
nullptr);
4671 const Type *Ty =
T.getTypePtr();
4673#define TYPE(Class, Base)
4674#define ABSTRACT_TYPE(Class, Base)
4675#define NON_CANONICAL_TYPE(Class, Base)
4676#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4677#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4678#include "clang/AST/TypeNodes.inc"
4685 case Type::ExtVector:
4686 case Type::ConstantMatrix:
4689 case Type::TemplateSpecialization:
4690 case Type::ObjCObject:
4691 case Type::ObjCInterface:
4692 case Type::ObjCObjectPointer:
4693 case Type::ObjCTypeParam:
4696 case Type::HLSLInlineSpirv:
4697 llvm_unreachable(
"type class is never variably-modified!");
4698 case Type::Adjusted:
4704 case Type::ArrayParameter:
4710 case Type::BlockPointer:
4713 case Type::LValueReference:
4714 case Type::RValueReference:
4717 case Type::MemberPointer:
4720 case Type::ConstantArray:
4721 case Type::IncompleteArray:
4725 case Type::VariableArray: {
4739 case Type::FunctionProto:
4740 case Type::FunctionNoProto:
4745 case Type::UnaryTransform:
4746 case Type::Attributed:
4747 case Type::BTFTagAttributed:
4748 case Type::OverflowBehavior:
4749 case Type::HLSLAttributedResource:
4750 case Type::SubstTemplateTypeParm:
4751 case Type::MacroQualified:
4752 case Type::CountAttributed:
4753 case Type::LateParsedAttr:
4755 T =
T.getSingleStepDesugaredType(Context);
4760 case Type::Decltype:
4763 case Type::PackIndexing:
4770 case Type::DeducedTemplateSpecialization:
4773 case Type::TypeOfExpr:
4779 case Type::PredefinedSugar:
4783 }
while (!
T.isNull() &&
T->isVariablyModifiedType());
4789 UnaryExprOrTypeTrait ExprKind,
4796 if (ExprKind == UETT_VectorElements)
4799 if (ExprKind == UETT_VecStep)
4801 if (ExprKind == UETT_PtrAuthTypeDiscriminator)
4817 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4818 ExprKind == UETT_OpenMPRequiredSimdAlign) {
4823 DiagCompat(OpLoc, diag_compat::alignof_incomplete_array);
4824 ExprType =
Context.getBaseElementType(ExprType);
4833 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4838 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4842 if (ExprKind == UETT_CountOf) {
4846 Diag(OpLoc, diag::err_countof_arg_not_array_type) << ExprType;
4853 if (
Context.getTargetInfo().getTriple().isWasm() &&
4855 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4869 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4873 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4874 DC = LSI->CallOperator;
4875 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4876 DC = CRSI->TheCapturedDecl;
4877 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4893 UnaryExprOrTypeTrait ExprKind,
4900 if (!
T->isDependentType() &&
4909 (ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4919 ExprKind, TInfo,
Context.getSizeType(), OpLoc, R.getEnd());
4924 UnaryExprOrTypeTrait ExprKind) {
4935 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4937 }
else if (ExprKind == UETT_VecStep) {
4939 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4943 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4945 }
else if (ExprKind == UETT_VectorElements || ExprKind == UETT_SizeOf ||
4946 ExprKind == UETT_CountOf) {
4953 if ((ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4967 UnaryExprOrTypeTrait ExprKind,
bool IsType,
4988 UETT_AlignOf, KWName);
5001 if (
V.get()->isTypeDependent())
5013 return CT->getElementType();
5016 if (
V.get()->getType()->isArithmeticType())
5017 return V.get()->getType();
5022 if (PR.
get() !=
V.get()) {
5028 S.
Diag(Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
5029 << (IsReal ?
"__real" :
"__imag");
5040 default: llvm_unreachable(
"Unknown unary op!");
5041 case tok::plusplus: Opc = UO_PostInc;
break;
5042 case tok::minusminus: Opc = UO_PostDec;
break;
5061 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
5064 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
5071 auto *BaseNoParens =
Base->IgnoreParens();
5072 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
5073 return MSProp->getPropertyDecl()->getType()->isArrayType();
5094 if (RTy->isIntegralOrUnscopedEnumerationType()) {
5096 Result = PT->getPointeeType();
5098 Result = AT->getElementType();
5101 Result = PT->getPointeeType();
5103 Result = AT->getElementType();
5117 if (AS->isOMPArraySection())
5133 base = result.
get();
5142 auto CheckAndReportCommaError = [&](
Expr *E) {
5143 if (ArgExprs.size() > 1 ||
5145 Diag(E->getExprLoc(), diag::err_matrix_subscript_comma)
5156 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
5162 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
5163 if (matSubscriptE && matSubscriptE->isIncomplete()) {
5164 if (CheckAndReportCommaError(ArgExprs.front()))
5168 matSubscriptE->getRowIdx(),
5169 ArgExprs.front(), rbLoc);
5177 CheckInvalidBuiltinCountedByRef(base,
5185 bool IsMSPropertySubscript =
false;
5188 if (!IsMSPropertySubscript) {
5192 base = result.
get();
5198 if (CheckAndReportCommaError(ArgExprs.front()))
5206 Expr *idx = ArgExprs[0];
5215 if (ArgExprs.size() == 1 &&
5216 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
5220 ArgExprs[0] = result.
get();
5232 base, ArgExprs.front(),
5245 if (IsMSPropertySubscript) {
5246 if (ArgExprs.size() > 1) {
5248 diag::err_ms_property_subscript_expects_single_arg);
5274 Diag(base->
getExprLoc(), diag::err_ovl_builtin_subscript_expects_single_arg)
5282 ArgExprs[0]->getType()->isRecordType())))) {
5300 return InitSeq.
Perform(*
this, Entity, Kind, E);
5314 RowIdx = RowR.
get();
5324 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5325 bool IsColumnIdx) ->
Expr * {
5333 if (std::optional<llvm::APSInt> Idx =
5335 if ((*Idx < 0 || *Idx >=
Dim)) {
5337 << IsColumnIdx <<
Dim;
5344 "should be able to convert any integer type to size type");
5345 return ConvExpr.
get();
5349 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5354 Context.getExtVectorType(MTy->getElementType(), MTy->getNumColumns());
5370 RowIdx = RowR.
get();
5374 Base, RowIdx, ColumnIdx,
Context.IncompleteMatrixIdxTy, RBLoc);
5385 ColumnIdx = ColumnR.
get();
5390 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5391 bool IsColumnIdx) ->
Expr * {
5399 if (std::optional<llvm::APSInt> Idx =
5401 if ((*Idx < 0 || *Idx >=
Dim)) {
5403 << IsColumnIdx <<
Dim;
5410 "should be able to convert any integer type to size type");
5411 return ConvExpr.
get();
5415 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5416 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5417 if (!RowIdx || !ColumnIdx)
5421 MTy->getElementType(), RBLoc);
5424void Sema::CheckAddressOfNoDeref(
const Expr *E) {
5431 while ((
Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5432 StrippedExpr =
Member->getBase()->IgnoreParenImpCasts();
5434 LastRecord.PossibleDerefs.erase(StrippedExpr);
5448 if (ResultTy->
hasAttr(attr::NoDeref)) {
5449 LastRecord.PossibleDerefs.insert(E);
5456 QualType BaseTy =
Base->getType();
5461 const MemberExpr *
Member =
nullptr;
5462 while ((
Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5466 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5467 if (
Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5468 LastRecord.PossibleDerefs.insert(E);
5484 for (
auto *Op : {LHSExp, RHSExp}) {
5485 Op = Op->IgnoreImplicit();
5486 if (Op->getType()->isArrayType() && !Op->isLValue())
5509 Expr *BaseExpr, *IndexExpr;
5527 if (!
LangOpts.isSubscriptPointerArithmetic())
5543 if (!
LangOpts.isSubscriptPointerArithmetic()) {
5544 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5557 }
else if (
Hexagon().isHLXVectorType(LHSTy)) {
5572 LHSExp = Materialized.
get();
5579 Qualifiers BaseQuals = BaseType.getQualifiers();
5581 Qualifiers Combined = BaseQuals + MemberQuals;
5582 if (Combined != MemberQuals)
5583 ResultType =
Context.getQualifiedType(ResultType, Combined);
5593 CK_ArrayToPointerDecay).
get();
5599 }
else if (RHSTy->isArrayType()) {
5604 CK_ArrayToPointerDecay).
get();
5611 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5616 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5622 std::optional<llvm::APSInt> IntegerContantExpr =
5624 if (!IntegerContantExpr.has_value() ||
5625 IntegerContantExpr.value().isNegative())
5641 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5652 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5665 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5669 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5670 DC = LSI->CallOperator;
5671 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
5672 DC = CRSI->TheCapturedDecl;
5673 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
5691 bool SkipImmediateInvocations) {
5692 if (Param->hasUnparsedDefaultArg()) {
5693 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
5697 Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
5698 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
5699 Param->setInvalidDecl();
5703 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
5706 diag::note_default_argument_declared_here);
5710 if (Param->hasUninstantiatedDefaultArg()) {
5711 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
5716 Expr *
Init = RewrittenInit ? RewrittenInit : Param->getInit();
5717 assert(
Init &&
"default argument but no initializer?");
5726 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(
Init)) {
5729 Cleanup.setExprNeedsCleanups(InitWithCleanup->cleanupsHaveSideEffects());
5733 assert(!InitWithCleanup->getNumObjects() &&
5734 "default argument expression has capturing blocks?");
5747 SkipImmediateInvocations;
5821 bool Changed =
false;
5822 for (
unsigned I = 0, N = E->
capture_size(); I != N; ++I) {
5831 assert(!VD->isParameterPack() &&
5832 "unexpanded init-capture pack while rebuilding a default member "
5847 Expr *NewInitE = NewInit.
get();
5849 C->getLocation(),
C->getCaptureKind() ==
LCK_ByRef,
5851 VD->getIdentifier(), VD->getInitStyle() !=
VarDecl::CInit, NewInitE);
5852 if (CaptureType.
isNull() || !NewInitE)
5855 Changed |= NewInitE !=
Init;
5856 CaptureInits[I] = NewInitE;
5871 return SemaRef.MaybeBindToTemporary(Lambda);
5894 if (!
SemaRef.CurrentInstantiationScope ||
5906 assert(Param->hasDefaultArg() &&
"can't build nonexistent default arg");
5910 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5911 InitializationContext =
5913 if (!InitializationContext.has_value())
5914 InitializationContext.emplace(CallLoc, Param,
CurContext);
5916 if (!
Init && !Param->hasUnparsedDefaultArg()) {
5931 if (Param->hasUninstantiatedDefaultArg()) {
5940 if (!NestedDefaultChecking)
5941 V.TraverseDecl(Param);
5945 if (
V.HasImmediateCalls ||
5946 (NeedRebuild && isa_and_present<ExprWithCleanups>(Param->getInit()))) {
5947 if (
V.HasImmediateCalls)
5957 Res = Immediate.TransformInitializer(Param->getInit(),
5971 CallLoc, FD, Param,
Init,
5972 NestedDefaultChecking))
5980 Init, InitializationContext->Context);
5990 ClassPattern->
lookup(Field->getDeclName());
5991 auto Rng = llvm::make_filter_range(
6004 bool NestedDefaultChecking,
6008 if (!
Field->getInClassInitializer() &&
6012 FieldDecl *Pattern =
6014 assert(Pattern &&
"We must have set the Pattern!");
6021 Expr *InClassInit =
Field->getInClassInitializer();
6037 RecordDecl *OutermostClass = ParentRD->getOuterLexicalRecordContext();
6038 Diag(Loc, diag::err_default_member_initializer_not_yet_parsed)
6039 << OutermostClass <<
Field;
6041 diag::note_default_member_initializer_not_yet_parsed);
6044 Field->setInvalidDecl();
6057 if (!NestedDefaultChecking)
6058 V.TraverseDecl(Field);
6068 Expr *
Init = InClassInit;
6070 (
V.HasImmediateCalls || (NeedRebuild && ContainsAnyTemporaries))) {
6074 NestedDefaultChecking;
6080 EnsureImmediateInvocationInDefaultArgs
Immediate(*
this);
6083 Res =
Immediate.TransformInitializer(InClassInit,
6089 Field->setInvalidDecl();
6095 if (!NestedDefaultChecking)
6104 assert(Field->hasInClassInitializer());
6132 NestedDefaultChecking,
false);
6133 if (
Init.isInvalid())
6137 if (
Init.isInvalid()) {
6138 Field->setInvalidDecl();
6143 Context, InitContext->Loc, Field, InitContext->Context,
6144 Init.get() == Field->getInClassInitializer() ?
nullptr :
Init.get());
6150 assert(Field->hasInClassInitializer());
6182 Loc, Field, MemberEntity, NestedDefaultChecking,
true);
6183 if (
Init.isInvalid())
6193 Context, InitContext->Loc, Field, InitContext->Context,
6194 Init.get() == Field->getInClassInitializer() ?
nullptr :
Init.get());
6201 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
6203 else if (Fn && Fn->getType()->isBlockPointerType())
6207 if (
Method->isInstance())
6209 }
else if (Fn && Fn->getType() ==
Context.BoundMemberTy)
6222 FunctionName(FuncName) {}
6224 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
6233 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
6234 return std::make_unique<FunctionCallCCC>(*
this);
6238 const IdentifierInfo *
const FunctionName;
6254 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
6255 if (Corrected.isOverloaded()) {
6265 ND = Best->FoundDecl;
6266 Corrected.setCorrectionDecl(ND);
6272 ND = ND->getUnderlyingDecl();
6287 Fn = Fn->IgnoreParens();
6289 auto *UO = dyn_cast<UnaryOperator>(Fn);
6290 if (!UO || UO->getOpcode() != clang::UO_AddrOf)
6292 if (
auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
6293 return DRE->hasQualifier();
6295 if (
auto *OVL = dyn_cast<OverloadExpr>(UO->getSubExpr()->IgnoreParens()))
6296 return bool(OVL->getQualifier());
6306 bool IsExecConfig) {
6314 if (
Context.BuiltinInfo.hasCustomTypechecking(ID) &&
6315 !(
Context.getLangOpts().HLSL && FDecl->
hasAttr<BuiltinAliasAttr>()))
6322 bool HasExplicitObjectParameter =
6324 unsigned ExplicitObjectParameterOffset = HasExplicitObjectParameter ? 1 : 0;
6328 unsigned FnKind = Fn->getType()->isBlockPointerType()
6335 if (Args.size() < NumParams) {
6336 if (Args.size() < MinArgs) {
6341 ? diag::err_typecheck_call_too_few_args_suggest
6342 : diag::err_typecheck_call_too_few_args_at_least_suggest;
6345 << FnKind << MinArgs - ExplicitObjectParameterOffset
6346 <<
static_cast<unsigned>(Args.size()) -
6347 ExplicitObjectParameterOffset
6349 }
else if (MinArgs - ExplicitObjectParameterOffset == 1 && FDecl &&
6354 ? diag::err_typecheck_call_too_few_args_one
6355 : diag::err_typecheck_call_too_few_args_at_least_one)
6356 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6357 << HasExplicitObjectParameter << Fn->getSourceRange();
6360 ? diag::err_typecheck_call_too_few_args
6361 : diag::err_typecheck_call_too_few_args_at_least)
6362 << FnKind << MinArgs - ExplicitObjectParameterOffset
6363 <<
static_cast<unsigned>(Args.size()) -
6364 ExplicitObjectParameterOffset
6365 << HasExplicitObjectParameter << Fn->getSourceRange();
6368 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6376 assert((
Call->getNumArgs() == NumParams) &&
6377 "We should have reserved space for the default arguments before!");
6382 if (Args.size() > NumParams) {
6388 ? diag::err_typecheck_call_too_many_args_suggest
6389 : diag::err_typecheck_call_too_many_args_at_most_suggest;
6392 << FnKind << NumParams - ExplicitObjectParameterOffset
6393 <<
static_cast<unsigned>(Args.size()) -
6394 ExplicitObjectParameterOffset
6396 }
else if (NumParams - ExplicitObjectParameterOffset == 1 && FDecl &&
6399 Diag(Args[NumParams]->getBeginLoc(),
6400 MinArgs == NumParams
6401 ? diag::err_typecheck_call_too_many_args_one
6402 : diag::err_typecheck_call_too_many_args_at_most_one)
6403 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6404 <<
static_cast<unsigned>(Args.size()) -
6405 ExplicitObjectParameterOffset
6406 << HasExplicitObjectParameter << Fn->getSourceRange()
6408 Args.back()->getEndLoc());
6410 Diag(Args[NumParams]->getBeginLoc(),
6411 MinArgs == NumParams
6412 ? diag::err_typecheck_call_too_many_args
6413 : diag::err_typecheck_call_too_many_args_at_most)
6414 << FnKind << NumParams - ExplicitObjectParameterOffset
6415 <<
static_cast<unsigned>(Args.size()) -
6416 ExplicitObjectParameterOffset
6417 << HasExplicitObjectParameter << Fn->getSourceRange()
6419 Args.back()->getEndLoc());
6422 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6427 Call->shrinkNumArgs(NumParams);
6438 unsigned TotalNumArgs = AllArgs.size();
6439 for (
unsigned i = 0; i < TotalNumArgs; ++i)
6440 Call->setArg(i, AllArgs[i]);
6442 Call->computeDependence();
6451 bool IsListInitialization) {
6456 for (
unsigned i = FirstParam; i < NumParams; i++) {
6461 if (ArgIx < Args.size()) {
6462 Arg = Args[ArgIx++];
6465 diag::err_call_incomplete_argument, Arg))
6469 bool CFAudited =
false;
6471 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6472 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6475 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6476 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6482 BE->getBlockDecl()->setDoesNotEscape();
6503 if (
const auto *OBT = Arg->
getType()->
getAs<OverflowBehaviorType>();
6506 OBT->isUnsignedIntegerOrEnumerationType() && OBT->isWrapKind();
6508 isPedantic ? diag::warn_obt_discarded_at_function_boundary_pedantic
6509 : diag::warn_obt_discarded_at_function_boundary)
6510 << Arg->
getType() << ProtoArgType;
6514 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
6520 assert(Param &&
"can't use default arguments without a known callee");
6532 CheckArrayAccess(Arg);
6537 AllArgs.push_back(Arg);
6546 for (
Expr *A : Args.slice(ArgIx)) {
6550 AllArgs.push_back(arg.get());
6555 for (
Expr *A : Args.slice(ArgIx)) {
6558 AllArgs.push_back(Arg.
get());
6563 for (
Expr *A : Args.slice(ArgIx))
6564 CheckArrayAccess(A);
6572 TL = DTL.getOriginalLoc();
6575 << ATL.getLocalSourceRange();
6581 const Expr *ArgExpr) {
6586 QualType OrigTy = Param->getOriginalType();
6611 Diag(CallLoc, diag::warn_static_array_too_small)
6619 std::optional<CharUnits> ArgSize =
6621 std::optional<CharUnits> ParmSize =
6623 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6624 Diag(CallLoc, diag::warn_static_array_too_small)
6626 << (unsigned)ParmSize->getQuantity() << 1;
6640 if (!placeholder)
return false;
6642 switch (placeholder->
getKind()) {
6644#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6645 case BuiltinType::Id:
6646#include "clang/Basic/OpenCLImageTypes.def"
6647#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6648 case BuiltinType::Id:
6649#include "clang/Basic/OpenCLExtensionTypes.def"
6652#define SVE_TYPE(Name, Id, SingletonId) \
6653 case BuiltinType::Id:
6654#include "clang/Basic/AArch64ACLETypes.def"
6655#define PPC_VECTOR_TYPE(Name, Id, Size) \
6656 case BuiltinType::Id:
6657#include "clang/Basic/PPCTypes.def"
6658#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6659#include "clang/Basic/RISCVVTypes.def"
6660#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6661#include "clang/Basic/WebAssemblyReferenceTypes.def"
6662#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
6663#include "clang/Basic/AMDGPUTypes.def"
6664#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6665#include "clang/Basic/HLSLIntangibleTypes.def"
6666#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6667#include "clang/Basic/HLSLPackedTypes.def"
6668#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6669#include "clang/Basic/SPIRVTypes.def"
6670#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6671#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6672#include "clang/AST/BuiltinTypes.def"
6675 case BuiltinType::UnresolvedTemplate:
6678 case BuiltinType::Overload:
6683 case BuiltinType::ARCUnbridgedCast:
6687 case BuiltinType::PseudoObject:
6692 case BuiltinType::UnknownAny:
6696 case BuiltinType::BoundMember:
6697 case BuiltinType::BuiltinFn:
6698 case BuiltinType::IncompleteMatrixIdx:
6699 case BuiltinType::ArraySection:
6700 case BuiltinType::OMPArrayShaping:
6701 case BuiltinType::OMPIterator:
6705 llvm_unreachable(
"bad builtin type kind");
6711 bool hasInvalid =
false;
6712 for (
size_t i = 0, e = args.size(); i != e; i++) {
6715 if (result.
isInvalid()) hasInvalid =
true;
6716 else args[i] = result.
get();
6740 if (!Context.BuiltinInfo.hasPtrArgsOrResult(FDecl->
getBuiltinID()) || !FT ||
6744 bool NeedsNewDecl =
false;
6764 if (!ParamType->isPointerType() ||
6765 ParamType->getPointeeType().hasAddressSpace() ||
6766 !ArgType->isPointerType() ||
6767 !ArgType->getPointeeType().hasAddressSpace() ||
6769 OverloadParams.push_back(ParamType);
6774 NeedsNewDecl =
true;
6775 LangAS AS = ArgType->getPointeeType().getAddressSpace();
6777 PointeeType = Context.getAddrSpaceQualType(PointeeType, AS);
6778 OverloadParams.push_back(Context.getPointerType(PointeeType));
6788 OverloadParams, EPI);
6798 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6805 Params.push_back(Parm);
6807 OverloadDecl->setParams(Params);
6811 if (FDecl->
hasAttr<CUDAHostAttr>())
6812 OverloadDecl->
addAttr(CUDAHostAttr::CreateImplicit(Context));
6813 if (FDecl->
hasAttr<CUDADeviceAttr>())
6814 OverloadDecl->
addAttr(CUDADeviceAttr::CreateImplicit(Context));
6817 return OverloadDecl;
6828 !Callee->isVariadic())
6830 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6833 if (
const EnableIfAttr *
Attr =
6834 S.
CheckEnableIf(Callee, Fn->getBeginLoc(), ArgExprs,
true)) {
6835 S.
Diag(Fn->getBeginLoc(),
6837 ? diag::err_ovl_no_viable_member_function_in_call
6838 : diag::err_ovl_no_viable_function_in_call)
6839 << Callee << Callee->getSourceRange();
6840 S.
Diag(Callee->getLocation(),
6841 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6842 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6850 const auto GetFunctionLevelDCIfCXXClass =
6858 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6859 return MD->
getParent()->getCanonicalDecl();
6862 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6863 return RD->getCanonicalDecl();
6870 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6871 if (!CurParentClass)
6878 assert(NamingClass &&
"Must have naming class even for implicit access");
6884 return CurParentClass == NamingClass ||
6933 if (
Call->getNumArgs() != 1)
6936 const Expr *E =
Call->getCallee()->IgnoreParenImpCasts();
6939 const DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(E);
6952 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
6955 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
6966 if (
Call.isInvalid())
6971 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn);
6972 ULE && ULE->hasExplicitTemplateArgs() && ULE->decls().empty()) {
6973 DiagCompat(Fn->getExprLoc(), diag_compat::adl_only_template_id)
6981 if (
const auto *CE = dyn_cast<CallExpr>(
Call.get()))
6987 if (
auto *DRE = dyn_cast<DeclRefExpr>(Fn->IgnoreParens());
6988 DRE &&
Call.get()->isValueDependent()) {
6998 if (
T->isDependentType())
7001 if (
T == Context.BoundMemberTy ||
T == Context.UnknownAnyTy ||
7002 T == Context.BuiltinFnTy ||
T == Context.OverloadTy ||
7003 T->isFunctionType() ||
T->isFunctionReferenceType() ||
7004 T->isMemberFunctionPointerType() ||
T->isFunctionPointerType() ||
7005 T->isBlockPointerType() ||
T->isRecordType() ||
T->isUndeducedType())
7014 Expr *ExecConfig,
bool IsExecConfig,
7015 bool AllowRecovery) {
7024 if (Fn->getType() ==
Context.BuiltinFnTy && ArgExprs.size() == 1 &&
7025 ArgExprs[0]->getType() ==
Context.BuiltinFnTy) {
7028 if (FD->getName() ==
"__builtin_amdgcn_is_invocable") {
7042 for (
const Expr *Arg : ArgExprs)
7043 if (CheckInvalidBuiltinCountedByRef(Arg,
7050 if (!ArgExprs.empty()) {
7052 Diag(Fn->getBeginLoc(), diag::err_pseudo_dtor_call_with_args)
7055 ArgExprs.back()->getEndLoc()));
7061 if (Fn->getType() ==
Context.PseudoObjectTy) {
7078 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->IgnoreParens()),
7086 Diag(LParenLoc, diag::err_typecheck_call_not_function)
7087 << Fn->getType() << Fn->getSourceRange());
7095 if (Fn->getType()->isRecordType())
7099 if (Fn->getType() ==
Context.UnknownAnyTy) {
7105 if (Fn->getType() ==
Context.BoundMemberTy) {
7107 RParenLoc, ExecConfig, IsExecConfig,
7113 if (Fn->getType() ==
Context.OverloadTy) {
7124 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
7127 RParenLoc, ExecConfig, IsExecConfig,
7133 if (Fn->getType() ==
Context.UnknownAnyTy) {
7139 Expr *NakedFn = Fn->IgnoreParens();
7141 bool CallingNDeclIndirectly =
false;
7143 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
7144 if (UnOp->getOpcode() == UO_AddrOf) {
7145 CallingNDeclIndirectly =
true;
7150 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
7151 NDecl = DRE->getDecl();
7155 const llvm::Triple &Triple =
Context.getTargetInfo().getTriple();
7156 if (Triple.isSPIRV() && Triple.getVendor() == llvm::Triple::AMD) {
7173 Fn->getValueKind(), FDecl,
nullptr, DRE->isNonOdrUse());
7176 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
7177 NDecl = ME->getMemberDecl();
7179 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
7181 FD,
true, Fn->getBeginLoc()))
7193 for (
unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
7196 if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
7197 !ArgExprs[Idx]->getType()->isPointerType())
7201 auto ArgTy = ArgExprs[Idx]->getType();
7202 auto ArgPtTy = ArgTy->getPointeeType();
7203 auto ArgAS = ArgPtTy.getAddressSpace();
7206 bool NeedImplicitASC =
7211 if (!NeedImplicitASC)
7215 if (ArgExprs[Idx]->isGLValue()) {
7219 ArgExprs[Idx] = Res.
get();
7223 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
7226 Context.getQualifiedType(ArgPtTy.getUnqualifiedType(), ArgPtQuals);
7229 ArgTy.getQualifiers());
7233 CK_AddressSpaceConversion)
7239 if (
Context.isDependenceAllowed() &&
7242 assert((Fn->containsErrors() ||
7243 llvm::any_of(ArgExprs,
7244 [](
clang::Expr *E) { return E->containsErrors(); })) &&
7245 "should only occur in error-recovery path.");
7250 ExecConfig, IsExecConfig);
7255 std::string Name =
Context.BuiltinInfo.getName(Id);
7261 assert(BuiltInDecl &&
"failed to find builtin declaration");
7265 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
7270 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
7290 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
7308 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
7309 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
7312 switch (BuiltinID) {
7313 case Builtin::BI__builtin_longjmp:
7314 case Builtin::BI__builtin_setjmp:
7315 case Builtin::BI__sigsetjmp:
7316 case Builtin::BI_longjmp:
7317 case Builtin::BI_setjmp:
7318 case Builtin::BIlongjmp:
7319 case Builtin::BIsetjmp:
7320 case Builtin::BIsiglongjmp:
7321 case Builtin::BIsigsetjmp:
7334 if (DeferParent->
Contains(*CurScope) &&
7336 Diag(Fn->getExprLoc(), diag::err_defer_invalid_sjlj) << FDecl;
7341 if (FDecl->
hasAttr<AnyX86InterruptAttr>()) {
7342 Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
7345 if (FDecl->
hasAttr<ARMInterruptAttr>()) {
7346 Diag(Fn->getExprLoc(), diag::err_arm_interrupt_called);
7355 if (Caller->hasAttr<AnyX86InterruptAttr>() ||
7356 Caller->hasAttr<AnyX86NoCallerSavedRegistersAttr>()) {
7358 bool HasNonGPRRegisters =
7360 if (HasNonGPRRegisters &&
7361 (!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())) {
7362 Diag(Fn->getExprLoc(), diag::warn_anyx86_excessive_regsave)
7363 << (Caller->hasAttr<AnyX86InterruptAttr>() ? 0 : 1);
7382 Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
7398 if (!BuiltinID || !
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7405 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7406 << Fn->getType() << Fn->getSourceRange());
7412 if (Fn->getType() ==
Context.UnknownAnyTy) {
7420 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7421 << Fn->getType() << Fn->getSourceRange());
7428 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
7429 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
7433 assert(UsesADL == ADLCallKind::NotADL &&
7434 "CUDAKernelCallExpr should not use ADL");
7445 if (BuiltinID &&
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7458 ExprResult E = CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7467 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
7468 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
7469 << FDecl << Fn->getSourceRange());
7475 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
7476 << Fn->getType() << Fn->getSourceRange());
7479 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
7480 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
7481 << FDecl << Fn->getSourceRange());
7495 if (
Context.getTargetInfo().getTriple().isWasm()) {
7496 for (
const Expr *Arg : Args) {
7497 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
7499 diag::err_wasm_table_as_function_parameter));
7523 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
7524 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
7525 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
7544 if (!Proto && !Args.empty() &&
7546 !
Diags.isIgnored(diag::warn_strict_uses_without_prototype,
7548 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
7549 << (FDecl !=
nullptr) << FDecl;
7552 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7553 Expr *Arg = Args[i];
7555 if (Proto && i < Proto->getNumParams()) {
7557 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
7575 diag::err_call_incomplete_argument, Arg))
7584 if (
Method->isImplicitObjectMemberFunction())
7585 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
7586 << Fn->getSourceRange() << 0);
7594 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7595 if (
const auto *RT =
7596 dyn_cast<RecordType>(Args[i]->
getType().getCanonicalType())) {
7597 if (RT->getDecl()->isOrContainsUnion())
7598 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
7609 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
7610 checkFortifiedLibcArgument(FDecl, TheCall);
7613 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7615 if (CheckPointerCall(NDecl, TheCall, Proto))
7618 if (CheckOtherCall(TheCall, Proto))
7628 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
7629 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
7634 TInfo =
Context.getTrivialTypeSourceInfo(literalType);
7646 LParenLoc,
Context.getBaseElementType(literalType),
7647 diag::err_array_incomplete_or_sizeless_type,
7670 ? diag::err_variable_object_no_init
7671 : diag::err_compound_literal_with_vla_type;
7678 diag::err_typecheck_decl_incomplete_type,
7693 LiteralExpr =
Result.get();
7700 bool IsFileScope = !
CurContext->isFunctionOrMethod() &&
7734 bool DeferImmediate =
7741 if (
Init->isTypeDependent() ||
Init->isValueDependent())
7743 if (DeferImmediate) {
7745 V.TraverseStmt(
Init);
7746 if (
V.HasImmediateCalls)
7751 ConstantExprKind::Initializer)) {
7752 Diag(
Init->getExprLoc(), diag::err_init_element_not_constant)
7753 <<
Init->getSourceBitField();
7761 if (
auto *ILE = dyn_cast<InitListExpr>(LiteralExpr)) {
7762 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7763 Expr *
Init = CheckElement(ILE->getInit(i));
7766 ILE->setInit(i,
Init);
7769 LiteralExpr = CheckElement(LiteralExpr);
7776 LiteralExpr, IsFileScope);
7782 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7799 Cleanup.setExprNeedsCleanups(
true);
7819 bool DiagnosedArrayDesignator =
false;
7820 bool DiagnosedNestedDesignator =
false;
7821 bool DiagnosedMixedDesignator =
false;
7825 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7826 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7828 FirstDesignator = DIE->getBeginLoc();
7833 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7834 DiagnosedNestedDesignator =
true;
7835 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7836 << DIE->getDesignatorsSourceRange();
7839 for (
auto &Desig : DIE->designators()) {
7840 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7841 DiagnosedArrayDesignator =
true;
7842 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7843 << Desig.getSourceRange();
7847 if (!DiagnosedMixedDesignator &&
7849 DiagnosedMixedDesignator =
true;
7850 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7851 << DIE->getSourceRange();
7852 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7853 << InitArgList[0]->getSourceRange();
7857 DiagnosedMixedDesignator =
true;
7859 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7860 << DIE->getSourceRange();
7861 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7862 << InitArgList[I]->getSourceRange();
7866 if (FirstDesignator.
isValid()) {
7870 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7872 ? diag::warn_cxx17_compat_designated_init
7873 : diag::ext_cxx_designated_init);
7875 Diag(FirstDesignator, diag::ext_designated_init);
7879 return BuildInitList(LBraceLoc, InitArgList, RBraceLoc,
true);
7890 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7891 if (InitArgList[I]->
getType()->isNonOverloadPlaceholderType()) {
7898 InitArgList[I] = result.
get();
7918 Cleanup.setExprNeedsCleanups(
true);
7927 if (
Context.hasSameUnqualifiedType(SrcTy, DestTy))
7932 llvm_unreachable(
"member pointer type in C");
7941 if (SrcAS != DestAS)
7942 return CK_AddressSpaceConversion;
7943 if (
Context.hasCvrSimilarType(SrcTy, DestTy))
7949 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7954 return CK_CPointerToObjCPointerCast;
7956 return CK_BlockPointerToObjCPointerCast;
7958 return CK_PointerToBoolean;
7960 return CK_PointerToIntegral;
7966 llvm_unreachable(
"illegal cast from pointer");
7968 llvm_unreachable(
"Should have returned before this");
7973 return CK_FixedPointCast;
7975 return CK_FixedPointToBoolean;
7977 return CK_FixedPointToIntegral;
7979 return CK_FixedPointToFloating;
7983 diag::err_unimplemented_conversion_with_fixed_point_type)
7985 return CK_IntegralCast;
7990 llvm_unreachable(
"illegal cast to pointer type");
7992 llvm_unreachable(
"Should have returned before this");
8002 return CK_NullToPointer;
8003 return CK_IntegralToPointer;
8005 return CK_IntegralToBoolean;
8007 return CK_IntegralCast;
8009 return CK_IntegralToFloating;
8014 return CK_IntegralRealToComplex;
8018 CK_IntegralToFloating);
8019 return CK_FloatingRealToComplex;
8021 llvm_unreachable(
"member pointer type in C");
8023 return CK_IntegralToFixedPoint;
8025 llvm_unreachable(
"Should have returned before this");
8030 return CK_FloatingCast;
8032 return CK_FloatingToBoolean;
8034 return CK_FloatingToIntegral;
8039 return CK_FloatingRealToComplex;
8043 CK_FloatingToIntegral);
8044 return CK_IntegralRealToComplex;
8048 llvm_unreachable(
"valid float->pointer cast?");
8050 llvm_unreachable(
"member pointer type in C");
8052 return CK_FloatingToFixedPoint;
8054 llvm_unreachable(
"Should have returned before this");
8059 return CK_FloatingComplexCast;
8061 return CK_FloatingComplexToIntegralComplex;
8064 if (
Context.hasSameType(ET, DestTy))
8065 return CK_FloatingComplexToReal;
8067 return CK_FloatingCast;
8070 return CK_FloatingComplexToBoolean;
8074 CK_FloatingComplexToReal);
8075 return CK_FloatingToIntegral;
8079 llvm_unreachable(
"valid complex float->pointer cast?");
8081 llvm_unreachable(
"member pointer type in C");
8084 diag::err_unimplemented_conversion_with_fixed_point_type)
8086 return CK_IntegralCast;
8088 llvm_unreachable(
"Should have returned before this");
8093 return CK_IntegralComplexToFloatingComplex;
8095 return CK_IntegralComplexCast;
8098 if (
Context.hasSameType(ET, DestTy))
8099 return CK_IntegralComplexToReal;
8101 return CK_IntegralCast;
8104 return CK_IntegralComplexToBoolean;
8108 CK_IntegralComplexToReal);
8109 return CK_IntegralToFloating;
8113 llvm_unreachable(
"valid complex int->pointer cast?");
8115 llvm_unreachable(
"member pointer type in C");
8118 diag::err_unimplemented_conversion_with_fixed_point_type)
8120 return CK_IntegralCast;
8122 llvm_unreachable(
"Should have returned before this");
8125 llvm_unreachable(
"Unhandled scalar cast");
8132 len = vecType->getNumElements();
8133 eltType = vecType->getElementType();
8140 if (!
type->isRealType())
return false;
8150 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
8154 const auto *VecTy = SecondType->getAs<
VectorType>();
8158 return ValidScalableConversion(srcTy, destTy) ||
8159 ValidScalableConversion(destTy, srcTy);
8169 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
8170 matSrcType->
getNumColumns() == matDestType->getNumColumns();
8176 uint64_t SrcLen, DestLen;
8184 auto IsX87LongDouble = [&](
QualType T) {
8185 return T->isRealFloatingType() && &
Context.getFloatTypeSemantics(
T) ==
8186 &llvm::APFloat::x87DoubleExtended();
8188 if (IsX87LongDouble(SrcEltTy) != IsX87LongDouble(DestEltTy))
8194 uint64_t SrcEltSize =
Context.getTypeSize(SrcEltTy);
8195 uint64_t DestEltSize =
Context.getTypeSize(DestEltTy);
8197 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
8202 "expected at least one type to be a vector here");
8204 bool IsSrcTyAltivec =
8220 return (IsSrcTyAltivec || IsDestTyAltivec);
8240 switch (
Context.getLangOpts().getLaxVectorConversions()) {
8247 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8252 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8269 return Diag(R.getBegin(), diag::err_invalid_conversion_between_matrixes)
8270 << DestTy << SrcTy << R;
8273 return Diag(R.getBegin(),
8274 diag::err_invalid_conversion_between_matrix_and_type)
8275 << SrcTy << DestTy << R;
8277 return Diag(R.getBegin(),
8278 diag::err_invalid_conversion_between_matrix_and_type)
8279 << DestTy << SrcTy << R;
8282 Kind = CK_MatrixCast;
8288 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
8292 return Diag(R.getBegin(),
8294 diag::err_invalid_conversion_between_vectors :
8295 diag::err_invalid_conversion_between_vector_and_integer)
8296 << VectorTy << Ty << R;
8298 return Diag(R.getBegin(),
8299 diag::err_invalid_conversion_between_vector_and_scalar)
8300 << VectorTy << Ty << R;
8309 if (DestElemTy == SplattedExpr->
getType())
8310 return SplattedExpr;
8323 CK_BooleanToSignedIntegral);
8324 SplattedExpr = CastExprRes.
get();
8325 CK = CK_IntegralToFloating;
8327 CK = CK_BooleanToSignedIntegral;
8334 SplattedExpr = CastExprRes.
get();
8342 if (DestElemTy == SplattedExpr->
getType())
8343 return SplattedExpr;
8352 SplattedExpr = CastExprRes.
get();
8370 !
Context.hasSameUnqualifiedType(DestTy, SrcTy) &&
8371 !
Context.areCompatibleVectorTypes(DestTy, SrcTy))) {
8372 Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors)
8373 << DestTy << SrcTy << R;
8384 return Diag(R.getBegin(),
8385 diag::err_invalid_conversion_between_vector_and_scalar)
8386 << DestTy << SrcTy << R;
8388 Kind = CK_VectorSplat;
8398 DestType == SourceType)
8406 if (!CE->getCalleeAllocSizeAttr())
8408 std::optional<llvm::APInt> AllocSize =
8409 CE->evaluateBytesReturnedByAllocSizeCall(S.
Context);
8412 if (!AllocSize || AllocSize->isZero())
8422 if (LhsSize && Size < LhsSize)
8424 << Size.getQuantity() << TargetType << LhsSize->getQuantity();
8432 "ActOnCastExpr(): missing type or expr");
8448 bool isVectorLiteral =
false;
8463 isVectorLiteral =
true;
8466 isVectorLiteral =
true;
8471 if (isVectorLiteral)
8501 "Expected paren or paren list expression");
8508 LiteralLParenLoc = PE->getLParenLoc();
8509 LiteralRParenLoc = PE->getRParenLoc();
8510 exprs = PE->getExprs();
8511 numExprs = PE->getNumExprs();
8538 if (numExprs == 1) {
8541 if (Literal.isInvalid())
8547 else if (numExprs < numElems) {
8549 diag::err_incorrect_number_of_vector_initializers);
8553 initExprs.append(exprs, exprs + numExprs);
8562 Diag(exprs[0]->getBeginLoc(), diag::err_typecheck_convert_incompatible)
8569 if (Literal.isInvalid())
8576 initExprs.append(exprs, exprs + numExprs);
8582 LiteralRParenLoc,
false);
8611 unsigned NumUserSpecifiedExprs,
8616 InitLoc, LParenLoc, RParenLoc);
8621 const Expr *NullExpr = LHSExpr;
8622 const Expr *NonPointerExpr = RHSExpr;
8629 NonPointerExpr = LHSExpr;
8651 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
8652 << NonPointerExpr->
getType() << DiagType
8664 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8672 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
8706 bool IsBlockPointer =
false;
8710 IsBlockPointer =
true;
8735 ResultAddrSpace = LAddrSpace;
8737 ResultAddrSpace = RAddrSpace;
8739 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8746 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
8751 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_ptrauth)
8768 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8770 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8778 lhptee, rhptee,
false,
false,
8781 if (CompositeTy.
isNull()) {
8798 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
8809 QualType ResultTy = [&, ResultAddrSpace]() {
8844 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
8897 bool IsIntFirstExpr) {
8899 !
Int.get()->getType()->isIntegerType())
8902 Expr *Expr1 = IsIntFirstExpr ?
Int.get() : PointerExpr;
8903 Expr *Expr2 = IsIntFirstExpr ? PointerExpr :
Int.get();
8905 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8909 CK_IntegralToPointer);
8943 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8949 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8955 if (LHSType == RHSType)
8965 (S, LHS, RHS, LHSType, RHSType,
false);
8999 llvm::raw_svector_ostream OS(Str);
9000 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
9001 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
9002 << CondTy << OS.str();
9023 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
9041 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
9042 << CondTy << VecResTy;
9047 QualType RVE = RV->getElementType();
9052 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
9053 << CondTy << VecResTy;
9079 bool IsBoolVecLang =
9107 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9108 QualType Ty = CE->getCallee()->getType();
9140 if (
Context.isDependenceAllowed() &&
9146 "should only occur in error-recovery path.");
9180 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
9189 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
9208 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9224 Context.hasSameUnqualifiedType(LHSTy, RHSTy))
9264 if (!compositeType.
isNull())
9265 return compositeType;
9295 if (
Context.hasSameType(LHSTy, RHSTy))
9296 return Context.getCommonSugaredType(LHSTy, RHSTy);
9299 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9318 Self.Diag(Loc,
Note) << ParenRange;
9338 const Expr **RHSExprs) {
9343 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
9344 E = MTE->getSubExpr();
9349 if (
const auto *OP = dyn_cast<BinaryOperator>(E);
9351 *Opcode = OP->getOpcode();
9352 *RHSExprs = OP->getRHS();
9357 if (
const auto *
Call = dyn_cast<CXXOperatorCallExpr>(E)) {
9358 if (
Call->getNumArgs() != 2)
9364 if (OO < OO_Plus || OO > OO_Arrow ||
9365 OO == OO_PlusPlus || OO == OO_MinusMinus)
9371 *RHSExprs =
Call->getArg(1);
9387 if (
const auto *OP = dyn_cast<BinaryOperator>(E))
9388 return OP->isComparisonOp() || OP->isLogicalOp();
9389 if (
const auto *OP = dyn_cast<UnaryOperator>(E))
9390 return OP->getOpcode() == UO_LNot;
9405 const Expr *RHSExpr) {
9407 const Expr *CondRHS;
9418 ? diag::warn_precedence_bitwise_conditional
9419 : diag::warn_precedence_conditional;
9421 Self.Diag(OpLoc, DiagID)
9427 Self.PDiag(diag::note_precedence_silence)
9432 Self.PDiag(diag::note_precedence_conditional_first),
9443 auto GetNullability = [](
QualType Ty) {
9454 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
9462 MergedKind = RHSKind;
9469 MergedKind = RHSKind;
9471 MergedKind = LHSKind;
9477 if (GetNullability(ResTy) == MergedKind)
9495 Expr *commonExpr =
nullptr;
9497 commonExpr = CondExpr;
9504 commonExpr = result.
get();
9518 commonExpr = commonRes.
get();
9528 commonExpr = MatExpr.
get();
9536 LHSExpr = CondExpr = opaqueValue;
9542 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
9544 VK, OK, QuestionLoc);
9552 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
9560 RHS.get(), result,
VK, OK);
9563 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
9564 ColonLoc, result,
VK, OK);
9568 unsigned FromAttributes = 0, ToAttributes = 0;
9569 if (
const auto *FromFn =
9570 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(FromType)))
9573 if (
const auto *ToFn =
9574 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(ToType)))
9578 return FromAttributes != ToAttributes;
9590 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9591 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9594 const Type *lhptee, *rhptee;
9596 std::tie(lhptee, lhq) =
9598 std::tie(rhptee, rhq) =
9669 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
9693 ltrans = LUnderlying;
9694 rtrans = RUnderlying;
9712 if (ltrans == rtrans) {
9728 std::tie(lhptee, lhq) =
9730 std::tie(rhptee, rhq) =
9742 return AssignConvertType::
9743 IncompatibleNestedPointerAddressSpaceMismatch;
9747 if (lhptee == rhptee)
9767 const auto *LFPT = dyn_cast<FunctionProtoType>(LFT);
9768 const auto *RFPT = dyn_cast<FunctionProtoType>(RFT);
9771 LFPT->getParamTypes(),
9772 RFPT->getExtProtoInfo());
9777 LFPT->getParamTypes(), EPI);
9782 EPI.
ExtInfo = LFT->getExtInfo();
9784 RFPT->getParamTypes(), EPI);
9803 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9804 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9825 if (LQuals != RQuals)
9854 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9855 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9903 return VT->getElementType().getCanonicalType() == ElementType;
9933 LHSType =
Context.getCanonicalType(LHSType).getUnqualifiedType();
9934 RHSType =
Context.getCanonicalType(RHSType).getUnqualifiedType();
9937 if (LHSType == RHSType) {
9944 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9945 if (AT->isGNUAutoType()) {
9951 auto OBTResult =
Context.checkOBTAssignmentCompatibility(LHSType, RHSType);
9952 switch (OBTResult) {
9957 Kind = LHSType->
isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast;
9970 !
Context.areCompatibleOverflowBehaviorTypes(LHSPointee, RHSPointee)) {
9978 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
9983 if (Kind != CK_NoOp && ConvertRHS)
9985 Kind = CK_NonAtomicToAtomic;
9997 if (
Context.typesAreCompatible(LHSTypeRef->getPointeeType(), RHSType)) {
9998 Kind = CK_LValueBitCast;
10009 if (LHSExtType->getNumElements() != RHSExtType->getNumElements())
10013 RHSExtType->getElementType()->isIntegerType()) {
10014 Kind = CK_IntegralToBoolean;
10018 if (
Context.getLangOpts().OpenCL &&
10019 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
10029 Kind = CK_VectorSplat;
10039 if (
Context.areCompatibleVectorTypes(LHSType, RHSType)) {
10051 if (
Context.getTargetInfo().getTriple().isPPC() &&
10053 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
10055 << RHSType << LHSType;
10069 if (
Context.getTargetInfo().getTriple().isPPC() &&
10074 << RHSType << LHSType;
10085 if (
ARM().areCompatibleSveTypes(LHSType, RHSType) ||
10086 ARM().areLaxCompatibleSveTypes(LHSType, RHSType)) {
10094 if (
Context.areCompatibleRVVTypes(LHSType, RHSType) ||
10095 Context.areLaxCompatibleRVVTypes(LHSType, RHSType)) {
10124 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
10127 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10129 if (AddrSpaceL != AddrSpaceR)
10130 Kind = CK_AddressSpaceConversion;
10131 else if (
Context.hasCvrSimilarType(RHSType, LHSType))
10141 Kind = CK_IntegralToPointer;
10149 if (LHSPointer->getPointeeType()->isVoidType()) {
10157 Context.getObjCClassRedefinitionType())) {
10168 if (LHSPointer->getPointeeType()->isVoidType()) {
10169 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10174 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10192 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10198 Kind = CK_IntegralToPointer;
10204 Kind = CK_AnyPointerToBlockPointerCast;
10210 if (RHSPT->getPointeeType()->isVoidType()) {
10211 Kind = CK_AnyPointerToBlockPointerCast;
10225 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10227 !
ObjC().CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
10234 Kind = CK_IntegralToPointer;
10241 Kind = CK_CPointerToObjCPointerCast;
10251 Context.getObjCClassRedefinitionType())) {
10263 Kind = CK_BlockPointerToObjCPointerCast;
10275 Kind = CK_NullToPointer;
10282 if (LHSType ==
Context.BoolTy) {
10283 Kind = CK_PointerToBoolean;
10289 Kind = CK_PointerToIntegral;
10299 if (LHSType ==
Context.BoolTy) {
10300 Kind = CK_PointerToBoolean;
10306 Kind = CK_PointerToIntegral;
10315 if (
Context.typesAreCompatible(LHSType, RHSType)) {
10322 Kind = CK_IntToOCLSampler;
10356 const RecordType *UT =
ArgType->getAsUnionType();
10361 if (!UD->
hasAttr<TransparentUnionAttr>())
10367 for (
auto *it : UD->
fields()) {
10368 if (it->getType()->isPointerType()) {
10407 bool DiagnoseCFAudited,
10411 assert((ConvertRHS || !
Diagnose) &&
"can't indicate whether we diagnosed");
10417 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
10421 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
10422 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
10424 diag::warn_noderef_to_dereferenceable_pointer)
10443 AllowedExplicit::None,
10455 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10456 !
ObjC().CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
10478 RHS.
get(), LHSType,
false, DAP))
10487 if (!
Context.hasSameUnqualifiedType(RHSType, LHSType)) {
10616 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10626 ObjC().CheckConversionToObjCLiteral(LHSType, E,
Diagnose))) {
10646struct OriginalOperand {
10647 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
10648 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
10649 Op = MTE->getSubExpr();
10650 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
10651 Op = BTE->getSubExpr();
10652 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
10653 Orig = ICE->getSubExprAsWritten();
10654 Conversion = ICE->getConversionFunction();
10658 QualType
getType()
const {
return Orig->getType(); }
10661 NamedDecl *Conversion;
10667 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
10669 Diag(Loc, diag::err_typecheck_invalid_operands)
10670 << OrigLHS.getType() << OrigRHS.getType()
10675 if (OrigLHS.Conversion) {
10676 Diag(OrigLHS.Conversion->getLocation(),
10677 diag::note_typecheck_invalid_operands_converted)
10680 if (OrigRHS.Conversion) {
10682 diag::note_typecheck_invalid_operands_converted)
10697 if (!(LHSNatVec && RHSNatVec)) {
10699 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
10700 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10702 <<
Vector->getSourceRange();
10706 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10729 unsigned &DiagID) {
10735 scalarCast = CK_IntegralToBoolean;
10740 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10745 scalarCast = CK_IntegralCast;
10750 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10753 scalarCast = CK_FloatingCast;
10756 scalarCast = CK_IntegralToFloating;
10765 if (scalarCast != CK_NoOp)
10776 assert(VecTy &&
"Expression E must be a vector");
10781 VecTy->getVectorKind());
10785 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10786 if (ICE->getSubExpr()->getType() == NewVecTy)
10787 return ICE->getSubExpr();
10789 auto Cast = ElementType->isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
10801 QualType IntTy =
Int->get()->getType().getUnqualifiedType();
10807 bool CstInt =
Int->get()->EvaluateAsInt(EVResult, S.
Context);
10816 unsigned NumBits = IntSigned
10818 :
Result.getActiveBits())
10819 :
Result.getActiveBits();
10826 return (IntSigned != OtherIntSigned &&
10832 return (Order < 0);
10839 if (
Int->get()->containsErrors())
10842 QualType IntTy =
Int->get()->getType().getUnqualifiedType();
10847 bool CstInt =
Int->get()->EvaluateAsInt(EVResult, S.
Context);
10859 llvm::APFloat::rmTowardZero);
10862 bool Ignored =
false;
10863 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
10865 if (
Result != ConvertBack)
10871 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
10873 if (Bits > FloatPrec)
10886 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
10887 QualType VectorTy =
Vector->get()->getType().getUnqualifiedType();
10892 "ExtVectorTypes should not be handled here!");
10893 VectorEltTy = VT->getElementType();
10898 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
10924 ScalarCast = CK_IntegralCast;
10928 ScalarCast = CK_FloatingToIntegral;
10936 llvm::APFloat
Result(0.0);
10942 bool CstScalar = Scalar->get()->isValueDependent() ||
10945 if (!CstScalar && Order < 0)
10951 bool Truncated =
false;
10953 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10958 ScalarCast = CK_FloatingCast;
10963 ScalarCast = CK_IntegralToFloating;
10970 if (ScalarCast != CK_NoOp)
10978 bool AllowBothBool,
10979 bool AllowBoolConversions,
10980 bool AllowBoolOperation) {
10981 if (!IsCompAssign) {
10997 assert(LHSVecType || RHSVecType);
11005 (RHSVecType && RHSVecType->getElementType()->isMFloat8Type()))
11010 if (!AllowBothBool && LHSVecType &&
11016 if (!AllowBoolOperation &&
11021 if (
Context.hasSameType(LHSType, RHSType))
11022 return Context.getCommonSugaredType(LHSType, RHSType);
11025 if (LHSVecType && RHSVecType &&
11026 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
11040 if (AllowBoolConversions && LHSVecType && RHSVecType &&
11043 Context.getTypeSize(RHSVecType->getElementType()))) {
11050 if (!IsCompAssign &&
11053 RHSVecType->getElementType()->isIntegerType()) {
11062 unsigned &SVEorRVV) {
11079 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
11080 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
11081 Diag(Loc, diag::err_typecheck_sve_rvv_ambiguous)
11082 << SVEorRVV << LHSType << RHSType;
11089 unsigned &SVEorRVV) {
11094 if (FirstVecType && SecondVecType) {
11097 SecondVecType->getVectorKind() ==
11108 if (SecondVecType &&
11121 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
11122 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
11123 Diag(Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
11124 << SVEorRVV << LHSType << RHSType;
11130 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
11145 LHSType, RHSVecType->getElementType(),
11158 QualType VecType = LHSVecType ? LHSType : RHSType;
11159 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
11160 QualType OtherType = LHSVecType ? RHSType : LHSType;
11161 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
11163 if (
Context.getTargetInfo().getTriple().isPPC() &&
11165 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
11166 Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
11170 if (!IsCompAssign) {
11189 if ((!RHSVecType && !RHSType->
isRealType()) ||
11191 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11192 << LHSType << RHSType
11204 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
11215 QualType Scalar = LHSVecType ? RHSType : LHSType;
11217 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
11219 diag::err_typecheck_vector_not_convertable_implict_truncation)
11220 << ScalarOrVector << Scalar <<
Vector;
11227 << LHSType << RHSType
11236 if (!IsCompAssign) {
11251 unsigned DiagID = diag::err_typecheck_invalid_operands;
11253 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
11254 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
11260 if (
Context.hasSameType(LHSType, RHSType))
11275 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11282 Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
11283 Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
11284 Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
11293 bool ScalarOrVector =
11296 Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
11297 << ScalarOrVector << Scalar <<
Vector;
11329 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
11341 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
11342 << LHSNull << NonNullType
11354 QualType ElementType = CT->getElementType().getCanonicalType();
11355 bool IsComplexRangePromoted = S.
getLangOpts().getComplexRange() ==
11357 if (!ElementType->isFloatingType() || !IsComplexRangePromoted)
11362 const llvm::fltSemantics &ElementTypeSemantics =
11364 const llvm::fltSemantics &HigherElementTypeSemantics =
11367 if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
11368 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
11375 if (
Type == HigherElementType) {
11387 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
11388 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
11391 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
11392 RUE->getKind() != UETT_SizeOf)
11399 if (RUE->isArgumentType())
11400 RHSTy = RUE->getArgumentType().getNonReferenceType();
11402 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
11409 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11410 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11411 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
11415 QualType ArrayElemTy = ArrayTy->getElementType();
11421 S.
Diag(Loc, diag::warn_division_sizeof_array)
11423 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11424 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11425 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
11429 S.
Diag(Loc, diag::note_precedence_silence) << RHS;
11442 S.
PDiag(diag::warn_remainder_division_by_zero)
11451 const Expr *LHSExpr = LHS.
get();
11452 const Expr *RHSExpr = RHS.
get();
11457 if (!LHSIsScoped && !RHSIsScoped)
11469 ->getDefinitionOrSelf()
11470 ->getIntegerType();
11471 std::string InsertionString =
"static_cast<" + IntType.getAsString() +
">(";
11472 S.
Diag(BeginLoc, diag::note_no_implicit_conversion_for_scoped_enum)
11477 DiagnosticHelper(LHSExpr, LHSType);
11480 DiagnosticHelper(RHSExpr, RHSType);
11487 bool IsCompAssign = Opc == BO_MulAssign || Opc == BO_DivAssign;
11488 bool IsDiv = Opc == BO_Div || Opc == BO_DivAssign;
11580 if (compType.
isNull() ||
11585 IsCompAssign ? BO_RemAssign : BO_Rem);
11596 ? diag::err_typecheck_pointer_arith_void_type
11597 : diag::ext_gnu_void_ptr)
11606 ? diag::err_typecheck_pointer_arith_void_type
11607 : diag::ext_gnu_void_ptr)
11608 << 0 <<
Pointer->getSourceRange();
11619 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
11620 <<
Pointer->getSourceRange();
11622 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
11639 S.
PDiag(diag::warn_pointer_sub_null_ptr)
11641 <<
Pointer->getSourceRange());
11650 ? diag::err_typecheck_pointer_arith_function_type
11651 : diag::ext_gnu_ptr_func_arith)
11663 assert(
Pointer->getType()->isAnyPointerType());
11665 ? diag::err_typecheck_pointer_arith_function_type
11666 : diag::ext_gnu_ptr_func_arith)
11667 << 0 <<
Pointer->getType()->getPointeeType()
11669 <<
Pointer->getSourceRange();
11677 QualType ResType = Operand->getType();
11679 ResType = ResAtomicType->getValueType();
11685 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
11686 Operand->getSourceRange());
11699 QualType ResType = Operand->getType();
11701 ResType = ResAtomicType->getValueType();
11733 if (!isLHSPointer && !isRHSPointer)
return true;
11735 QualType LHSPointeeTy, RHSPointeeTy;
11740 if (isLHSPointer && isRHSPointer) {
11744 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
11752 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
11753 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
11754 if (isLHSVoidPtr || isRHSVoidPtr) {
11762 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
11763 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
11764 if (isLHSFuncPtr || isRHSFuncPtr) {
11786 Expr* IndexExpr = RHSExpr;
11789 IndexExpr = LHSExpr;
11792 bool IsStringPlusInt = StrExpr &&
11798 Self.Diag(OpLoc, diag::warn_string_plus_int)
11802 if (IndexExpr == RHSExpr) {
11804 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11809 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11815 const Expr *StringRefExpr = LHSExpr;
11820 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
11821 StringRefExpr = RHSExpr;
11824 if (!CharExpr || !StringRefExpr)
11844 Self.Diag(OpLoc, diag::warn_string_plus_char)
11845 << DiagRange << Ctx.
CharTy;
11847 Self.Diag(OpLoc, diag::warn_string_plus_char)
11848 << DiagRange << CharExpr->
getType();
11854 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11859 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11868 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
11886 if (CompLHSTy) *CompLHSTy = compType;
11895 *CompLHSTy = compType;
11904 *CompLHSTy = compType;
11915 if (Opc == BO_Add) {
11922 if (CompLHSTy) *CompLHSTy = compType;
11936 std::swap(PExp, IExp);
11949 if (!IExp->getType()->isIntegerType())
11958 (!IExp->isValueDependent() &&
11959 (!IExp->EvaluateAsInt(KnownVal,
Context) ||
11963 Context, BO_Add, PExp, IExp);
11977 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
11983 CheckArrayAccess(PExp, IExp);
11989 if (
Context.isPromotableIntegerType(LHSTy))
11990 LHSTy =
Context.getPromotedIntegerType(LHSTy);
11992 *CompLHSTy = LHSTy;
12003 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
12004 if (CAT->isZeroSize())
12006 }
else if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
12007 if (
const Expr *Bound = VAT->getSizeExpr())
12008 if (std::optional<llvm::APSInt> Size =
12009 Bound->getIntegerConstantExpr(Ctx))
12013 T = AT->getElementType();
12032 if (CompLHSTy) *CompLHSTy = compType;
12041 *CompLHSTy = compType;
12050 *CompLHSTy = compType;
12064 if (CompLHSTy) *CompLHSTy = compType;
12081 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
12107 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
12110 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
12121 if (!
Context.hasSameUnqualifiedType(lpointee, rpointee)) {
12126 if (!
Context.typesAreCompatible(
12127 Context.getCanonicalType(lpointee).getUnqualifiedType(),
12128 Context.getCanonicalType(rpointee).getUnqualifiedType())) {
12144 if (LAddrSpace != RAddrSpace) {
12151 if (LAddrSpace != ResultAddrSpace) {
12158 if (RAddrSpace != ResultAddrSpace) {
12184 Diag(Loc, diag::warn_sub_ptr_zero_size_types)
12188 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
12189 return Context.getPointerDiffType();
12199 if (
const EnumType *ET =
T->getAsCanonical<EnumType>())
12200 return ET->getDecl()->isScoped();
12212 if (Opc == BO_Shr &&
12221 llvm::APSInt Right = RHSResult.
Val.
getInt();
12223 if (Right.isNegative()) {
12225 S.
PDiag(diag::warn_shift_negative)
12236 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
12238 if (Right.uge(LeftSize)) {
12240 S.
PDiag(diag::warn_shift_gt_typewidth)
12260 llvm::APSInt Left = LHSResult.
Val.
getInt();
12271 if (Left.isNegative()) {
12273 S.
PDiag(diag::warn_shift_lhs_negative)
12278 llvm::APInt ResultBits =
12279 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
12280 if (ResultBits.ule(LeftSize))
12282 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
12288 Result.toString(HexResult, 16,
false,
true);
12294 if (ResultBits - 1 == LeftSize) {
12295 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
12296 << HexResult << LHSType
12301 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
12302 << HexResult.str() <<
Result.getSignificantBits() << LHSType
12314 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
12320 if (!IsCompAssign) {
12342 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12349 if (!LHSEleType->isIntegerType()) {
12350 S.
Diag(Loc, diag::err_typecheck_expect_int)
12355 if (!RHSEleType->isIntegerType()) {
12356 S.
Diag(Loc, diag::err_typecheck_expect_int)
12365 if (LHSEleType != RHSEleType) {
12367 LHSEleType = RHSEleType;
12373 }
else if (RHSVecTy) {
12378 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12386 if (LHSBT != RHSBT &&
12388 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
12405 bool IsCompAssign) {
12406 if (!IsCompAssign) {
12429 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
12430 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
12431 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12436 if (!LHSEleType->isIntegerType()) {
12437 S.
Diag(Loc, diag::err_typecheck_expect_int)
12442 if (!RHSEleType->isIntegerType()) {
12443 S.
Diag(Loc, diag::err_typecheck_expect_int)
12451 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12461 if (LHSEleType != RHSEleType) {
12463 LHSEleType = RHSEleType;
12465 const llvm::ElementCount VecSize =
12474 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12480 const llvm::ElementCount VecSize =
12482 if (LHSEleType != RHSEleType) {
12484 RHSEleType = LHSEleType;
12497 bool IsCompAssign) {
12531 if (IsCompAssign) LHS = OldLHS;
12559 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
12560 : diag::ext_typecheck_comparison_of_distinct_pointers)
12600 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
12601 : diag::ext_typecheck_comparison_of_fptr_to_void)
12608 case Stmt::ObjCArrayLiteralClass:
12609 case Stmt::ObjCDictionaryLiteralClass:
12610 case Stmt::ObjCStringLiteralClass:
12611 case Stmt::ObjCBoxedExprClass:
12655 QualType T = Method->parameters()[0]->getType();
12656 if (!
T->isObjCObjectPointerType())
12659 QualType R = Method->getReturnType();
12660 if (!R->isScalarType())
12672 Literal = LHS.
get();
12675 Literal = RHS.
get();
12691 llvm_unreachable(
"Unknown Objective-C object literal kind");
12695 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
12696 << Literal->getSourceRange();
12698 S.
Diag(Loc, diag::warn_objc_literal_comparison)
12699 << LiteralKind << Literal->getSourceRange();
12708 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
12721 if (!UO || UO->
getOpcode() != UO_LNot)
return;
12731 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
12733 << Loc << IsBitwiseOp;
12760 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
12762 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
12763 if (Mem->isImplicitAccess())
12764 D = Mem->getMemberDecl();
12779 return std::nullopt;
12787 std::swap(LHS, RHS);
12791 std::swap(LHS, RHS);
12795 return std::nullopt;
12798 auto *BO = dyn_cast<BinaryOperator>(LHS);
12799 if (!BO || BO->getOpcode() != BO_Add)
12800 return std::nullopt;
12804 Other = BO->getRHS();
12806 Other = BO->getLHS();
12808 return std::nullopt;
12810 if (!
Other->getType()->isUnsignedIntegerType())
12811 return std::nullopt;
12813 return Opc == BO_GE;
12867 auto IsDeprArrayComparionIgnored =
12870 ? diag::warn_array_comparison_cxx26
12871 : !S.
getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored
12872 ? diag::warn_array_comparison
12873 : diag::warn_depr_array_comparison;
12899 Result = AlwaysConstant;
12903 S.
PDiag(diag::warn_comparison_always)
12918 Result = AlwaysConstant;
12922 S.
PDiag(diag::warn_comparison_always)
12925 }
else if (std::optional<bool> Res =
12928 S.
PDiag(diag::warn_comparison_always)
12930 << (*Res ? AlwaysTrue : AlwaysFalse));
12941 Expr *LiteralString =
nullptr;
12942 Expr *LiteralStringStripped =
nullptr;
12946 LiteralString = LHS;
12947 LiteralStringStripped = LHSStripped;
12952 LiteralString = RHS;
12953 LiteralStringStripped = RHSStripped;
12956 if (LiteralString) {
12958 S.
PDiag(diag::warn_stringcompare)
12971 llvm_unreachable(
"unhandled cast kind");
12973 case CK_UserDefinedConversion:
12975 case CK_LValueToRValue:
12977 case CK_ArrayToPointerDecay:
12979 case CK_FunctionToPointerDecay:
12981 case CK_IntegralCast:
12983 case CK_FloatingCast:
12985 case CK_IntegralToFloating:
12986 case CK_FloatingToIntegral:
12988 case CK_IntegralComplexCast:
12989 case CK_FloatingComplexCast:
12990 case CK_FloatingComplexToIntegralComplex:
12991 case CK_IntegralComplexToFloatingComplex:
12993 case CK_FloatingComplexToReal:
12994 case CK_FloatingRealToComplex:
12995 case CK_IntegralComplexToReal:
12996 case CK_IntegralRealToComplex:
12998 case CK_HLSLArrayRValue:
13011 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
13038 << 0 << FromType << ToType;
13043 llvm_unreachable(
"unhandled case in switch");
13070 if (NumEnumArgs == 1) {
13072 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
13078 if (NumEnumArgs == 2) {
13087 assert(IntType->isArithmeticType());
13097 LHSType = RHSType = IntType;
13106 if (
Type.isNull()) {
13112 std::optional<ComparisonCategoryType> CCT =
13124 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
13142 if (
Type.isNull()) {
13163 int NullValue =
PP.isMacroDefined(
"NULL") ? 0 : 1;
13168 if (
const auto *
CL = dyn_cast<CharacterLiteral>(E.
get())) {
13169 if (
CL->getValue() == 0)
13173 NullValue ?
"NULL" :
"(void *)0");
13174 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
13181 NullValue ?
"NULL" :
"(void *)0");
13191 bool IsThreeWay = Opc == BO_Cmp;
13192 bool IsOrdered = IsRelational || IsThreeWay;
13203 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
13260 auto computeResultTy = [&]() {
13269 std::optional<ComparisonCategoryType> CCT =
13274 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
13278 Diag(Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
13279 << (LHSIsNull ? LHS.
get()->getSourceRange()
13292 return computeResultTy();
13295 if (!IsOrdered && LHSIsNull != RHSIsNull) {
13296 bool IsEquality = Opc == BO_EQ;
13308 bool IsError = Opc == BO_Cmp;
13310 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
13312 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
13313 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
13342 return computeResultTy();
13358 (IsOrdered ? 2 : 1) &&
13363 return computeResultTy();
13377 if (IsRelational) {
13382 Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
13388 }
else if (!IsRelational &&
13392 && !LHSIsNull && !RHSIsNull)
13399 if (LCanPointeeTy != RCanPointeeTy) {
13405 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
13406 << LHSType << RHSType << 0
13412 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
13418 bool RHSHasCFIUncheckedCallee = RFn && RFn->getCFIUncheckedCalleeAttr();
13419 bool ChangingCFIUncheckedCallee =
13420 LHSHasCFIUncheckedCallee != RHSHasCFIUncheckedCallee;
13422 if (LHSIsNull && !RHSIsNull)
13424 else if (!ChangingCFIUncheckedCallee)
13427 return computeResultTy();
13439 if (!IsOrdered && LHSIsNull && RHSIsNull) {
13442 return computeResultTy();
13446 return computeResultTy();
13457 return computeResultTy();
13461 return computeResultTy();
13470 return computeResultTy();
13475 return computeResultTy();
13479 if (IsRelational &&
13490 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
13491 if (CTSD->isInStdNamespace() &&
13492 llvm::StringSwitch<bool>(CTSD->getName())
13493 .Cases({
"less",
"less_equal",
"greater",
"greater_equal"},
true)
13499 return computeResultTy();
13512 return computeResultTy();
13522 if (!LHSIsNull && !RHSIsNull &&
13523 !
Context.typesAreCompatible(lpointee, rpointee)) {
13524 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13529 return computeResultTy();
13536 if (!LHSIsNull && !RHSIsNull) {
13541 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13545 if (LHSIsNull && !RHSIsNull)
13548 : CK_AnyPointerToBlockPointerCast);
13552 : CK_AnyPointerToBlockPointerCast);
13553 return computeResultTy();
13562 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
13564 if (!LPtrToVoid && !RPtrToVoid &&
13565 !
Context.typesAreCompatible(LHSType, RHSType)) {
13572 if (LHSIsNull && !RHSIsNull) {
13578 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13588 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13590 return computeResultTy();
13594 if (!
Context.areComparableObjCPointerTypes(LHSType, RHSType))
13600 if (LHSIsNull && !RHSIsNull)
13604 return computeResultTy();
13610 CK_BlockPointerToObjCPointerCast);
13611 return computeResultTy();
13612 }
else if (!IsOrdered &&
13616 CK_BlockPointerToObjCPointerCast);
13617 return computeResultTy();
13622 unsigned DiagID = 0;
13623 bool isError =
false;
13632 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
13633 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
13636 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
13638 }
else if (IsOrdered)
13639 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
13641 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
13653 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13656 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13657 return computeResultTy();
13661 if (!IsOrdered && RHSIsNull
13664 return computeResultTy();
13666 if (!IsOrdered && LHSIsNull
13669 return computeResultTy();
13672 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
13674 return computeResultTy();
13678 return computeResultTy();
13681 if (LHSIsNull && RHSType->
isQueueT()) {
13683 return computeResultTy();
13686 if (LHSType->
isQueueT() && RHSIsNull) {
13688 return computeResultTy();
13716 return Context.getExtVectorType(
13717 Context.getBitIntType(
false, BIT->getNumBits()),
13740 return Context.getVectorType(
13741 Context.getBitIntType(
false, BIT->getNumBits()),
13750 const auto TypeSize =
Context.getTypeSize(ETy);
13752 const QualType IntTy =
Context.getIntTypeForBitwidth(TypeSize,
true);
13753 const llvm::ElementCount VecSize =
Context.getBuiltinVectorTypeInfo(VTy).EC;
13754 return Context.getScalableVectorType(IntTy, VecSize.getKnownMinValue());
13760 if (Opc == BO_Cmp) {
13761 Diag(Loc, diag::err_three_way_vector_comparison);
13789 return Context.getLogicalOperationType();
13791 Diag(Loc, diag::warn_deprecated_altivec_src_compat);
13797 return Context.getLogicalOperationType();
13820 assert(
getLangOpts().
HLSL &&
"matrix comparisons are only supported in HLSL");
13821 assert(Opc != BO_Cmp &&
"three-way comparisons are not supported in HLSL");
13842 return Context.getConstantMatrixType(
Context.BoolTy, MT->getNumRows(),
13843 MT->getNumColumns());
13850 if (Opc == BO_Cmp) {
13851 Diag(Loc, diag::err_three_way_vector_comparison);
13879 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
13880 RHSBuiltinTy->isSVEBool())
13899 bool Negative =
false;
13900 bool ExplicitPlus =
false;
13901 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
13902 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
13908 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
13910 if (Opc != UO_Minus && Opc != UO_Plus)
13912 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
13915 Negative = (Opc == UO_Minus);
13916 ExplicitPlus = !Negative;
13922 const llvm::APInt &LeftSideValue = LHSInt->getValue();
13923 llvm::APInt RightSideValue = RHSInt->getValue();
13924 if (LeftSideValue != 2 && LeftSideValue != 10)
13927 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
13932 llvm::StringRef ExprStr =
13937 llvm::StringRef XorStr =
13940 if (XorStr ==
"xor")
13951 RightSideValue = -RightSideValue;
13952 RHSStr =
"-" + RHSStr;
13953 }
else if (ExplicitPlus) {
13954 RHSStr =
"+" + RHSStr;
13957 StringRef LHSStrRef = LHSStr;
13958 StringRef RHSStrRef = RHSStr;
13961 if (LHSStrRef.starts_with(
"0b") || LHSStrRef.starts_with(
"0B") ||
13962 RHSStrRef.starts_with(
"0b") || RHSStrRef.starts_with(
"0B") ||
13963 LHSStrRef.starts_with(
"0x") || LHSStrRef.starts_with(
"0X") ||
13964 RHSStrRef.starts_with(
"0x") || RHSStrRef.starts_with(
"0X") ||
13965 (LHSStrRef.size() > 1 && LHSStrRef.starts_with(
"0")) ||
13966 (RHSStrRef.size() > 1 && RHSStrRef.starts_with(
"0")) ||
13967 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
13972 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
13973 int64_t RightSideIntValue = RightSideValue.getSExtValue();
13974 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
13975 std::string SuggestedExpr =
"1 << " + RHSStr;
13976 bool Overflow =
false;
13977 llvm::APInt One = (LeftSideValue - 1);
13978 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
13980 if (RightSideIntValue < 64)
13981 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13982 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
13984 else if (RightSideIntValue == 64)
13985 S.
Diag(Loc, diag::warn_xor_used_as_pow)
13986 << ExprStr <<
toString(XorValue, 10,
true);
13990 S.
Diag(Loc, diag::warn_xor_used_as_pow_base_extra)
13991 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
13994 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
13997 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13998 << (
"0x2 ^ " + RHSStr) << SuggestXor;
13999 }
else if (LeftSideValue == 10) {
14000 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
14001 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
14002 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
14004 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
14005 << (
"0xA ^ " + RHSStr) << SuggestXor;
14021 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
14048 SemaRef.Diag(Loc, diag::err_matrix_logical_operations_supported_for_hlsl);
14064 bool IsCompAssign) {
14065 if (!IsCompAssign) {
14081 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
14083 if (
Context.hasSameType(LHSType, RHSType))
14084 return Context.getCommonSugaredType(LHSType, RHSType);
14090 if (LHSMatType && !RHSMatType) {
14098 if (!LHSMatType && RHSMatType) {
14110 bool IsCompAssign) {
14111 if (!IsCompAssign) {
14122 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
14124 if (LHSMatType && RHSMatType) {
14125 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
14128 if (
Context.hasSameType(LHSMatType, RHSMatType))
14129 return Context.getCommonSugaredType(
14133 QualType LHSELTy = LHSMatType->getElementType(),
14135 if (!
Context.hasSameType(LHSELTy, RHSELTy))
14138 return Context.getConstantMatrixType(
14139 Context.getCommonSugaredType(LHSELTy, RHSELTy),
14164 bool IsCompAssign =
14165 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
14174 LHS, RHS, Loc, IsCompAssign,
14177 LegalBoolVecOperator);
14206 ExprResult LHSResult = LHS, RHSResult = RHS;
14208 LHSResult, RHSResult, Loc,
14210 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
14212 LHS = LHSResult.
get();
14213 RHS = RHSResult.
get();
14238 bool EnumConstantInBoolContext =
false;
14240 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
14241 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
14242 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
14243 EnumConstantInBoolContext =
true;
14247 if (EnumConstantInBoolContext)
14248 Diag(Loc, diag::warn_enum_constant_in_bool_context);
14253 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
14254 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
14255 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
14256 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
14278 Diag(Loc, diag::warn_logical_instead_of_bitwise)
14281 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
14282 << (Opc == BO_LAnd ?
"&" :
"|")
14285 Opc == BO_LAnd ?
"&" :
"|");
14286 if (Opc == BO_LAnd)
14288 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
14296 if (!
Context.getLangOpts().CPlusPlus) {
14299 if (
Context.getLangOpts().OpenCL &&
14300 Context.getLangOpts().OpenCLVersion < 120) {
14355 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
14356 if (!ME)
return false;
14360 if (!
Base)
return false;
14361 return Base->getMethodDecl() !=
nullptr;
14385 assert(S.
getLangOpts().CPlusPlus &&
"BindingDecl outside of C++?");
14396 assert(Var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
14404 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
14446 bool DiagnosticEmitted =
false;
14450 bool IsDereference =
false;
14451 bool NextIsDereference =
false;
14455 IsDereference = NextIsDereference;
14458 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14459 NextIsDereference = ME->isArrow();
14460 const ValueDecl *VD = ME->getMemberDecl();
14461 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
14463 if (Field->isMutable()) {
14464 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
14469 if (!DiagnosticEmitted) {
14470 S.
Diag(Loc, diag::err_typecheck_assign_const)
14472 << Field->getType();
14473 DiagnosticEmitted =
true;
14476 <<
ConstMember <<
false << Field << Field->getType()
14477 << Field->getSourceRange();
14481 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
14482 if (VDecl->getType().isConstQualified()) {
14483 if (!DiagnosticEmitted) {
14484 S.
Diag(Loc, diag::err_typecheck_assign_const)
14486 << VDecl->getType();
14487 DiagnosticEmitted =
true;
14490 <<
ConstMember <<
true << VDecl << VDecl->getType()
14491 << VDecl->getSourceRange();
14498 dyn_cast<ArraySubscriptExpr>(E)) {
14502 dyn_cast<ExtVectorElementExpr>(E)) {
14509 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
14513 if (!DiagnosticEmitted) {
14514 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
14516 DiagnosticEmitted =
true;
14519 diag::note_typecheck_assign_const)
14523 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14525 if (
const ValueDecl *VD = DRE->getDecl()) {
14527 if (!DiagnosticEmitted) {
14528 S.
Diag(Loc, diag::err_typecheck_assign_const)
14530 DiagnosticEmitted =
true;
14532 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
14533 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
14538 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
14539 if (MD->isConst()) {
14540 if (!DiagnosticEmitted) {
14541 S.
Diag(Loc, diag::err_typecheck_assign_const_method)
14542 << ExprRange << MD;
14543 DiagnosticEmitted =
true;
14545 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const_method)
14546 << MD << MD->getSourceRange();
14552 if (DiagnosticEmitted)
14556 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
14566 const RecordType *Ty,
14569 bool &DiagnosticEmitted) {
14570 std::vector<const RecordType *> RecordTypeList;
14571 RecordTypeList.push_back(Ty);
14572 unsigned NextToCheckIndex = 0;
14575 while (RecordTypeList.size() > NextToCheckIndex) {
14576 bool IsNested = NextToCheckIndex > 0;
14577 for (
const FieldDecl *Field : RecordTypeList[NextToCheckIndex]
14579 ->getDefinitionOrSelf()
14582 QualType FieldTy = Field->getType();
14584 if (!DiagnosticEmitted) {
14585 S.
Diag(Loc, diag::err_typecheck_assign_const)
14587 << IsNested << Field;
14588 DiagnosticEmitted =
true;
14590 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
14592 << FieldTy << Field->getSourceRange();
14597 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
14598 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
14599 RecordTypeList.push_back(FieldRecTy);
14602 ++NextToCheckIndex;
14611 assert(Ty->
isRecordType() &&
"lvalue was not record?");
14614 bool DiagEmitted =
false;
14616 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
14619 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
14644 unsigned DiagID = 0;
14645 bool NeedType =
false;
14652 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
14654 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
14667 if (var->isARCPseudoStrong() &&
14668 (!var->getTypeSourceInfo() ||
14669 !var->getTypeSourceInfo()->getType().isConstQualified())) {
14675 ? diag::err_typecheck_arc_assign_self_class_method
14676 : diag::err_typecheck_arc_assign_self;
14679 }
else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
14681 DiagID = diag::err_typecheck_arc_assign_externally_retained;
14685 DiagID = diag::err_typecheck_arr_assign_enumeration;
14689 if (Loc != OrigLoc)
14715 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
14719 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
14723 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
14726 llvm_unreachable(
"did not take early return for MLV_Valid");
14730 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E)) {
14732 if (UnaryOp->getOpcode() == UO_Imag &&
14734 DiagID = diag::err_typecheck_lvalue_imag_not_modifiable_lvalue;
14740 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
14746 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
14748 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
14751 DiagID = diag::err_typecheck_duplicate_matrix_components_not_mlvalue;
14754 llvm_unreachable(
"readonly properties should be processed differently");
14756 DiagID = diag::err_readonly_message_assignment;
14759 DiagID = diag::err_no_subobject_property_setting;
14764 if (Loc != OrigLoc)
14786 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
14787 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
14795 if (LHSDecl != RHSDecl)
14800 if (RefTy->getPointeeType().isVolatileQualified())
14803 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
14813 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
14837 bool ShowFullyQualifiedAssigneeName =
false;
14840 Assignee = DR->getDecl();
14841 }
else if (
auto *ME = dyn_cast<MemberExpr>(LHSExpr->
IgnoreParenCasts())) {
14842 Assignee = ME->getMemberDecl();
14843 ShowFullyQualifiedAssigneeName =
true;
14848 ShowFullyQualifiedAssigneeName);
14857 Diag(Loc, diag::err_opencl_half_load_store) << 1
14864 Diag(Loc, diag::err_wasm_table_art) << 0;
14869 if (CompoundType.
isNull()) {
14880 ((
Context.isObjCNSObjectType(LHSType) &&
14882 (
Context.isObjCNSObjectType(RHSType) &&
14887 Diag(Loc, diag::err_objc_object_assignment) << LHSType;
14893 RHSCheck = ICE->getSubExpr();
14894 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
14895 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
14896 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
14902 UO->getSubExpr()->getBeginLoc().
isFileID()) {
14903 Diag(Loc, diag::warn_not_compound_assign)
14904 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
14905 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
14915 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
14931 if (!
Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
14954 if (CompoundType.
isNull()) {
14980 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
14981 if (CE->getCastKind() == CK_ToVoid) {
14987 CE->getSubExpr()->getType()->isDependentType()) {
14992 if (
const auto *CE = dyn_cast<CallExpr>(E))
14993 return CE->getCallReturnType(Context)->isVoidType();
15017 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
15018 if (BO->getOpcode() != BO_Comma)
15020 LHS = BO->getRHS();
15027 Diag(Loc, diag::warn_comma_operator);
15031 LangOpts.CPlusPlus ?
"static_cast<void>("
15063 diag::err_incomplete_type);
15084 ResType = ResAtomicType->getValueType();
15086 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
15096 : diag::warn_increment_bool)
15100 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
15118 S.
DiagCompat(OpLoc, diag_compat::increment_complex)
15135 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
15146 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
15147 << IsInc << ResType;
15179 case Stmt::DeclRefExprClass:
15181 case Stmt::MemberExprClass:
15189 case Stmt::ArraySubscriptExprClass: {
15194 if (ICE->getSubExpr()->getType()->isArrayType())
15199 case Stmt::UnaryOperatorClass: {
15211 case Stmt::ParenExprClass:
15213 case Stmt::ImplicitCastExprClass:
15217 case Stmt::CXXUuidofExprClass:
15227 AO_Vector_Element = 1,
15228 AO_Property_Expansion = 2,
15229 AO_Register_Variable = 3,
15230 AO_Matrix_Element = 4,
15248 return Diag(OpLoc, diag::err_parens_pointer_member_function)
15253 return Diag(OpLoc, diag::err_typecheck_addrof_dtor)
15254 << DRE->getSourceRange();
15256 if (DRE->getQualifier())
15260 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
15261 << DRE->getSourceRange();
15264 StringRef Qual = (MD->
getParent()->getName() +
"::").toStringRef(Str);
15265 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
15266 << DRE->getSourceRange()
15272 if (PTy->getKind() == BuiltinType::Overload) {
15276 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
15284 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15292 if (PTy->getKind() == BuiltinType::UnknownAny)
15295 if (PTy->getKind() == BuiltinType::BoundMember) {
15296 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15319 auto* VarRef = dyn_cast<DeclRefExpr>(op);
15320 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
15321 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
15329 if (uOp->getOpcode() == UO_Deref)
15332 return uOp->getSubExpr()->getType();
15339 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
15345 unsigned AddressOfError = AO_No_Error;
15349 Diag(OpLoc, IsError ? diag::err_typecheck_addrof_temporary
15350 : diag::ext_typecheck_addrof_temporary)
15365 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15383 auto ReturnOrParamTypeIsIncomplete = [&](
QualType T,
15388 diag::note_ptrauth_virtual_function_pointer_incomplete_arg_ret);
15389 Diag(RetArgTypeLoc,
15390 diag::note_ptrauth_virtual_function_incomplete_arg_ret_type)
15397 bool IsIncomplete =
15399 ReturnOrParamTypeIsIncomplete(
15402 IsIncomplete |= ReturnOrParamTypeIsIncomplete(PVD->getType(), OpLoc,
15403 PVD->getBeginLoc());
15409 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
15418 AddressOfError = AO_Property_Expansion;
15420 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
15424 }
else if (
const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
15425 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl()))
15431 AddressOfError = AO_Bit_Field;
15434 AddressOfError = AO_Vector_Element;
15437 AddressOfError = AO_Matrix_Element;
15441 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
15446 AddressOfError = AO_Register_Variable;
15449 AddressOfError = AO_Property_Expansion;
15462 if (
auto *DRE = dyn_cast<DeclRefExpr>(op);
15468 diag::err_cannot_form_pointer_to_member_of_reference_type)
15479 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
15487 llvm_unreachable(
"Unknown/unexpected decl type");
15490 if (AddressOfError != AO_No_Error) {
15507 if (
Context.getTargetInfo().getTriple().isWasm()) {
15510 Diag(OpLoc, diag::err_wasm_ca_reference)
15515 Diag(OpLoc, diag::err_wasm_table_pr)
15521 CheckAddressOfPackedMember(op);
15527 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
15533 const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
15536 if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
15537 if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
15540 FD->ModifiedNonNullParams.insert(Param);
15546 bool IsAfterAmp =
false) {
15550 Op = ConvResult.
get();
15562 Result = PT->getPointeeType();
15566 Result = OPT->getPointeeType();
15570 if (PR.
get() != Op)
15575 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
15580 if (
Result->isVoidType()) {
15586 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
15589 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
15596 S.
Diag(OpLoc, diag::err_typecheck_indirection_hlx_vectorpair_pointer)
15612 default: llvm_unreachable(
"Unknown binop!");
15613 case tok::periodstar: Opc = BO_PtrMemD;
break;
15614 case tok::arrowstar: Opc = BO_PtrMemI;
break;
15615 case tok::star: Opc = BO_Mul;
break;
15616 case tok::slash: Opc = BO_Div;
break;
15617 case tok::percent: Opc = BO_Rem;
break;
15618 case tok::plus: Opc = BO_Add;
break;
15619 case tok::minus: Opc = BO_Sub;
break;
15620 case tok::lessless: Opc = BO_Shl;
break;
15621 case tok::greatergreater: Opc = BO_Shr;
break;
15622 case tok::lessequal: Opc = BO_LE;
break;
15623 case tok::less: Opc = BO_LT;
break;
15624 case tok::greaterequal: Opc = BO_GE;
break;
15625 case tok::greater: Opc = BO_GT;
break;
15626 case tok::exclaimequal: Opc = BO_NE;
break;
15627 case tok::equalequal: Opc = BO_EQ;
break;
15628 case tok::spaceship: Opc = BO_Cmp;
break;
15629 case tok::amp: Opc = BO_And;
break;
15630 case tok::caret: Opc = BO_Xor;
break;
15631 case tok::pipe: Opc = BO_Or;
break;
15632 case tok::ampamp: Opc = BO_LAnd;
break;
15633 case tok::pipepipe: Opc = BO_LOr;
break;
15634 case tok::equal: Opc = BO_Assign;
break;
15635 case tok::starequal: Opc = BO_MulAssign;
break;
15636 case tok::slashequal: Opc = BO_DivAssign;
break;
15637 case tok::percentequal: Opc = BO_RemAssign;
break;
15638 case tok::plusequal: Opc = BO_AddAssign;
break;
15639 case tok::minusequal: Opc = BO_SubAssign;
break;
15640 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
15641 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
15642 case tok::ampequal: Opc = BO_AndAssign;
break;
15643 case tok::caretequal: Opc = BO_XorAssign;
break;
15644 case tok::pipeequal: Opc = BO_OrAssign;
break;
15645 case tok::comma: Opc = BO_Comma;
break;
15654 default: llvm_unreachable(
"Unknown unary op!");
15655 case tok::plusplus: Opc = UO_PreInc;
break;
15656 case tok::minusminus: Opc = UO_PreDec;
break;
15657 case tok::amp: Opc = UO_AddrOf;
break;
15658 case tok::star: Opc = UO_Deref;
break;
15659 case tok::plus: Opc = UO_Plus;
break;
15660 case tok::minus: Opc = UO_Minus;
break;
15661 case tok::tilde: Opc = UO_Not;
break;
15662 case tok::exclaim: Opc = UO_LNot;
break;
15663 case tok::kw___real: Opc = UO_Real;
break;
15664 case tok::kw___imag: Opc = UO_Imag;
break;
15665 case tok::kw___extension__: Opc = UO_Extension;
break;
15697 llvm::find_if(Parent->
fields(),
15699 return F->getDeclName() == Name;
15701 return (Field != Parent->
field_end()) ? *Field :
nullptr;
15716 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
15717 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
15718 if (!LHSDeclRef || !RHSDeclRef ||
15726 if (LHSDecl != RHSDecl)
15731 if (RefTy->getPointeeType().isVolatileQualified())
15734 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
15735 : diag::warn_self_assignment_overloaded)
15740 Diag << 1 << SelfAssignField
15753 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
15755 const Expr *RHS = R.get();
15758 ObjCPointerExpr = LHS;
15762 ObjCPointerExpr = RHS;
15771 unsigned Diag = diag::warn_objc_pointer_masking;
15780 if (SelArg0.starts_with(
"performSelector"))
15781 Diag = diag::warn_objc_pointer_masking_performSelector;
15798 assert((
isVector(ResultTy, Context.HalfTy) ||
15799 isVector(ResultTy, Context.ShortTy)) &&
15800 "Result must be a vector of half or short");
15803 "both operands expected to be a half vector");
15810 if (
isVector(ResultTy, Context.ShortTy))
15815 ResultTy,
VK, OK, OpLoc, FPFeatures,
15816 BinOpResTy, BinOpResTy);
15820 BinOpResTy,
VK, OK, OpLoc, FPFeatures);
15828 Expr *E1 =
nullptr) {
15829 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType)
15838 auto HasVectorOfHalfType = [&Ctx](
Expr *E) {
15848 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
15853 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
15858 Expr *RHSExpr,
bool ForFoldExpression) {
15872 if (
Init.isInvalid())
15874 RHSExpr =
Init.get();
15884 bool ConvertHalfVec =
false;
15886 if (!LHS.
isUsable() || !RHS.isUsable())
15896 if (BO_Assign == Opc)
15897 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
15925 if (!ResultTy.
isNull()) {
15942 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
15944 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
15945 if (VD->hasLocalStorage() &&
getCurScope()->isDeclScope(VD))
15946 BE->getBlockDecl()->setCanAvoidCopyToHeap();
15957 Opc == BO_PtrMemI);
15961 ConvertHalfVec =
true;
15968 ConvertHalfVec =
true;
15972 ConvertHalfVec =
true;
15983 ConvertHalfVec =
true;
15986 if (
const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
15987 !ForFoldExpression && BI && BI->isComparisonOp())
15988 Diag(OpLoc, diag::warn_consecutive_comparison)
15994 ConvertHalfVec =
true;
15998 ConvertHalfVec =
true;
16011 ConvertHalfVec =
true;
16016 ConvertHalfVec =
true;
16018 CompLHSTy = CompResultTy;
16025 CompLHSTy = CompResultTy;
16031 ConvertHalfVec =
true;
16038 ConvertHalfVec =
true;
16047 CompLHSTy = CompResultTy;
16058 CompLHSTy = CompResultTy;
16066 VK = RHS.get()->getValueKind();
16067 OK = RHS.get()->getObjectKind();
16079 (Opc == BO_Comma ||
isVector(RHS.get()->getType(),
Context.HalfTy) ==
16081 "both sides are half vectors or neither sides are");
16083 LHS.
get(), RHS.get());
16086 CheckArrayAccess(LHS.
get());
16087 CheckArrayAccess(RHS.get());
16091 &
Context.Idents.get(
"object_setClass"),
16097 "object_setClass(")
16110 if (CompResultTy.
isNull()) {
16111 if (ConvertHalfVec)
16131 if (ConvertHalfVec)
16136 Context, LHS.
get(), RHS.get(), Opc, ResultTy,
VK, OK, OpLoc,
16153 if (isLeftComp == isRightComp)
16158 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
16159 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
16160 if (isLeftBitwise || isRightBitwise)
16172 Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
16175 Self.PDiag(diag::note_precedence_silence) << OpStr,
16176 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
16178 Self.PDiag(diag::note_precedence_bitwise_first)
16193 Self.PDiag(diag::note_precedence_silence)
16202 if (Bop->getOpcode() == BO_LAnd) {
16207 }
else if (Bop->getOpcode() == BO_LOr) {
16208 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
16211 if (RBop->getOpcode() == BO_LAnd &&
16223 if (Bop->getOpcode() == BO_LAnd) {
16238 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
16239 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
16241 << Bop->getSourceRange() << OpLoc;
16243 S.
PDiag(diag::note_precedence_silence)
16244 << Bop->getOpcodeStr(),
16245 Bop->getSourceRange());
16251 Expr *SubExpr, StringRef Shift) {
16253 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
16254 StringRef Op = Bop->getOpcodeStr();
16255 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
16256 << Bop->getSourceRange() << OpLoc << Shift << Op;
16258 S.
PDiag(diag::note_precedence_silence) << Op,
16259 Bop->getSourceRange());
16275 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
16278 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
16280 << (Kind == OO_LessLess);
16282 S.
PDiag(diag::note_precedence_silence)
16283 << (Kind == OO_LessLess ?
"<<" :
">>"),
16286 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
16300 if ((Opc == BO_Or || Opc == BO_Xor) &&
16308 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
16314 || Opc == BO_Shr) {
16330 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
16331 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
16340 CheckInvalidBuiltinCountedByRef(LHSExpr, K);
16341 CheckInvalidBuiltinCountedByRef(RHSExpr, K);
16343 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
16349 if (OverOp !=
OO_None && OverOp != OO_Equal)
16398 Expr *RHSExpr,
bool ForFoldExpression) {
16399 if (!LHSExpr || !RHSExpr)
16411 if (pty->getKind() == BuiltinType::PseudoObject &&
16424 RHSExpr = resolvedRHS.
get();
16438 (pty->getKind() == BuiltinType::BoundMember ||
16439 pty->getKind() == BuiltinType::Overload)) {
16440 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
16441 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
16442 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
16443 return isa<FunctionTemplateDecl>(ND);
16445 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
16446 : OE->getNameLoc(),
16447 diag::err_template_kw_missing)
16448 << OE->getName().getAsIdentifierInfo();
16455 LHSExpr = LHS.
get();
16462 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
16469 ForFoldExpression);
16479 RHSExpr = resolvedRHS.
get();
16485 if (!
HLSL().CheckResourceBinOp(Opc, LHSExpr, RHSExpr, OpLoc))
16488 std::optional<ExprResult> ConvRHS =
16490 if (ConvRHS &&
Context.hasSameUnqualifiedType(
16491 LHSExpr->
getType(), ConvRHS->get()->getType())) {
16492 assert(!ConvRHS->isInvalid());
16493 RHSExpr = ConvRHS->get();
16499 bool CanOverloadBinOp =
16503 bool TypeDependent =
16507 if (CanOverloadBinOp && (TypeDependent || Overloadable))
16515 "Should only occur in error-recovery path.");
16521 Context, LHSExpr, RHSExpr, Opc,
16541 ResultType = RHSExpr->
getType();
16544 ResultType =
Context.DependentTy;
16557 if (
T.isNull() ||
T->isDependentType())
16573 bool CanOverflow =
false;
16575 bool ConvertHalfVec =
false;
16584 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16591 if (Opc == UO_AddrOf)
16592 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
16593 if (Opc == UO_Deref)
16594 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
16599 resultType =
Context.DependentTy;
16608 Opc == UO_PreInc || Opc == UO_PostInc,
16609 Opc == UO_PreInc || Opc == UO_PreDec);
16614 CheckAddressOfNoDeref(InputExpr);
16627 CanOverflow = Opc == UO_Minus &&
16640 if (ConvertHalfVec)
16647 (!
Context.getLangOpts().ZVector ||
16657 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16668 Diag(OpLoc, diag::ext_integer_complement_complex)
16676 if (!
T->isIntegerType())
16677 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16680 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16696 resultType =
Context.FloatTy;
16702 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16712 if (
Context.getLangOpts().CPlusPlus) {
16717 }
else if (
Context.getLangOpts().OpenCL &&
16718 Context.getLangOpts().OpenCLVersion < 120) {
16722 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16735 Input.
get(), resultType,
16740 if (
Context.getLangOpts().OpenCL &&
16741 Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
16745 if (!
T->isIntegerType())
16746 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16752 }
else if (
Context.getLangOpts().CPlusPlus &&
16756 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16762 }
else if (resultType ==
Context.AMDGPUFeaturePredicateTy) {
16763 resultType =
Context.getLogicalOperationType();
16767 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16773 resultType =
Context.getLogicalOperationType();
16801 "the co_await expression must be non-dependant before "
16802 "building operator co_await");
16813 if (Opc != UO_AddrOf && Opc != UO_Deref)
16814 CheckArrayAccess(Input.
get());
16820 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
16826 if (ConvertHalfVec)
16832 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
16833 if (!DRE->getQualifier())
16843 return Method->isImplicitObjectMemberFunction();
16849 if (!ULE->getQualifier())
16854 if (
Method->isImplicitObjectMemberFunction())
16875 if (pty->getKind() == BuiltinType::PseudoObject &&
16880 if (Opc == UO_Extension)
16885 if (Opc == UO_AddrOf &&
16886 (pty->getKind() == BuiltinType::Overload ||
16887 pty->getKind() == BuiltinType::UnknownAny ||
16888 pty->getKind() == BuiltinType::BoundMember))
16913 Expr *Input,
bool IsAfterAmp) {
16923 OpLoc, LabLoc, TheDecl,
Context.getPointerType(
Context.VoidTy));
16957 assert(!
Cleanup.exprNeedsCleanups() &&
16958 "cleanups within StmtExpr not correctly bound!");
16968 bool StmtExprMayBindToTemp =
false;
16970 if (
const auto *LastStmt = dyn_cast<ValueStmt>(Compound->
body_back())) {
16971 if (
const Expr *
Value = LastStmt->getExprStmt()) {
16972 StmtExprMayBindToTemp =
true;
16980 Expr *ResStmtExpr =
16982 if (StmtExprMayBindToTemp)
16984 return ResStmtExpr;
17007 auto *Cast = dyn_cast<ImplicitCastExpr>(E);
17008 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
17009 return Cast->getSubExpr();
17030 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
17031 << ArgTy << TypeRange);
17037 diag::err_offsetof_incomplete_type, TypeRange))
17040 bool DidWarnAboutNonPOD =
false;
17056 CurrentType =
Context.DependentTy;
17074 Exprs.push_back(Idx);
17086 CurrentType =
Context.DependentTy;
17092 diag::err_offsetof_incomplete_type))
17109 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
17111 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
17112 : diag::ext_offsetof_non_pod_type;
17115 Diag(BuiltinLoc, DiagID)
17118 DidWarnAboutNonPOD =
true;
17129 MemberDecl = IndirectMemberDecl->getAnonField();
17136 if (!R.isAmbiguous())
17137 Diag(BuiltinLoc, diag::err_no_member)
17154 if (IndirectMemberDecl)
17161 Context.getCanonicalTagType(Parent), Paths)) {
17163 Diag(D.
getEndLoc(), diag::err_offsetof_field_of_virtual_base)
17173 if (IndirectMemberDecl) {
17174 for (
auto *FI : IndirectMemberDecl->chain()) {
17186 Comps, Exprs, RParenLoc);
17210 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
17215 bool CondIsTrue =
false;
17217 resType =
Context.DependentTy;
17220 llvm::APSInt condEval(32);
17222 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
17225 CondExpr = CondICE.
get();
17226 CondIsTrue = condEval.getZExtValue();
17229 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
17231 resType = ActiveExpr->
getType();
17237 resType,
VK, OK, RPLoc, CondIsTrue);
17249 Decl *ManglingContextDecl;
17250 std::tie(MCtx, ManglingContextDecl) =
17254 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
17276 "block-id should have no identifier!");
17287 assert(
T->isFunctionType() &&
17288 "GetTypeForDeclarator made a non-function block signature");
17304 unsigned Size =
Result.getFullDataSize();
17305 Sig =
Context.CreateTypeSourceInfo(
Result.getType(), Size);
17316 QualType RetTy = Fn->getReturnType();
17326 if (RetTy !=
Context.DependentTy) {
17334 if (ExplicitSignature) {
17335 for (
unsigned I = 0, E = ExplicitSignature.
getNumParams(); I != E; ++I) {
17337 if (Param->getIdentifier() ==
nullptr && !Param->isImplicit() &&
17341 Diag(Param->getLocation(), diag::ext_parameter_name_omitted_c23);
17343 Params.push_back(Param);
17349 for (
const auto &I : Fn->param_types()) {
17352 Params.push_back(Param);
17357 if (!Params.empty()) {
17368 AI->setOwningFunction(CurBlock->
TheDecl);
17371 if (AI->getIdentifier()) {
17377 if (AI->isInvalidDecl())
17396 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
17401 assert(!
Cleanup.exprNeedsCleanups() &&
17402 "cleanups within block not correctly bound!");
17417 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
17425 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
17431 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
17452 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
17456 BlockTy =
Context.getBlockPointerType(BlockTy);
17460 !
PP.isCodeCompletionEnabled())
17465 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
17491 Expr *CopyExpr =
nullptr;
17518 if (!
Result.isInvalid() &&
17519 !
Result.get()->getType().isConstQualified()) {
17521 Result.get()->getType().withConst(),
17525 if (!
Result.isInvalid()) {
17535 if (!
Result.isInvalid() &&
17539 CopyExpr =
Result.get();
17546 Captures.push_back(NewCap);
17560 if (
Result->getBlockDecl()->hasCaptures()) {
17563 Cleanup.setExprNeedsCleanups(
true);
17567 for (
const auto &CI :
Result->getBlockDecl()->captures()) {
17568 const VarDecl *var = CI.getVariable();
17583 {Result},
Result->getType());
17597 Expr *OrigExpr = E;
17611 Context.getTargetInfo().getTriple().isNVPTX())
17638 "__builtin_zos_va_list must be an array type");
17643 VaListType = ZOSVaListType;
17652 VaListType =
Context.getArrayDecayedType(VaListType);
17664 if (
Init.isInvalid())
17680 diag::err_first_argument_to_va_arg_not_of_type_va_list)
17685 diag::err_second_parameter_to_va_arg_incomplete,
17691 diag::err_second_parameter_to_va_arg_abstract,
17698 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
17699 : diag::warn_second_parameter_to_va_arg_not_pod)
17706 PDiag(diag::warn_second_parameter_to_va_arg_array)
17739 UnderlyingType = ED->getIntegerType();
17740 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17753 ?
Context.getCorrespondingSignedType(UnderlyingType)
17754 :
Context.getCorrespondingUnsignedType(UnderlyingType);
17755 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17761 PromoteType =
Context.DoubleTy;
17762 if (!PromoteType.
isNull())
17764 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
17779 if (pw ==
Context.getTargetInfo().getIntWidth())
17781 else if (pw ==
Context.getTargetInfo().getLongWidth())
17783 else if (pw ==
Context.getTargetInfo().getLongLongWidth())
17786 llvm_unreachable(
"I don't know size of pointer!");
17803 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
17812 S.
Diag(Loc, diag::err_std_source_location_impl_not_found);
17820 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17824 unsigned Count = 0;
17826 StringRef Name = F->getName();
17828 if (Name ==
"_M_file_name") {
17829 if (F->getType() !=
17833 }
else if (Name ==
"_M_function_name") {
17834 if (F->getType() !=
17838 }
else if (Name ==
"_M_line") {
17839 if (!F->getType()->isIntegerType())
17842 }
else if (Name ==
"_M_column") {
17843 if (!F->getType()->isIntegerType())
17852 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17875 ResultTy =
Context.UnsignedIntTy;
17884 ResultTy =
Context.getPointerType(
17903 Data->BinaryData = BinaryData;
17907 Data->getDataElementCount());
17911 const Expr *SrcExpr) {
17920 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
17933 bool *Complained) {
17935 *Complained =
false;
17938 bool CheckInferredResultType =
false;
17940 unsigned DiagKind = 0;
17942 bool MayHaveConvFixit =
false;
17943 bool MayHaveFunctionDiff =
false;
17954 DiagKind = diag::warn_compatible_implicit_pointer_conv;
17958 DiagKind = diag::err_typecheck_convert_pointer_int;
17961 DiagKind = diag::ext_typecheck_convert_pointer_int;
17964 MayHaveConvFixit =
true;
17968 DiagKind = diag::err_typecheck_convert_int_pointer;
17971 DiagKind = diag::ext_typecheck_convert_int_pointer;
17974 MayHaveConvFixit =
true;
17978 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
17980 MayHaveConvFixit =
true;
17984 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
17987 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
17990 MayHaveConvFixit =
true;
17994 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
17996 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
17999 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
18003 if (CheckInferredResultType) {
18009 MayHaveConvFixit =
true;
18013 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
18016 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
18021 DiagKind = diag::err_typecheck_convert_pointer_void_func;
18024 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
18030 SrcType =
Context.getDecayedType(SrcType);
18037 DiagKind = diag::err_typecheck_incompatible_address_space;
18040 DiagKind = diag::err_typecheck_incompatible_ownership;
18043 DiagKind = diag::err_typecheck_incompatible_ptrauth;
18047 llvm_unreachable(
"unknown error case for discarding qualifiers!");
18052 SrcType =
Context.getArrayDecayedType(SrcType);
18054 DiagKind = diag::ext_typecheck_convert_discards_overflow_behavior;
18070 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
18073 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
18080 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
18082 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
18086 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
18090 DiagKind = diag::err_int_to_block_pointer;
18094 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
18101 for (
auto *srcProto : srcOPT->
quals()) {
18107 IFace = IFaceT->getDecl();
18112 for (
auto *dstProto : dstOPT->
quals()) {
18118 IFace = IFaceT->getDecl();
18121 DiagKind = diag::err_incompatible_qualified_id;
18124 DiagKind = diag::warn_incompatible_qualified_id;
18130 DiagKind = diag::err_incompatible_vectors;
18133 DiagKind = diag::warn_incompatible_vectors;
18137 DiagKind = diag::err_arc_weak_unavailable_assign;
18144 "Unexpected function type found in IncompatibleOBTKinds assignment");
18146 SrcType =
Context.getDecayedType(SrcType);
18148 auto getOBTKindName = [](
QualType Ty) -> StringRef {
18149 if (Ty->isPointerType())
18150 Ty = Ty->getPointeeType();
18151 if (
const auto *OBT = Ty->getAs<OverflowBehaviorType>()) {
18152 return OBT->getBehaviorKind() ==
18153 OverflowBehaviorType::OverflowBehaviorKind::Trap
18157 llvm_unreachable(
"OBT kind unhandled");
18160 Diag(Loc, diag::err_incompatible_obt_kinds_assignment)
18161 << DstType << SrcType << getOBTKindName(DstType)
18162 << getOBTKindName(SrcType);
18169 *Complained =
true;
18173 DiagKind = diag::err_typecheck_convert_incompatible;
18175 MayHaveConvFixit =
true;
18177 MayHaveFunctionDiff =
true;
18186 FirstType = DstType;
18187 SecondType = SrcType;
18197 FirstType = SrcType;
18198 SecondType = DstType;
18207 FDiag << FirstType << SecondType << ActionForDiag
18210 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
18211 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
18221 if (!ConvHints.
isNull()) {
18226 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
18228 if (MayHaveFunctionDiff)
18232 if ((DiagKind == diag::warn_incompatible_qualified_id ||
18233 DiagKind == diag::err_incompatible_qualified_id) &&
18235 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
18238 if (SecondType ==
Context.OverloadTy)
18242 if (CheckInferredResultType)
18250 *Complained =
true;
18261 return S.
Diag(Loc, diag::err_ice_not_integral)
18265 return S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus;
18280 IDDiagnoser(
unsigned DiagID)
18284 return S.
Diag(Loc, DiagID);
18286 } Diagnoser(DiagID);
18299 return S.
Diag(Loc, diag::ext_expr_not_ice) << S.
LangOpts.CPlusPlus;
18321 BaseDiagnoser(BaseDiagnoser) {}
18330 return S.
Diag(Loc, diag::err_ice_incomplete_type) <<
T;
18335 return S.
Diag(Loc, diag::err_ice_explicit_conversion) <<
T << ConvTy;
18346 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) <<
T;
18357 llvm_unreachable(
"conversion functions are permitted");
18359 } ConvertDiagnoser(Diagnoser);
18365 E = Converted.
get();
18386 E = RValueExpr.
get();
18406 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
18407 diag::note_invalid_subexpr_in_const_expr) {
18408 DiagLoc = Notes[0].first;
18431 EvalResult.
Diag = &Notes;
18450 if (!MSWarning.empty()) {
18454 for (
auto &Info : MSWarning)
18455 Diag(Info.first, Info.second);
18471 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
18472 diag::note_invalid_subexpr_in_const_expr) {
18473 DiagLoc = Notes[0].first;
18499 class TransformToPE :
public TreeTransform<TransformToPE> {
18503 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
18506 bool AlwaysRebuild() {
return true; }
18507 bool ReplacingOriginal() {
return true; }
18516 ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
18518 !SemaRef.isUnevaluatedContext())
18520 diag::err_invalid_non_static_member_use)
18523 return BaseTransform::TransformDeclRefExpr(E);
18527 ExprResult TransformUnaryOperator(UnaryOperator *E) {
18531 return BaseTransform::TransformUnaryOperator(E);
18539 return SkipLambdaBody(E, Body);
18546 "Should only transform unevaluated expressions");
18551 return TransformToPE(*this).TransformExpr(E);
18556 "Should only transform unevaluated expressions");
18560 return TransformToPE(*this).TransformType(TInfo);
18568 LambdaContextDecl, ExprContext);
18582 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
18585 Prev.InImmediateEscalatingFunctionContext;
18652 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
18653 if (E->getOpcode() == UO_Deref)
18654 return CheckPossibleDeref(S, E->getSubExpr());
18655 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
18656 return CheckPossibleDeref(S, E->getBase());
18657 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
18658 return CheckPossibleDeref(S, E->getBase());
18659 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
18662 if (
const auto *Ptr = Ty->
getAs<PointerType>())
18663 Inner =
Ptr->getPointeeType();
18665 Inner = Arr->getElementType();
18669 if (Inner->
hasAttr(attr::NoDeref))
18679 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
18686 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
18701 if (BO->getOpcode() == BO_Assign) {
18703 llvm::erase(LHSs, BO->getLHS());
18711 "Cannot mark an immediate escalating expression outside of an "
18712 "immediate escalating context");
18715 if (
auto *DeclRef =
18716 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18717 DeclRef->setIsImmediateEscalating(
true);
18718 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(E->
IgnoreImplicit())) {
18719 Ctr->setIsImmediateEscalating(
true);
18720 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreImplicit())) {
18721 DeclRef->setIsImmediateEscalating(
true);
18723 assert(
false &&
"expected an immediately escalating expression");
18726 FI->FoundImmediateEscalatingExpression =
true;
18741 if (
auto *DeclRef =
18742 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18751 auto CheckConstantExpressionAndKeepResult = [&]() {
18755 Eval,
getASTContext(), SProxy, ConstantExprKind::ImmediateInvocation);
18757 Cached = std::move(Eval.
Val);
18765 !CheckConstantExpressionAndKeepResult()) {
18770 if (
Cleanup.exprNeedsCleanups()) {
18787 Cleanup.cleanupsHaveSideEffects(), {});
18800 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
18808 Eval.
Diag = &Notes;
18813 ConstantExprKind::ImmediateInvocation);
18814 if (!
Result || !Notes.empty()) {
18817 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
18820 if (
auto *
Call = dyn_cast<CallExpr>(InnerExpr))
18822 else if (
auto *
Call = dyn_cast<CXXConstructExpr>(InnerExpr))
18823 FD =
Call->getConstructor();
18824 else if (
auto *Cast = dyn_cast<CastExpr>(InnerExpr))
18825 FD = dyn_cast_or_null<FunctionDecl>(Cast->getConversionFunction());
18828 "could not find an immediate function in this expression");
18835 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
18837 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
18841 for (
auto &
Note : Notes)
18853 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18857 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
18861 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
18863 auto It = std::find_if(CurrentII, IISet.rend(),
18865 return Elem.getPointer() == E;
18871 if (It == IISet.rend()) {
18873 CurrentII->setInt(1);
18880 return Base::TransformConstantExpr(E);
18881 RemoveImmediateInvocation(E);
18882 return Base::TransformExpr(E->
getSubExpr());
18888 return Base::TransformCXXOperatorCallExpr(E);
18902 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(
Init))
18903 Init = ICE->getSubExpr();
18904 else if (
auto *ICE = dyn_cast<MaterializeTemporaryExpr>(
Init))
18905 Init = ICE->getSubExpr();
18911 if (
auto *CE = dyn_cast<ConstantExpr>(
Init);
18912 CE && CE->isImmediateInvocation())
18913 RemoveImmediateInvocation(CE);
18914 return Base::TransformInitializer(
Init, NotCopyInit);
18930 bool AlwaysRebuild() {
return false; }
18931 bool ReplacingOriginal() {
return true; }
18932 bool AllowSkippingCXXConstructExpr() {
18933 bool Res = AllowSkippingFirstCXXConstructExpr;
18934 AllowSkippingFirstCXXConstructExpr =
true;
18937 bool AllowSkippingFirstCXXConstructExpr =
true;
18948 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
18950 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
18956 It->getPointer()->setSubExpr(Res.
get());
18976 if (VD && (VD->isUsableInConstantExpressions(
SemaRef.
Context) ||
18977 VD->hasConstantInitialization())) {
19010 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
19011 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
19014 return DRSet.size();
19017 Visitor.TraverseStmt(
19027 if (DR->isImmediateEscalating())
19031 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
19033 ND = MD->getParent();
19040 bool ImmediateEscalating =
false;
19041 bool IsPotentiallyEvaluated =
19051 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
19052 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
19053 if (!FD->getBuiltinID())
19057 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
19059 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
19061 if (FD->isImmediateEscalating() && !FD->isConsteval())
19075 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
19083 D = diag::err_lambda_unevaluated_operand;
19089 D = diag::err_lambda_in_constant_expression;
19090 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
19093 D = diag::err_lambda_in_invalid_context;
19095 llvm_unreachable(
"Couldn't infer lambda error message.");
19097 for (
const auto *L : Rec.
Lambdas)
19098 Diag(L->getBeginLoc(), D);
19118 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
19189 llvm_unreachable(
"Invalid context");
19235 : FD(FD), Param(Param) {}
19242 CCName =
"stdcall";
19245 CCName =
"fastcall";
19248 CCName =
"vectorcall";
19251 llvm_unreachable(
"CC does not need mangling");
19254 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
19255 << Param->getDeclName() << FD->
getDeclName() << CCName;
19260 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
19266enum class OdrUseContext {
19285 if (Context.isUnevaluated())
19286 return OdrUseContext::None;
19289 return OdrUseContext::Dependent;
19291 if (Context.isDiscardedStatementContext())
19292 return OdrUseContext::FormallyOdrUsed;
19294 else if (Context.Context ==
19296 return OdrUseContext::FormallyOdrUsed;
19298 return OdrUseContext::Used;
19302 if (!
Func->isConstexpr())
19305 if (
Func->isImplicitlyInstantiable() || !
Func->isUserProvided())
19312 auto *CCD = dyn_cast<CXXConstructorDecl>(
Func);
19313 return CCD && CCD->getInheritedConstructor();
19317 bool MightBeOdrUse) {
19318 assert(
Func &&
"No function?");
19320 Func->setReferenced();
19333 OdrUseContext OdrUse =
19335 if (IsRecursiveCall && OdrUse == OdrUseContext::Used)
19336 OdrUse = OdrUseContext::FormallyOdrUsed;
19340 if (
Func->isTrivial() && !
Func->hasAttr<DLLExportAttr>() &&
19341 OdrUse == OdrUseContext::Used) {
19344 OdrUse = OdrUseContext::FormallyOdrUsed;
19346 OdrUse = OdrUseContext::FormallyOdrUsed;
19353 bool NeededForConstantEvaluation =
19378 bool NeedDefinition =
19379 !IsRecursiveCall &&
19380 (OdrUse == OdrUseContext::Used ||
19381 (NeededForConstantEvaluation && !
Func->isPureVirtual()));
19388 if (NeedDefinition &&
19390 Func->getMemberSpecializationInfo()))
19397 if (NeedDefinition && !
Func->getBody()) {
19400 dyn_cast<CXXConstructorDecl>(
Func)) {
19413 }
else if (
Constructor->getInheritedConstructor()) {
19417 dyn_cast<CXXDestructorDecl>(
Func)) {
19427 if (MethodDecl->isOverloadedOperator() &&
19428 MethodDecl->getOverloadedOperator() == OO_Equal) {
19430 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
19431 if (MethodDecl->isCopyAssignmentOperator())
19433 else if (MethodDecl->isMoveAssignmentOperator())
19437 MethodDecl->getParent()->isLambda()) {
19444 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
19448 if (
Func->isDefaulted() && !
Func->isDeleted()) {
19450 Func->getDefaultedFunctionKind();
19459 if (
Func->isImplicitlyInstantiable()) {
19461 Func->getTemplateSpecializationKindForInstantiation();
19463 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
19464 if (FirstInstantiation) {
19465 PointOfInstantiation = Loc;
19466 if (
auto *MSI =
Func->getMemberSpecializationInfo())
19467 MSI->setPointOfInstantiation(Loc);
19470 Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
19475 PointOfInstantiation = Loc;
19479 Func->isConstexpr()) {
19484 std::make_pair(
Func, PointOfInstantiation));
19485 else if (
Func->isConstexpr())
19491 Func->setInstantiationIsPending(
true);
19493 std::make_pair(
Func, PointOfInstantiation));
19494 if (llvm::isTimeTraceVerbose()) {
19495 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
19497 llvm::raw_string_ostream
OS(Name);
19504 Consumer.HandleCXXImplicitFunctionInstantiation(
Func);
19509 for (
auto *i :
Func->redecls()) {
19510 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
19528 if (
Init->isInClassMemberInitializer())
19530 MarkDeclarationsReferencedInExpr(Init->getInit());
19551 if (
LangOpts.OffloadImplicitHostDeviceTemplates &&
LangOpts.CUDAIsDevice &&
19556 if (OdrUse == OdrUseContext::Used && !
Func->isUsed(
false)) {
19558 if (!
Func->isDefined() && !
Func->isInAnotherModuleUnit()) {
19559 if (mightHaveNonExternalLinkage(
Func))
19561 else if (
Func->getMostRecentDecl()->isInlined() &&
19563 !
Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
19581 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
19582 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(
Func)) {
19602 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
19605 VarDecl *Var =
V->getPotentiallyDecomposedVarDecl();
19606 assert(Var &&
"expected a capturable variable");
19616 QualType CaptureType, DeclRefType;
19622 DeclRefType, FunctionScopeIndexToStopAt);
19637 << 2 << 1 << Var << UserTarget;
19640 ? diag::note_cuda_const_var_unpromoted
19641 : diag::note_cuda_host_var);
19650 Var->
hasAttr<CUDADeviceAttr>() &&
19651 !Var->
getAttr<CUDADeviceAttr>()->isImplicit())) &&
19652 !Var->
hasAttr<CUDASharedAttr>() &&
19668 (!FD || (!FD->getDescribedFunctionTemplate() &&
19680 unsigned CapturingScopeIndex) {
19688 var->getDeclContext()->getEnclosingNonExpansionStatementContext();
19708 unsigned ContextKind = 3;
19718 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
19719 << var << ValueKind << ContextKind << VarDC;
19720 S.
Diag(var->getLocation(), diag::note_entity_declared_at)
19729 bool &SubCapturesAreNested,
19735 SubCapturesAreNested =
true;
19788 "Only variables and structured bindings can be captured");
19795 if ((IsLambda || IsBlock) && S.
getLangOpts().OpenMP &&
19798 S.
Diag(Loc, diag::err_omp_unsupported_on_binding) << 3;
19808 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
19817 S.
Diag(Loc, diag::err_ref_vm_type);
19828 S.
Diag(Loc, diag::err_ref_flexarray_type);
19830 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type) << Var;
19835 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19840 S.
Diag(Loc, diag::err_capture_block_variable) << Var << !IsLambda;
19849 S.
Diag(Loc, diag::err_opencl_block_ref_block);
19853 if (
auto *BD = dyn_cast<BindingDecl>(Var)) {
19854 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
19856 if (BD->getHoldingVar()) {
19858 S.
Diag(Loc, diag::err_capture_tuple_binding_openmp) << Var;
19864 S.
DiagCompat(Loc, diag_compat::capture_binding) << Var;
19875 S.
DiagCompat(Loc, diag_compat::capture_binding) << Var;
19888 bool ByRef =
false;
19894 if (BuildAndDiagnose) {
19895 S.
Diag(Loc, diag::err_ref_array_type);
19906 if (BuildAndDiagnose) {
19907 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
19923 if (BuildAndDiagnose) {
19925 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
19926 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
19931 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19940 DeclRefType = CaptureType;
19944 if (BuildAndDiagnose)
19954 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
19955 const bool RefersToCapturedVariable,
TryCaptureKind Kind,
bool IsTopScope,
19983 if (IsBindingDecl ? PrivateKind == OMPC_private
19984 : PrivateKind != OMPC_unknown)
19990 if (BuildAndDiagnose && IsBindingDecl) {
19992 if (Idx != 0 && RSI->
Captures[Idx - 1].isReferenceCapture() != ByRef) {
19994 diag::err_omp_decomposition_bindings_different_capture_kinds)
20004 CaptureType = DeclRefType;
20007 if (BuildAndDiagnose)
20008 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
20011 if (BuildAndDiagnose && IsBindingDecl)
20023 const bool RefersToCapturedVariable,
20028 bool ByRef =
false;
20032 ByRef = (LSI->
ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref);
20037 S.
Diag(Loc, diag::err_wasm_ca_reference) << 0;
20068 if (!RefType->getPointeeType()->isFunctionType())
20075 if (BuildAndDiagnose) {
20076 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
20086 if (!
Invalid && BuildAndDiagnose) {
20090 diag::err_capture_of_incomplete_or_sizeless_type,
20094 diag::err_capture_of_abstract_type))
20120 if (BuildAndDiagnose)
20121 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
20122 Loc, EllipsisLoc, CaptureType,
Invalid);
20133 if (
T.isTriviallyCopyableType(Context))
20137 if (!(RD = RD->getDefinition()))
20139 if (RD->hasSimpleCopyConstructor())
20141 if (RD->hasUserDeclaredCopyConstructor())
20143 if (Ctor->isCopyConstructor())
20144 return !Ctor->isDeleted();
20164 if (ShouldOfferCopyFix) {
20168 FixBuffer.assign({Separator, Var->
getName()});
20169 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
20174 FixBuffer.assign({Separator,
"&", Var->
getName()});
20175 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
20187 return !C.isThisCapture() && !C.isInitCapture();
20196 if (ShouldOfferCopyFix) {
20197 bool CanDefaultCopyCapture =
true;
20206 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &
C) {
20207 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
20209 FixBuffer.assign({
"=", Separator});
20210 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
20219 return !C.isInitCapture() && C.isReferenceCapture() &&
20220 !C.isThisCapture();
20222 FixBuffer.assign({
"&", Separator});
20223 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
20232 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
20256 const auto *VD = dyn_cast<VarDecl>(Var);
20258 if (VD->isInitCapture())
20263 assert(VD &&
"Cannot capture a null variable");
20265 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
20269 if (FunctionScopeIndexToStopAt) {
20270 assert(!
FunctionScopes.empty() &&
"No function scopes to stop at?");
20275 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(
FunctionScopes[FSIndex]);
20276 FSIndex && LSI && !LSI->AfterParameterList)
20278 assert(MaxFunctionScopesIndex <= FSIndex &&
20279 "FunctionScopeIndexToStopAt should be no greater than FSIndex into "
20280 "FunctionScopes.");
20281 while (FSIndex != MaxFunctionScopesIndex) {
20289 bool IsGlobal = !VD->hasLocalStorage();
20290 if (IsGlobal && !(
LangOpts.OpenMP &&
20291 OpenMP().isOpenMPCapturedDecl(Var,
true,
20292 MaxFunctionScopesIndex)))
20306 CaptureType = Var->
getType();
20308 bool Nested =
false;
20310 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
20315 LSI = dyn_cast_or_null<LambdaScopeInfo>(
20318 bool IsInScopeDeclarationContext =
20329 if (IsInScopeDeclarationContext &&
20330 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
20336 !IsInScopeDeclarationContext
20339 BuildAndDiagnose, *
this);
20345 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
20364 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
20365 Parm && Parm->getDeclContext() == DC)
20373 if (BuildAndDiagnose) {
20376 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
20391 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
20392 QTy = PVD->getOriginalType();
20397 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
20403 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
20408 if (IsOpenMPPrivateDecl != OMPC_unknown &&
20411 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
20412 QTy = PVD->getOriginalType();
20414 E =
OpenMP().getNumberOfConstructScopes(RSI->OpenMPLevel);
20418 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
20419 "Wrong number of captured regions associated with the "
20420 "OpenMP construct.");
20425 IsOpenMPPrivateDecl != OMPC_private &&
20427 RSI->OpenMPCaptureLevel);
20431 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
20437 OpenMP().adjustOpenMPTargetScopeIndex(FunctionScopesIndex,
20440 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
20441 (IsGlobal && !IsGlobalCap)) {
20442 Nested = !IsTargetCap;
20448 CaptureType =
Context.getLValueReferenceType(DeclRefType);
20457 if (BuildAndDiagnose) {
20458 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
20480 FunctionScopesIndex--;
20481 if (IsInScopeDeclarationContext)
20483 }
while (!VarDC->
Equals(DC));
20491 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
20504 if (
Invalid && !BuildAndDiagnose)
20509 DeclRefType, Nested, *
this,
Invalid);
20513 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
20514 Kind, I == N - 1, *
this,
Invalid);
20520 DeclRefType, Nested, Kind, EllipsisLoc,
20525 if (
Invalid && !BuildAndDiagnose)
20537 DeclRefType,
nullptr);
20545 false, CaptureType, DeclRefType,
nullptr);
20549 assert(Var &&
"Null value cannot be captured");
20556 false, CaptureType, DeclRefType,
20560 return DeclRefType;
20568class CopiedTemplateArgs {
20572 template<
typename RefExpr>
20573 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
20575 E->copyTemplateArgumentsInto(TemplateArgStorage);
20578#ifdef __has_cpp_attribute
20579#if __has_cpp_attribute(clang::lifetimebound)
20580 [[clang::lifetimebound]]
20584 return HasArgs ? &TemplateArgStorage :
nullptr;
20610 auto Rebuild = [&](
Expr *Sub) {
20615 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
20618 auto *VD = dyn_cast<VarDecl>(D);
20641 llvm_unreachable(
"unexpected non-odr-use-reason");
20645 if (VD->getType()->isReferenceType())
20647 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
20648 if (RD->hasDefinition() && RD->hasMutableFields())
20650 if (!VD->isUsableInConstantExpressions(S.
Context))
20655 if (VD->getType()->isReferenceType())
20663 auto MaybeCUDAODRUsed = [&]() ->
bool {
20669 auto *DRE = dyn_cast<DeclRefExpr>(E);
20672 auto *VD = dyn_cast<VarDecl>(DRE->getDecl());
20679 auto MarkNotOdrUsed = [&] {
20680 if (!MaybeCUDAODRUsed()) {
20683 LSI->markVariableExprAsNonODRUsed(E);
20691 case Expr::DeclRefExprClass: {
20693 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
20699 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
20700 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
20701 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
20702 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
20705 case Expr::FunctionParmPackExprClass: {
20710 if (IsPotentialResultOdrUsed(D))
20721 case Expr::ArraySubscriptExprClass: {
20727 if (!
Base.isUsable())
20729 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
20730 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
20733 ASE->getRBracketLoc());
20736 case Expr::MemberExprClass: {
20742 if (!
Base.isUsable())
20745 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
20746 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
20747 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
20748 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
20749 ME->getObjectKind(), ME->isNonOdrUse());
20752 if (ME->getMemberDecl()->isCXXInstanceMember())
20757 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
20763 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
20764 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
20765 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
20766 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
20769 case Expr::BinaryOperatorClass: {
20771 Expr *LHS = BO->getLHS();
20772 Expr *RHS = BO->getRHS();
20774 if (BO->getOpcode() == BO_PtrMemD) {
20776 if (!Sub.isUsable())
20778 BO->setLHS(Sub.get());
20780 }
else if (BO->getOpcode() == BO_Comma) {
20782 if (!Sub.isUsable())
20784 BO->setRHS(Sub.get());
20792 case Expr::ParenExprClass: {
20795 if (!Sub.isUsable())
20797 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
20802 case Expr::ConditionalOperatorClass: {
20813 LHS = CO->getLHS();
20815 RHS = CO->getRHS();
20817 CO->getCond(), LHS.
get(), RHS.
get());
20822 case Expr::UnaryOperatorClass: {
20824 if (UO->getOpcode() != UO_Extension)
20827 if (!Sub.isUsable())
20829 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
20836 case Expr::GenericSelectionExprClass: {
20840 bool AnyChanged =
false;
20841 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
20842 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
20846 AssocExprs.push_back(AssocExpr.
get());
20849 AssocExprs.push_back(OrigAssocExpr);
20853 void *ExOrTy =
nullptr;
20854 bool IsExpr = GSE->isExprPredicate();
20856 ExOrTy = GSE->getControllingExpr();
20858 ExOrTy = GSE->getControllingType();
20860 GSE->getGenericLoc(), GSE->getDefaultLoc(),
20861 GSE->getRParenLoc(), IsExpr, ExOrTy,
20862 GSE->getAssocTypeSourceInfos(), AssocExprs)
20870 case Expr::ChooseExprClass: {
20881 if (!LHS.
get() && !RHS.
get())
20884 LHS = CE->getLHS();
20886 RHS = CE->getRHS();
20889 RHS.
get(), CE->getRParenLoc());
20893 case Expr::ConstantExprClass: {
20896 if (!Sub.isUsable())
20903 case Expr::ImplicitCastExprClass: {
20908 switch (ICE->getCastKind()) {
20910 case CK_DerivedToBase:
20911 case CK_UncheckedDerivedToBase: {
20912 ExprResult Sub = Rebuild(ICE->getSubExpr());
20913 if (!Sub.isUsable())
20917 ICE->getValueKind(), &Path);
20974 for (
Expr *E : LocalMaybeODRUseExprs) {
20975 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
20977 DRE->getLocation(), *
this);
20978 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
20981 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
20985 llvm_unreachable(
"Unexpected expression");
20990 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
20999 const bool RefersToEnclosingScope =
21002 if (RefersToEnclosingScope) {
21017 assert(E &&
"Capture variable should be used in an expression.");
21030 "Invalid Expr argument to DoMarkVarDeclReferenced");
21041 bool UsableInConstantExpr =
21060 bool NeededForConstantEvaluation =
21063 bool NeedDefinition =
21064 OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
21068 "Can't instantiate a partial template specialization.");
21085 bool TryInstantiating =
21089 if (TryInstantiating) {
21092 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
21093 if (FirstInstantiation) {
21094 PointOfInstantiation = Loc;
21096 MSI->setPointOfInstantiation(PointOfInstantiation);
21118 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
21119 DRE->setDecl(DRE->getDecl());
21120 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(E))
21121 ME->setMemberDecl(ME->getMemberDecl());
21122 }
else if (FirstInstantiation) {
21124 .push_back(std::make_pair(Var, PointOfInstantiation));
21126 bool Inserted =
false;
21128 auto Iter = llvm::find_if(
21130 return P.first == Var;
21132 if (Iter != I.end()) {
21147 .push_back(std::make_pair(Var, PointOfInstantiation));
21171 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
21172 if (DRE->isNonOdrUse())
21174 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
21175 if (ME->isNonOdrUse())
21179 case OdrUseContext::None:
21184 "missing non-odr-use marking for unevaluated decl ref");
21187 case OdrUseContext::FormallyOdrUsed:
21192 case OdrUseContext::Used:
21201 case OdrUseContext::Dependent:
21219 if (OdrUse == OdrUseContext::Used) {
21220 QualType CaptureType, DeclRefType;
21226 }
else if (OdrUse == OdrUseContext::Dependent) {
21242 auto *ID = dyn_cast<DeclRefExpr>(E);
21243 if (!ID || ID->isTypeDependent() || !ID->refersToEnclosingVariableOrCapture())
21250 auto IsDependent = [&]() {
21252 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
21257 LSI->AfterParameterList)
21260 const auto *MD = LSI->CallOperator;
21261 if (MD->getType().isNull())
21265 if (!Ty || !MD->isExplicitObjectMemberFunction() ||
21269 if (
auto *
C = LSI->CaptureMap.count(D) ? &LSI->getCapture(D) :
nullptr) {
21270 if (
C->isCopyCapture())
21275 if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
21281 ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
21287 bool MightBeOdrUse,
21295 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
21314 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
21321 bool IsVirtualCall = MD->
isVirtual() &&
21323 if (!IsVirtualCall)
21340 bool OdrUse =
true;
21342 if (
Method->isVirtual() &&
21346 if (
auto *FD = dyn_cast<FunctionDecl>(E->
getDecl())) {
21351 !FD->isDependentContext())
21365 bool MightBeOdrUse =
true;
21368 if (
Method->isPureVirtual())
21369 MightBeOdrUse =
false;
21388 bool MightBeOdrUse) {
21389 if (MightBeOdrUse) {
21390 if (
auto *VD = dyn_cast<VarDecl>(D)) {
21395 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
21421bool MarkReferencedDecls::TraverseTemplateArgument(
21422 const TemplateArgument &Arg) {
21425 EnterExpressionEvaluationContext
Evaluated(
21439 MarkReferencedDecls Marker(*
this, Loc);
21440 Marker.TraverseType(
T);
21446class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
21449 bool SkipLocalVariables;
21452 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
21454 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
21460 void Visit(Expr *E) {
21461 if (llvm::is_contained(StopAt, E))
21463 Inherited::Visit(E);
21466 void VisitConstantExpr(ConstantExpr *E) {
21471 void VisitDeclRefExpr(DeclRefExpr *E) {
21473 if (SkipLocalVariables) {
21474 if (VarDecl *VD = dyn_cast<VarDecl>(E->
getDecl()))
21475 if (VD->hasLocalStorage())
21485 void VisitMemberExpr(MemberExpr *E) {
21493 bool SkipLocalVariables,
21495 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(E);
21507 (
Decl->isConstexpr() || (
Decl->isStaticDataMember() &&
21511 if (Stmts.empty()) {
21522 if (
Diags.getIgnoreAllWarnings() &&
21533 if (
Decl &&
Decl->isFileVarDecl()) {
21606 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
21612 : FD(FD), CE(CE) { }
21616 S.
Diag(Loc, diag::err_call_incomplete_return)
21621 S.
Diag(Loc, diag::err_call_function_incomplete_return)
21626 } Diagnoser(FD, CE);
21639 unsigned diagnostic = diag::warn_condition_is_assignment;
21640 bool IsOrAssign =
false;
21643 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
21646 IsOrAssign = Op->getOpcode() == BO_OrAssign;
21654 if (
ObjC().isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
21655 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21659 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21662 Loc = Op->getOperatorLoc();
21664 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
21667 IsOrAssign = Op->getOperator() == OO_PipeEqual;
21668 Loc = Op->getOperatorLoc();
21680 Diag(Loc, diag::note_condition_assign_silence)
21685 Diag(Loc, diag::note_condition_or_assign_to_comparison)
21688 Diag(Loc, diag::note_condition_assign_to_comparison)
21706 if (opE->getOpcode() == BO_EQ &&
21707 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
21713 Diag(Loc, diag::note_equality_comparison_silence)
21716 Diag(Loc, diag::note_equality_comparison_to_assign)
21722 bool IsConstexpr) {
21724 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
21744 if (!
T->isScalarType()) {
21745 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
21749 CheckBoolLikeConversion(E, Loc);
21796 struct RebuildUnknownAnyFunction
21797 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
21801 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
21804 llvm_unreachable(
"unexpected statement!");
21815 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
21816 ExprResult SubResult = Visit(E->getSubExpr());
21819 Expr *SubExpr = SubResult.
get();
21820 E->setSubExpr(SubExpr);
21821 E->setType(SubExpr->
getType());
21828 return rebuildSugarExpr(E);
21831 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21832 return rebuildSugarExpr(E);
21835 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21839 Expr *SubExpr = SubResult.
get();
21847 ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
21865 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21866 return resolveDecl(E, E->
getDecl());
21884 struct RebuildUnknownAnyExpr
21885 : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
21892 RebuildUnknownAnyExpr(Sema &S, QualType
CastType)
21896 llvm_unreachable(
"unexpected statement!");
21906 ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
21910 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
21911 ExprResult SubResult = Visit(E->getSubExpr());
21913 Expr *SubExpr = SubResult.
get();
21914 E->setSubExpr(SubExpr);
21915 E->setType(SubExpr->
getType());
21922 return rebuildSugarExpr(E);
21925 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21926 return rebuildSugarExpr(E);
21929 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21930 const PointerType *
Ptr = DestType->
getAs<PointerType>();
21948 DestType =
Ptr->getPointeeType();
21955 ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
21957 ExprResult resolveDecl(Expr *E, ValueDecl *VD);
21963 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21964 return resolveDecl(E, E->
getDecl());
21970ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
21975 FK_FunctionPointer,
21980 QualType CalleeType = CalleeExpr->
getType();
21983 Kind = FK_MemberFunction;
21985 }
else if (
const PointerType *Ptr = CalleeType->
getAs<PointerType>()) {
21986 CalleeType =
Ptr->getPointeeType();
21987 Kind = FK_FunctionPointer;
21990 Kind = FK_BlockPointer;
21992 const FunctionType *FnType = CalleeType->
castAs<FunctionType>();
21997 unsigned diagID = diag::err_func_returning_array_function;
21998 if (Kind == FK_BlockPointer)
21999 diagID = diag::err_block_returning_array_function;
22012 const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FnType);
22034 SmallVector<QualType, 8> ArgTypes;
22035 if (ParamTypes.empty() && Proto->
isVariadic()) {
22037 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
22040 ParamTypes = ArgTypes;
22051 case FK_MemberFunction:
22055 case FK_FunctionPointer:
22059 case FK_BlockPointer:
22065 ExprResult CalleeResult = Visit(CalleeExpr);
22073ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
22076 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
22084 Method->setReturnType(DestType);
22094ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
22096 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
22110 }
else if (E->
getCastKind() == CK_LValueToRValue) {
22127 llvm_unreachable(
"Unhandled cast type!");
22131ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
22133 QualType
Type = DestType;
22138 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(VD)) {
22139 if (
const PointerType *Ptr =
Type->getAs<PointerType>()) {
22140 DestType =
Ptr->getPointeeType();
22147 if (!
Type->isFunctionType()) {
22152 if (
const FunctionProtoType *FT =
Type->getAs<FunctionProtoType>()) {
22156 QualType FDT = FD->getType();
22157 const FunctionType *FnType = FDT->
castAs<FunctionType>();
22158 const FunctionProtoType *Proto = dyn_cast_or_null<FunctionProtoType>(FnType);
22159 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
22160 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
22161 SourceLocation Loc = FD->getLocation();
22163 S.
Context, FD->getDeclContext(), Loc, Loc,
22164 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
22166 false , FD->hasPrototype(),
22169 if (FD->getQualifier())
22172 SmallVector<ParmVarDecl*, 16> Params;
22173 for (
const auto &AI : FT->param_types()) {
22174 ParmVarDecl *Param =
22177 Params.push_back(Param);
22179 NewFD->setParams(Params);
22185 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
22186 if (MD->isInstance()) {
22197 if (
const ReferenceType *RefTy =
Type->getAs<ReferenceType>()) {
22198 Type = RefTy->getPointeeType();
22199 }
else if (
Type->isFunctionType()) {
22200 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
22226 diag::err_typecheck_cast_to_incomplete))
22241 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
22248 ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
22257 assert(!arg->hasPlaceholderType());
22269 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
22272 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
22273 E = call->getCallee();
22274 diagID = diag::err_uncasted_call_of_unknown_any;
22282 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
22283 loc = ref->getLocation();
22284 d = ref->getDecl();
22285 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
22286 loc = mem->getMemberLoc();
22287 d = mem->getMemberDecl();
22289 diagID = diag::err_uncasted_call_of_unknown_any;
22290 loc = msg->getSelectorStartLoc();
22291 d = msg->getMethodDecl();
22293 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
22294 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
22312 if (!placeholderType)
return E;
22314 switch (placeholderType->
getKind()) {
22315 case BuiltinType::UnresolvedTemplate: {
22328 if (
auto *TD = dyn_cast<TemplateDecl>(Temp))
22329 TN =
Context.getQualifiedTemplateName(NNS, ULE->hasTemplateKeyword(),
22334 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
22335 << TN << ULE->getSourceRange() << IsTypeAliasTemplateDecl;
22337 << IsTypeAliasTemplateDecl;
22340 bool HasAnyDependentTA =
false;
22342 HasAnyDependentTA |= Arg.getArgument().
isDependent();
22354 TST =
Context.getTemplateSpecializationType(
22363 case BuiltinType::Overload: {
22383 case BuiltinType::BoundMember: {
22389 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
22390 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
22391 if (ME->getMemberNameInfo().getName().getNameKind() ==
22393 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
22401 case BuiltinType::ARCUnbridgedCast: {
22408 case BuiltinType::UnknownAny:
22412 case BuiltinType::PseudoObject:
22415 case BuiltinType::BuiltinFn: {
22420 unsigned BuiltinID = FD->getBuiltinID();
22421 if (BuiltinID == Builtin::BI__noop) {
22423 CK_BuiltinFnToFnPtr)
22430 if (
Context.BuiltinInfo.isInStdNamespace(BuiltinID)) {
22436 ? diag::err_use_of_unaddressable_function
22437 : diag::warn_cxx20_compat_use_of_unaddressable_function);
22438 if (FD->isImplicitlyInstantiable()) {
22465 case BuiltinType::IncompleteMatrixIdx: {
22471 MS->getBase(), MS->getRowIdx(), E->
getExprLoc());
22473 Diag(MS->getRowIdx()->getBeginLoc(), diag::err_matrix_incomplete_index);
22478 case BuiltinType::ArraySection:
22487 case BuiltinType::OMPArrayShaping:
22490 case BuiltinType::OMPIterator:
22494#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
22495 case BuiltinType::Id:
22496#include "clang/Basic/OpenCLImageTypes.def"
22497#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
22498 case BuiltinType::Id:
22499#include "clang/Basic/OpenCLExtensionTypes.def"
22500#define SVE_TYPE(Name, Id, SingletonId) \
22501 case BuiltinType::Id:
22502#include "clang/Basic/AArch64ACLETypes.def"
22503#define PPC_VECTOR_TYPE(Name, Id, Size) \
22504 case BuiltinType::Id:
22505#include "clang/Basic/PPCTypes.def"
22506#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22507#include "clang/Basic/RISCVVTypes.def"
22508#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22509#include "clang/Basic/WebAssemblyReferenceTypes.def"
22510#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
22511#include "clang/Basic/AMDGPUTypes.def"
22512#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22513#include "clang/Basic/HLSLIntangibleTypes.def"
22514#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22515#include "clang/Basic/HLSLPackedTypes.def"
22516#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22517#include "clang/Basic/SPIRVTypes.def"
22518#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
22519#define PLACEHOLDER_TYPE(Id, SingletonId)
22520#include "clang/AST/BuiltinTypes.def"
22524 llvm_unreachable(
"invalid placeholder type!");
22537 if (!
Context.getLangOpts().RecoveryAST)
22543 if (
T.isNull() ||
T->isUndeducedType() ||
22544 !
Context.getLangOpts().RecoveryASTType)
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 enumerations for traits support.
Defines enum values for all the target-independent builtin functions.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
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.
static QualType getUnderlyingType(const SubRegion *R)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis functions specific to AMDGPU.
This file declares semantic analysis functions specific to ARM.
This file declares semantic analysis for CUDA constructs.
static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy, SourceLocation OpLoc)
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 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 Decl * getPredefinedExprDecl(Sema &S, DeclContext *DC)
getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used to determine the value o...
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 void diagnoseUncapturableValueReferenceOrBinding(Sema &S, SourceLocation loc, ValueDecl *var)
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 AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn)
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 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 AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(Sema &SemaRef, ValueDecl *D, Expr *E)
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 CXXRecordDecl * LookupStdSourceLocationImpl(Sema &S, SourceLocation Loc)
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 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 bool areTypesCompatibleForGeneric(ASTContext &Ctx, QualType T, QualType U)
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool MayBeFunctionType(const ASTContext &Context, const Expr *E)
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 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 void RemoveNestedImmediateInvocation(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec, SmallVector< Sema::ImmediateInvocationCandidate, 4 >::reverse_iterator It)
static void CheckUnicodeArithmeticConversions(Sema &SemaRef, Expr *LHS, Expr *RHS, SourceLocation Loc, ArithConvKind ACK)
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 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 bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the lambda.
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 ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
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 AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType, SourceLocation Loc)
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 void diagnoseScopedEnums(Sema &S, const SourceLocation Loc, const ExprResult &LHS, const ExprResult &RHS, BinaryOperatorKind Opc)
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 Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
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 void CheckSufficientAllocSize(Sema &S, QualType DestType, const Expr *E)
Check that a call to alloc_size function specifies sufficient space for the destination type.
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 QualType handleOverflowBehaviorTypeConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
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 diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name, SourceLocation TypoLoc)
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 FieldDecl * FindFieldDeclInstantiationPattern(const ASTContext &Ctx, FieldDecl *Field)
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 std::optional< bool > isTautologicalBoundsCheck(Sema &S, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opc)
Detect patterns ptr + size >= ptr and ptr + size < ptr, where ptr is a pointer and size is an unsigne...
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 bool checkPtrAuthTypeDiscriminatorOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
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 void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, TryCaptureKind Kind, bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the captured region.
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 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 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 isProvablyZeroSize(const ASTContext &Ctx, QualType T)
Determine whether the size of T is provably zero: some array dimension is provably zero or the base e...
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, QualType ResultTy, 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 DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
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 HLSL constructs.
This file declares semantic analysis functions specific to Hexagon.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis routines for OpenCL.
This file declares semantic analysis for OpenMP constructs and clauses.
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.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
@ Open
The standard open() call: int open(const char *path, int oflag, ...);.
a trap message and trap category.
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...
unsigned getIntWidth(QualType T) const
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.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) 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 getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
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.
const LangOptions & getLangOpts() const
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
const QualType GetHigherPrecisionFPType(QualType ElementType) const
bool typesAreBlockPointerCompatible(QualType, QualType)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType getCorrespondingSaturatedType(QualType Ty) const
CanQualType BoundMemberTy
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
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
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
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.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
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.
const TargetInfo & getTargetInfo() const
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
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 ...
unsigned getTargetAddressSpace(LangAS AS) const
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
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
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 bool isRelationalOp(Opcode Opc)
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isComparisonOp(Opcode Opc)
StringRef getOpcodeStr() const
bool isRelationalOp() const
SourceLocation getOperatorLoc() const
bool isMultiplicativeOp() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
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 isAssignmentOp(Opcode Opc)
static bool isCompoundAssignmentOp(Opcode Opc)
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 isEqualityOp(Opcode Opc)
static bool isBitwiseOp(Opcode Opc)
BinaryOperatorKind Opcode
A binding in a decomposition declaration.
A fixed int type of a specified bitwidth.
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)
void setSignatureAsWritten(TypeSourceInfo *Sig)
void setBlockMissingReturnType(bool val=true)
void setIsVariadic(bool value)
SourceLocation getCaretLocation() const
void setBody(CompoundStmt *B)
ArrayRef< ParmVarDecl * > parameters() const
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'.
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...
const RecordType * getDetectedVirtual() const
The virtual base discovered on the path (if we are merely detecting virtuals).
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
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
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.
bool isLambda() const
Determine whether this class describes a lambda function object.
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.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
static CXXReflectExpr * Create(ASTContext &C, SourceLocation OperatorLoc, const TypeSourceInfo *TSI)
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
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 * getArg(unsigned Arg)
getArg - Return the specified argument.
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.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void computeDependence()
Compute and set dependence bits.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
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 byte-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
bool isZero() const
Test whether the quantity equals zero.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static CharUnits One()
Construct a CharUnits quantity of one.
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
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 }.
ConditionalOperator - The ?
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.
An expression that occurs in a constant context and the result of evaluating the expression.
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.
std::optional< LayoutKind > getLayout() const
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...
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.
Represents a pointer type decayed from an array or function type.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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.
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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 semantically encloses the declaration context DC.
DeclContext * getEnclosingNonExpansionStatementContext()
Retrieve the innermost enclosing context that doesn't belong to an expansion statement.
bool isExpansionStmt() const
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
NestedNameSpecifier getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setDecl(ValueDecl *NewD)
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
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,...
SourceLocation getBeginLoc() const
SourceLocation getLocation() const
Decl - This represents one declaration (or definition), e.g.
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 isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setReferenced(bool R=true)
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypeSourceInfo * getTypeSourceInfo() const
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)
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
Designator - A designator in a C99 designated initializer.
bool isArrayDesignator() const
SourceLocation getEndLoc() const
Returns the end location of this designator.
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
const IdentifierInfo * getFieldDecl() const
SourceLocation getBeginLoc() const
Returns the start location of this designator.
Expr * getArrayIndex() const
A little helper class used to produce diagnostics.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
bool ShouldVisitImplicitCode
virtual bool VisitStmt(MaybeConst< Stmt > *S)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
virtual bool TraverseLambdaCapture(MaybeConst< LambdaExpr > *LE, const LambdaCapture *C, MaybeConst< Expr > *Init)
virtual bool TraverseTemplateArgument(const TemplateArgument &Arg)
Represents a reference to emded data.
RAII object that enters a new expression evaluation context.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
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,...
bool isIntegerConstantExpr(const ASTContext &Ctx) const
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...
@ SE_AllowSideEffects
Allow any unmodeled side effect.
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 EvaluateAsMandatedConstantExpr(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required by the language to be a constant expression.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
bool EvaluateAsMandatedConstantRValue(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy) const
Evaluate an expression that is required by the language to be a constant expression,...
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.
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 isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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 ...
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.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
@ MLV_DuplicateVectorComponents
@ MLV_InvalidMessageExpression
@ MLV_DuplicateMatrixComponents
@ MLV_ConstQualifiedField
@ MLV_SubObjCPropertySetting