19#include "llvm/ADT/StringExtras.h"
20#include "llvm/Support/ErrorHandling.h"
21#include "llvm/Support/SipHash.h"
28 case Builtin::BIas_const:
29 case Builtin::BIforward:
30 case Builtin::BIforward_like:
32 case Builtin::BImove_if_noexcept:
33 case Builtin::BIaddressof:
34 case Builtin::BI__addressof:
35 case Builtin::BI__builtin_addressof:
36 case Builtin::BI__builtin_launder:
83 int64_t
V = Val.getSExtValue();
87 uint64_t
V = Val.getZExtValue();
94 if constexpr (std::is_same_v<T, APInt>)
96 else if constexpr (std::is_same_v<T, APSInt>)
101 std::is_signed_v<T>),
102 !std::is_signed_v<T>),
119 ValueT, { Dest.
deref<
T>() = T::from(
static_cast<T>(
Value)); });
128 if (
T->isPointerType())
132 if (
const auto *AT =
T->getAsArrayTypeUnsafe())
133 return AT->getElementType();
144 S.
CCEDiag(Loc, diag::note_constexpr_invalid_function)
148 S.
CCEDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
154 "Not a boolean vector");
158 llvm::APSInt
Result(NumElems, 0);
159 for (
unsigned I = 0; I != NumElems; ++I) {
160 if (Val.
elem<
bool>(I))
172 return F && F->isInStdNamespace() && F->getIdentifier() &&
173 F->getIdentifier()->isStr(
"is_constant_evaluated");
184 diag::warn_is_constant_evaluated_always_true_constexpr)
188 diag::warn_is_constant_evaluated_always_true_constexpr)
189 <<
"__builtin_is_constant_evaluated" <<
Call->getSourceRange();
201 assert(
Call->getNumArgs() == 1);
209 uint64_t Limit = ~static_cast<uint64_t>(0);
210 if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp ||
211 ID == Builtin::BIwcsncmp || ID == Builtin::BI__builtin_wcsncmp)
217 if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp ||
218 ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp)
229 if (A.isDummy() || B.
isDummy())
234 bool IsWide = ID == Builtin::BIwcscmp || ID == Builtin::BIwcsncmp ||
235 ID == Builtin::BI__builtin_wcscmp ||
236 ID == Builtin::BI__builtin_wcsncmp;
237 assert(A.getFieldDesc()->isPrimitiveArray());
246 auto returnResult = [&](
int V) ->
bool {
251 unsigned IndexA = A.getIndex();
254 for (;; ++IndexA, ++IndexB, ++Steps) {
270 return returnResult(1);
272 return returnResult(-1);
273 if (CA.isZero() || CB.isZero())
274 return returnResult(0);
279 uint8_t CA = PA.
deref<uint8_t>();
280 uint8_t CB = PB.
deref<uint8_t>();
283 return returnResult(1);
285 return returnResult(-1);
286 if (CA == 0 || CB == 0)
287 return returnResult(0);
290 return returnResult(0);
298 if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
316 if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
322 for (
size_t I = StrPtr.
getIndex();; ++I, ++Len) {
331 Val = ElemPtr.
deref<uint8_t>();
334 Val = ElemPtr.
deref<uint16_t>();
337 Val = ElemPtr.
deref<uint32_t>();
340 llvm_unreachable(
"Unsupported char size");
365 for (
unsigned I = 0;; ++I) {
371 if (Elem.
deref<int8_t>() == 0)
374 Str += Elem.
deref<
char>();
379 Fill = llvm::APInt(32, 0);
380 else if (StringRef(Str).getAsInteger(0, Fill))
383 const llvm::fltSemantics &TargetSemantics =
385 Call->getDirectCallee()->getReturnType());
391 llvm::APFloat::getSNaN(TargetSemantics,
false, &Fill));
394 llvm::APFloat::getQNaN(TargetSemantics,
false, &Fill));
403 llvm::APFloat::getQNaN(TargetSemantics,
false, &Fill));
406 llvm::APFloat::getSNaN(TargetSemantics,
false, &Fill));
416 const llvm::fltSemantics &TargetSemantics =
418 Call->getDirectCallee()->getReturnType());
421 Result.copy(APFloat::getInf(TargetSemantics));
494 bool IsInf = F.isInfinity();
497 pushInteger(S, IsInf ? (F.isNegative() ? -1 : 1) : 0,
Call->getType());
557 case Builtin::BI__builtin_isgreater:
559 case Builtin::BI__builtin_isgreaterequal:
561 case Builtin::BI__builtin_isless:
563 case Builtin::BI__builtin_islessequal:
565 case Builtin::BI__builtin_islessgreater: {
570 case Builtin::BI__builtin_isunordered:
573 llvm_unreachable(
"Unexpected builtin ID: Should be a floating point "
574 "comparison function");
589 int32_t
Result =
static_cast<int32_t
>(
590 (F.
classify() & std::move(FPClassArg)).getZExtValue());
605 for (
unsigned I = 0; I != 5; ++I)
613 case APFloat::fcInfinity:
616 case APFloat::fcNormal:
619 case APFloat::fcZero:
632 if (!In.isNegative())
659 APSInt(APInt::getSignedMinValue(Val.getBitWidth()),
false))
661 if (Val.isNegative())
671 if (
Call->getArg(0)->getType()->isExtVectorBoolType()) {
693 pushInteger(S, Val.getBitWidth() - Val.getSignificantBits(),
Call->getType());
709 assert(
Call->getNumArgs() == 1);
714 int32_t ReturnVal =
static_cast<int32_t
>(ResultClass);
726 unsigned NumArgs =
Call->getNumArgs();
727 assert(NumArgs == 2 || NumArgs == 3);
763 uint64_t N =
Value.countr_zero();
772 assert(
Call->getArg(0)->isLValue());
775 "Unsupported pointer type passed to __builtin_addressof()");
783 return Call->getDirectCallee()->isConstexpr();
800 unsigned BuiltinOp) {
809 QualType ResultType =
Call->getArg(2)->getType()->getPointeeType();
814 if (BuiltinOp == Builtin::BI__builtin_add_overflow ||
815 BuiltinOp == Builtin::BI__builtin_sub_overflow ||
816 BuiltinOp == Builtin::BI__builtin_mul_overflow) {
817 bool IsSigned = LHS.isSigned() || RHS.isSigned() ||
819 bool AllSigned = LHS.isSigned() && RHS.isSigned() &&
821 uint64_t LHSSize = LHS.getBitWidth();
822 uint64_t RHSSize = RHS.getBitWidth();
824 uint64_t MaxBits = std::max(std::max(LHSSize, RHSSize), ResultSize);
830 if (IsSigned && !AllSigned)
833 LHS =
APSInt(LHS.extOrTrunc(MaxBits), !IsSigned);
834 RHS =
APSInt(RHS.extOrTrunc(MaxBits), !IsSigned);
841 llvm_unreachable(
"Invalid value for BuiltinOp");
842 case Builtin::BI__builtin_add_overflow:
843 case Builtin::BI__builtin_sadd_overflow:
844 case Builtin::BI__builtin_saddl_overflow:
845 case Builtin::BI__builtin_saddll_overflow:
846 case Builtin::BI__builtin_uadd_overflow:
847 case Builtin::BI__builtin_uaddl_overflow:
848 case Builtin::BI__builtin_uaddll_overflow:
849 Result = LHS.isSigned() ? LHS.sadd_ov(RHS, Overflow)
850 : LHS.uadd_ov(RHS, Overflow);
852 case Builtin::BI__builtin_sub_overflow:
853 case Builtin::BI__builtin_ssub_overflow:
854 case Builtin::BI__builtin_ssubl_overflow:
855 case Builtin::BI__builtin_ssubll_overflow:
856 case Builtin::BI__builtin_usub_overflow:
857 case Builtin::BI__builtin_usubl_overflow:
858 case Builtin::BI__builtin_usubll_overflow:
859 Result = LHS.isSigned() ? LHS.ssub_ov(RHS, Overflow)
860 : LHS.usub_ov(RHS, Overflow);
862 case Builtin::BI__builtin_mul_overflow:
863 case Builtin::BI__builtin_smul_overflow:
864 case Builtin::BI__builtin_smull_overflow:
865 case Builtin::BI__builtin_smulll_overflow:
866 case Builtin::BI__builtin_umul_overflow:
867 case Builtin::BI__builtin_umull_overflow:
868 case Builtin::BI__builtin_umulll_overflow:
869 Result = LHS.isSigned() ? LHS.smul_ov(RHS, Overflow)
870 : LHS.umul_ov(RHS, Overflow);
876 if (BuiltinOp == Builtin::BI__builtin_add_overflow ||
877 BuiltinOp == Builtin::BI__builtin_sub_overflow ||
878 BuiltinOp == Builtin::BI__builtin_mul_overflow) {
886 if (!APSInt::isSameValue(Temp,
Result))
896 assert(
Call->getDirectCallee()->getReturnType()->isBooleanType());
922 bool FirstOverflowed =
false;
923 bool SecondOverflowed =
false;
926 llvm_unreachable(
"Invalid value for BuiltinOp");
927 case Builtin::BI__builtin_addcb:
928 case Builtin::BI__builtin_addcs:
929 case Builtin::BI__builtin_addc:
930 case Builtin::BI__builtin_addcl:
931 case Builtin::BI__builtin_addcll:
933 LHS.uadd_ov(RHS, FirstOverflowed).uadd_ov(CarryIn, SecondOverflowed);
935 case Builtin::BI__builtin_subcb:
936 case Builtin::BI__builtin_subcs:
937 case Builtin::BI__builtin_subc:
938 case Builtin::BI__builtin_subcl:
939 case Builtin::BI__builtin_subcll:
941 LHS.usub_ov(RHS, FirstOverflowed).usub_ov(CarryIn, SecondOverflowed);
946 CarryOut = (uint64_t)(FirstOverflowed | SecondOverflowed);
948 QualType CarryOutType =
Call->getArg(3)->getType()->getPointeeType();
953 assert(
Call->getType() ==
Call->getArg(0)->getType());
960 unsigned BuiltinOp) {
962 std::optional<APSInt> Fallback;
963 if (BuiltinOp == Builtin::BI__builtin_clzg &&
Call->getNumArgs() == 2)
967 if (
Call->getArg(0)->getType()->isExtVectorBoolType()) {
976 bool ZeroIsUndefined = BuiltinOp != Builtin::BI__lzcnt16 &&
977 BuiltinOp != Builtin::BI__lzcnt &&
978 BuiltinOp != Builtin::BI__lzcnt64;
996 unsigned BuiltinID) {
997 std::optional<APSInt> Fallback;
998 if (BuiltinID == Builtin::BI__builtin_ctzg &&
Call->getNumArgs() == 2)
1002 if (
Call->getArg(0)->getType()->isExtVectorBoolType()) {
1025 assert(Val.getActiveBits() <= 64);
1036 unsigned BuiltinOp) {
1037 auto returnBool = [&S](
bool Value) ->
bool {
1056 if (Size.isPowerOfTwo()) {
1058 unsigned InlineWidthBits =
1065 return returnBool(
true);
1068 assert(BuiltinOp != Builtin::BI__c11_atomic_is_lock_free);
1070 return returnBool(
true);
1074 if (
APSInt(
APInt(64, IntVal,
false),
true).isAligned(Size.getAsAlign()))
1075 return returnBool(
true);
1078 const Expr *PtrArg =
Call->getArg(1);
1080 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(PtrArg)) {
1083 if (ICE->getCastKind() == CK_BitCast)
1084 PtrArg = ICE->getSubExpr();
1092 return returnBool(
true);
1098 if (BuiltinOp == Builtin::BI__atomic_always_lock_free)
1099 return returnBool(
false);
1112 if (Size.isPowerOfTwo()) {
1114 unsigned InlineWidthBits =
1135 Result.initializeAllElements();
1148 unsigned BuiltinOp) {
1151 if (Alignment < 0 || !Alignment.isPowerOf2()) {
1152 S.
FFDiag(
Call, diag::note_constexpr_invalid_alignment) << Alignment;
1156 APSInt MaxValue(APInt::getOneBitSet(SrcWidth, SrcWidth - 1));
1157 if (APSInt::compareValues(Alignment, MaxValue) > 0) {
1158 S.
FFDiag(
Call, diag::note_constexpr_alignment_too_big)
1159 << MaxValue <<
Call->getArg(0)->getType() << Alignment;
1168 APInt AlignMinusOne = Alignment.extOrTrunc(Src.getBitWidth()) - 1;
1169 if (BuiltinOp == Builtin::BI__builtin_align_up) {
1171 APSInt((Src + AlignMinusOne) & ~AlignMinusOne, Src.isUnsigned());
1173 }
else if (BuiltinOp == Builtin::BI__builtin_align_down) {
1174 APSInt AlignedVal =
APSInt(Src & ~AlignMinusOne, Src.isUnsigned());
1182 assert(FirstArgT ==
PT_Ptr);
1187 unsigned PtrOffset = Ptr.
getIndex();
1193 if (BuiltinOp == Builtin::BI__builtin_is_aligned) {
1208 S.
FFDiag(
Call->getArg(0), diag::note_constexpr_alignment_compute)
1213 assert(BuiltinOp == Builtin::BI__builtin_align_down ||
1214 BuiltinOp == Builtin::BI__builtin_align_up);
1229 assert(Alignment.getBitWidth() <= 64 &&
1230 "Cannot handle > 64-bit address-space");
1231 uint64_t Alignment64 = Alignment.getZExtValue();
1234 ? llvm::alignDown(PtrOffset, Alignment64)
1235 : llvm::alignTo(PtrOffset, Alignment64));
1242 S.
FFDiag(
Call->getArg(0), diag::note_constexpr_alignment_adjust) << Alignment;
1250 assert(
Call->getNumArgs() == 2 ||
Call->getNumArgs() == 3);
1252 std::optional<APSInt> ExtraOffset;
1253 if (
Call->getNumArgs() == 3)
1269 if (BaseAlignment < Align) {
1271 diag::note_constexpr_baa_insufficient_alignment)
1272 << 0 << BaseAlignment.
getQuantity() << Align.getQuantity();
1281 if (AVOffset.
alignTo(Align) != AVOffset) {
1284 diag::note_constexpr_baa_insufficient_alignment)
1285 << 1 << AVOffset.
getQuantity() << Align.getQuantity();
1288 diag::note_constexpr_baa_value_insufficient_alignment)
1300 if (
Call->getNumArgs() != 2 || !
Call->getArg(0)->getType()->isIntegerType() ||
1301 !
Call->getArg(1)->getType()->isIntegerType())
1307 unsigned BitWidth = Val.getBitWidth();
1308 uint64_t Shift = Index.extractBitsAsZExtValue(8, 0);
1309 uint64_t Length = Index.extractBitsAsZExtValue(8, 8);
1310 Length = Length > BitWidth ? BitWidth : Length;
1313 if (Length == 0 || Shift >= BitWidth) {
1318 uint64_t
Result = Val.getZExtValue() >> Shift;
1319 Result &= llvm::maskTrailingOnes<uint64_t>(Length);
1328 if (
Call->getNumArgs() != 2 || !
Call->getArg(0)->getType()->isIntegerType() ||
1329 !
Call->getArg(1)->getType()->isIntegerType() ||
1336 unsigned BitWidth = Val.getBitWidth();
1337 uint64_t Index = Idx.extractBitsAsZExtValue(8, 0);
1339 if (Index < BitWidth)
1340 Val.clearHighBits(BitWidth - Index);
1349 if (
Call->getNumArgs() != 2 || !
Call->getArg(0)->getType()->isIntegerType() ||
1350 !
Call->getArg(1)->getType()->isIntegerType())
1356 unsigned BitWidth = Val.getBitWidth();
1358 for (
unsigned I = 0, P = 0; I != BitWidth; ++I) {
1360 Result.setBitVal(I, Val[P++]);
1369 if (
Call->getNumArgs() != 2 || !
Call->getArg(0)->getType()->isIntegerType() ||
1370 !
Call->getArg(1)->getType()->isIntegerType())
1376 unsigned BitWidth = Val.getBitWidth();
1378 for (
unsigned I = 0, P = 0; I != BitWidth; ++I) {
1380 Result.setBitVal(P++, Val[I]);
1391 unsigned BuiltinOp) {
1392 if (
Call->getNumArgs() != 4 || !
Call->getArg(0)->getType()->isIntegerType() ||
1393 !
Call->getArg(1)->getType()->isIntegerType() ||
1394 !
Call->getArg(2)->getType()->isIntegerType())
1403 bool IsAdd = BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u32 ||
1404 BuiltinOp == clang::X86::BI__builtin_ia32_addcarryx_u64;
1406 unsigned BitWidth = LHS.getBitWidth();
1407 unsigned CarryInBit = CarryIn.ugt(0) ? 1 : 0;
1409 IsAdd ? (LHS.zext(BitWidth + 1) + (RHS.zext(BitWidth + 1) + CarryInBit))
1410 : (LHS.zext(BitWidth + 1) - (RHS.zext(BitWidth + 1) + CarryInBit));
1414 APSInt(ExResult.extractBits(1, BitWidth),
true);
1416 QualType CarryOutType =
Call->getArg(3)->getType()->getPointeeType();
1440 assert(Ptr.getFieldDesc()->isPrimitiveArray());
1444 assert(Ptr.getFieldDesc()->getNumElems() >= 1);
1445 StringRef R(&Ptr.deref<
char>(), Ptr.getFieldDesc()->getNumElems() - 1);
1446 uint64_t
Result = getPointerAuthStableSipHash(R);
1459 if (ElemType.isNull()) {
1461 ? diag::note_constexpr_new_untyped
1462 : diag::note_constexpr_new);
1467 if (ElemType->isIncompleteType() || ElemType->isFunctionType()) {
1468 S.
FFDiag(
Call, diag::note_constexpr_new_not_complete_object_type)
1469 << (ElemType->isIncompleteType() ? 0 : 1) << ElemType;
1476 unsigned NumArgs =
Call->getNumArgs();
1477 assert(NumArgs >= 1);
1480 if (
Call->getArg(NumArgs - 1)->getType()->isNothrowT())
1484 Args = Args.drop_front();
1487 for (
const Expr *Arg : Args)
1493 assert(!ElemSize.
isZero());
1496 APInt NumElems, Remainder;
1498 APInt::udivrem(
Bytes, ElemSizeAP, NumElems, Remainder);
1499 if (Remainder != 0) {
1501 S.
FFDiag(
Call, diag::note_constexpr_operator_new_bad_size)
1507 if (NumElems.getActiveBits() >
1512 S.
FFDiag(Loc, diag::note_constexpr_new_too_large)
1513 << NumElems.getZExtValue();
1520 bool IsArray = NumElems.ugt(1);
1525 Allocator.
allocate(NewCall, *ElemT, NumElems.getZExtValue(),
1562 const Expr *Source =
nullptr;
1563 const Block *BlockToDelete =
nullptr;
1581 S.
CCEDiag(
Call, diag::note_constexpr_deallocate_null);
1586 BlockToDelete = Ptr.
block();
1589 S.
FFDiag(
Call, diag::note_constexpr_delete_not_heap_alloc)
1592 S.
Note(D->getLocation(), diag::note_declared_at);
1595 assert(BlockToDelete);
1599 std::optional<DynamicAllocator::Form> AllocForm =
1602 if (!Allocator.
deallocate(Source, BlockToDelete, S)) {
1605 S.
FFDiag(Loc, diag::note_constexpr_double_delete);
1628 assert(
Call->getType() == ElemType);
1634 unsigned BitWidth =
Result.bitWidth();
1635 for (
unsigned I = 1; I != NumElems; ++I) {
1639 if (ID == Builtin::BI__builtin_reduce_add) {
1641 unsigned OverflowBits = BitWidth + 1;
1643 (PrevResult.toAPSInt(OverflowBits) +
1644 Elem.toAPSInt(OverflowBits)));
1647 }
else if (ID == Builtin::BI__builtin_reduce_mul) {
1649 unsigned OverflowBits = BitWidth * 2;
1651 (PrevResult.toAPSInt(OverflowBits) *
1652 Elem.toAPSInt(OverflowBits)));
1656 }
else if (ID == Builtin::BI__builtin_reduce_and) {
1658 }
else if (ID == Builtin::BI__builtin_reduce_or) {
1660 }
else if (ID == Builtin::BI__builtin_reduce_xor) {
1662 }
else if (ID == Builtin::BI__builtin_reduce_min) {
1665 }
else if (ID == Builtin::BI__builtin_reduce_max) {
1669 llvm_unreachable(
"Unhandled vector reduce builtin");
1681 unsigned BuiltinID) {
1682 assert(
Call->getNumArgs() == 1);
1698 assert(
Call->getArg(0)->getType()->isVectorType());
1710 for (
unsigned I = 0; I != NumElems; ++I) {
1713 Dst.
elem<
T>(I) = T::from(
static_cast<T>(
1731 unsigned BuiltinID) {
1732 assert(
Call->getNumArgs() == 1);
1733 if (
Call->getArg(0)->getType()->isIntegerType()) {
1736 if (BuiltinID == Builtin::BI__builtin_elementwise_popcount) {
1744 assert(
Call->getArg(0)->getType()->isVectorType());
1757 for (
unsigned I = 0; I != NumElems; ++I) {
1759 if (BuiltinID == Builtin::BI__builtin_elementwise_popcount) {
1760 Dst.
elem<
T>(I) = T::from(Arg.
elem<
T>(I).toAPSInt().popcount());
1763 T::from(Arg.
elem<
T>(I).toAPSInt().reverseBits().getZExtValue());
1777 unsigned BuiltinID) {
1778 const bool HasZeroArg =
Call->getNumArgs() == 2;
1779 const bool IsCTTZ = BuiltinID == Builtin::BI__builtin_elementwise_ctzg;
1780 assert(
Call->getNumArgs() == 1 || HasZeroArg);
1781 if (
Call->getArg(0)->getType()->isIntegerType()) {
1784 std::optional<APSInt> ZeroVal;
1798 diag::note_constexpr_countzeroes_zero)
1803 if (BuiltinID == Builtin::BI__builtin_elementwise_clzg) {
1814 assert(
Call->getArg(1)->getType()->isVectorType() &&
1816 Call->getArg(1)->getType()));
1821 assert(
Call->getArg(0)->getType()->isVectorType());
1834 for (
unsigned I = 0; I != NumElems; ++I) {
1837 if (EltVal.isZero()) {
1844 diag::note_constexpr_countzeroes_zero)
1848 }
else if (IsCTTZ) {
1849 Dst.
atIndex(I).
deref<
T>() = T::from(EltVal.countTrailingZeros());
1851 Dst.
atIndex(I).
deref<
T>() = T::from(EltVal.countLeadingZeros());
1863 assert(
Call->getNumArgs() == 3);
1869 assert(!Size.isSigned() &&
"memcpy and friends take an unsigned size");
1871 if (ID == Builtin::BImemcpy || ID == Builtin::BImemmove)
1875 (ID == Builtin::BI__builtin_memmove || ID == Builtin::BImemmove ||
1876 ID == Builtin::BI__builtin_wmemmove || ID == Builtin::BIwmemmove);
1877 bool WChar = ID == Builtin::BIwmemcpy || ID == Builtin::BIwmemmove ||
1878 ID == Builtin::BI__builtin_wmemcpy ||
1879 ID == Builtin::BI__builtin_wmemmove;
1882 if (Size.isZero()) {
1887 if (SrcPtr.
isZero() || DestPtr.isZero()) {
1890 << Move << WChar << !SrcPtr.
isZero()
1897 std::string DiagVal =
"(void *)";
1900 : std::to_string(DestPtr.getIntegerRepresentation());
1902 << Move << WChar << DestPtr.isIntegralPointer() << DiagVal;
1907 if (DestPtr.isDummy() || SrcPtr.
isDummy())
1910 if (DestPtr.getType()->isIncompleteType()) {
1912 diag::note_constexpr_memcpy_incomplete_type)
1913 << Move << DestPtr.getType();
1918 diag::note_constexpr_memcpy_incomplete_type)
1926 diag::note_constexpr_memcpy_incomplete_type)
1927 << Move << DestElemType;
1931 size_t RemainingDestElems;
1932 if (DestPtr.getFieldDesc()->isArray()) {
1933 RemainingDestElems = DestPtr.isUnknownSizeArray()
1935 : (DestPtr.getNumElems() - DestPtr.getIndex());
1937 RemainingDestElems = 1;
1942 uint64_t WCharSize =
1944 Size *=
APSInt(
APInt(Size.getBitWidth(), WCharSize,
false),
1948 if (Size.urem(DestElemSize) != 0) {
1950 diag::note_constexpr_memcpy_unsupported)
1951 << Move << WChar << 0 << DestElemType << Size << DestElemSize;
1956 size_t RemainingSrcElems;
1962 RemainingSrcElems = 1;
1968 << Move << SrcElemType << DestElemType;
1974 << Move << DestElemType;
1979 size_t RemainingDestBytes = RemainingDestElems * DestElemSize;
1980 size_t RemainingSrcBytes = RemainingSrcElems * SrcElemSize;
1981 if (Size.ugt(RemainingDestBytes) || Size.ugt(RemainingSrcBytes)) {
1982 APInt N = Size.udiv(DestElemSize);
1984 diag::note_constexpr_memcpy_unsupported)
1985 << Move << WChar << (Size.ugt(RemainingSrcBytes) ? 1 : 2)
1986 << DestElemType <<
toString(N, 10,
false);
2003 unsigned N = Size.getZExtValue();
2005 if ((SrcIndex <= DstIndex && (SrcIndex + N) > DstIndex) ||
2006 (DstIndex <= SrcIndex && (DstIndex + N) > SrcIndex)) {
2013 assert(Size.getZExtValue() % DestElemSize == 0);
2024 return T->isCharType() ||
T->isChar8Type();
2030 assert(
Call->getNumArgs() == 3);
2035 if (ID == Builtin::BImemcmp || ID == Builtin::BIbcmp ||
2036 ID == Builtin::BIwmemcmp)
2039 if (Size.isZero()) {
2045 (ID == Builtin::BIwmemcmp || ID == Builtin::BI__builtin_wmemcmp);
2055 diag::note_constexpr_memcmp_unsupported)
2061 if (PtrA.isDummy() || PtrB.
isDummy())
2084 unsigned ElemSize = 1;
2089 size_t ByteSize = Size.getZExtValue() * ElemSize;
2090 size_t CmpSize = std::min(MinBufferSize, ByteSize);
2092 for (
size_t I = 0; I != CmpSize; I += ElemSize) {
2095 T A = *reinterpret_cast<T *>(BufferA.Data.get() + I);
2096 T B = *reinterpret_cast<T *>(BufferB.Data.get() + I);
2098 pushInteger(S, -1, Call->getType());
2107 std::byte A = BufferA.
Data[I];
2108 std::byte B = BufferB.
Data[I];
2123 if (ByteSize <= CmpSize) {
2132 S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_past_end)
2133 <<
AK_Read << S.Current->getRange(OpPC);
2141 if (ID == Builtin::BImemchr || ID == Builtin::BIwcschr ||
2142 ID == Builtin::BIstrchr || ID == Builtin::BIwmemchr)
2145 std::optional<APSInt> MaxLength;
2146 if (
Call->getNumArgs() == 3)
2152 if (MaxLength && MaxLength->isZero()) {
2160 diag::note_constexpr_ltor_incomplete_type)
2175 bool IsRawByte = ID == Builtin::BImemchr || ID == Builtin::BI__builtin_memchr;
2180 diag::note_constexpr_memchr_unsupported)
2185 if (ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr) {
2195 uint64_t DesiredVal;
2196 if (ID == Builtin::BIwmemchr || ID == Builtin::BI__builtin_wmemchr ||
2197 ID == Builtin::BIwcschr || ID == Builtin::BI__builtin_wcschr) {
2199 DesiredVal = Desired.getZExtValue();
2205 (ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr ||
2206 ID == Builtin::BIwcschr || ID == Builtin::BI__builtin_wcschr);
2215 (Index + Step) > 0 ? Ptr.
atIndex(Index + Step) : Ptr;
2222 ElemT, {
V =
static_cast<uint64_t
>(ElemPtr.
deref<
T>().toUnsigned()); });
2224 if (
V == DesiredVal) {
2229 if (StopAtZero &&
V == 0)
2233 if (MaxLength && Step == MaxLength->getZExtValue())
2257 return std::nullopt;
2295 uint64_t FieldOffset =
2301 llvm_unreachable(
"Unhandled descriptor type");
2337 auto isFlexibleArrayMember = [&](
const Descriptor *FieldDesc) {
2339 FAMKind StrictFlexArraysLevel =
2342 if (StrictFlexArraysLevel == FAMKind::Default)
2345 unsigned NumElems = FieldDesc->getNumElems();
2346 if (NumElems == 0 && StrictFlexArraysLevel != FAMKind::IncompleteOnly)
2349 if (NumElems == 1 && StrictFlexArraysLevel == FAMKind::OneZeroOrIncomplete)
2359 isFlexibleArrayMember(FieldDesc);
2372 assert(Kind <= 3 &&
"unexpected kind");
2373 bool UseFieldDesc = (Kind & 1u);
2374 bool ReportMinimum = (Kind & 2u);
2377 if (
Call->getArg(0)->HasSideEffects(ASTCtx)) {
2395 if (!UseFieldDesc || DetermineForCompleteObject) {
2397 if (ReportMinimum && !DetermineForCompleteObject)
2420 unsigned ByteOffset;
2432 assert(ByteOffset <= *FullSize);
2433 unsigned Result = *FullSize - ByteOffset;
2448 bool CalledFromStd =
false;
2450 if (Callee && Callee->isInStdNamespace()) {
2452 CalledFromStd = Identifier && Identifier->
isStr(
"is_within_lifetime");
2457 diag::err_invalid_is_within_lifetime)
2458 << (CalledFromStd ?
"std::is_within_lifetime"
2459 :
"__builtin_is_within_lifetime")
2494 assert(
Call->getNumArgs() == 1);
2495 assert(
Call->getType()->isIntegerType());
2498 if (!
Call->getArg(0)->getType()->isVectorType()) {
2512 assert(
Call->getNumArgs() == 2);
2515 if (!
Call->getArg(0)->getType()->isVectorType()) {
2516 assert(!
Call->getArg(1)->getType()->isVectorType());
2524 const auto *VT =
Call->getArg(0)->getType()->castAs<
VectorType>();
2525 assert(VT->getElementType()->isIntegralOrEnumerationType());
2527 unsigned NumElems = VT->getNumElements();
2528 bool DestUnsigned =
Call->getType()->isUnsignedIntegerOrEnumerationType();
2531 if (!
Call->getArg(1)->getType()->isVectorType()) {
2532 assert(
Call->getArg(1)->getType()->isIntegralOrEnumerationType());
2538 for (
unsigned I = 0; I != NumElems; ++I) {
2540 Dst.elem<
T>(I) =
static_cast<T>(
2549 assert(
Call->getArg(0)->getType()->isVectorType() &&
2550 Call->getArg(1)->getType()->isVectorType());
2551 assert(VT->getElementType() ==
2553 assert(VT->getNumElements() ==
2555 assert(VT->getElementType()->isIntegralOrEnumerationType());
2560 for (
unsigned I = 0; I != NumElems; ++I) {
2562 APSInt Elem1 = LHS.elem<
T>(I).toAPSInt();
2564 Dst.elem<
T>(I) =
static_cast<T>(
APSInt(
Fn(Elem1, Elem2), DestUnsigned));
2574 llvm::function_ref<
APInt(
const APSInt &)> PackFn) {
2576 [[maybe_unused]]
const auto *VT1 =
2578 assert(VT0 && VT1 &&
"pack builtin VT0 and VT1 must be VectorType");
2581 "pack builtin VT0 and VT1 ElementType must be same");
2588 const unsigned SrcBits = ASTCtx.
getIntWidth(VT0->getElementType());
2589 const unsigned LHSVecLen = VT0->getNumElements();
2590 const unsigned SrcPerLane = 128 / SrcBits;
2591 const unsigned Lanes = LHSVecLen * SrcBits / 128;
2595 const bool IsUnsigend =
getElemType(Dst)->isUnsignedIntegerType();
2597 for (
unsigned Lane = 0; Lane != Lanes; ++Lane) {
2598 const unsigned BaseSrc = Lane * SrcPerLane;
2599 const unsigned BaseDst = Lane * (2 * SrcPerLane);
2601 for (
unsigned I = 0; I != SrcPerLane; ++I) {
2603 APSInt A = LHS.elem<
T>(BaseSrc + I).toAPSInt();
2607 APSInt(PackFn(A), IsUnsigend));
2608 assignInteger(S, Dst.atIndex(BaseDst + SrcPerLane + I), DstT,
2609 APSInt(PackFn(B), IsUnsigend));
2614 Dst.initializeAllElements();
2620 unsigned BuiltinID) {
2621 assert(
Call->getNumArgs() == 2);
2632 assert(!
Call->getArg(1)->getType()->isVectorType());
2636 if (BuiltinID == Builtin::BI__builtin_elementwise_max) {
2637 Result = std::max(LHS, RHS);
2638 }
else if (BuiltinID == Builtin::BI__builtin_elementwise_min) {
2639 Result = std::min(LHS, RHS);
2641 llvm_unreachable(
"Wrong builtin ID");
2649 assert(
Call->getArg(0)->getType()->isVectorType() &&
2650 Call->getArg(1)->getType()->isVectorType());
2651 const auto *VT =
Call->getArg(0)->getType()->castAs<
VectorType>();
2652 assert(VT->getElementType() ==
2654 assert(VT->getNumElements() ==
2656 assert(VT->getElementType()->isIntegralOrEnumerationType());
2662 unsigned NumElems = VT->getNumElements();
2663 for (
unsigned I = 0; I != NumElems; ++I) {
2667 Elem1 = LHS.elem<
T>(I).toAPSInt();
2668 Elem2 = RHS.
elem<
T>(I).toAPSInt();
2672 if (BuiltinID == Builtin::BI__builtin_elementwise_max) {
2674 Call->getType()->isUnsignedIntegerOrEnumerationType());
2675 }
else if (BuiltinID == Builtin::BI__builtin_elementwise_min) {
2677 Call->getType()->isUnsignedIntegerOrEnumerationType());
2679 llvm_unreachable(
"Wrong builtin ID");
2683 { Dst.elem<
T>(I) =
static_cast<T>(
Result); });
2685 Dst.initializeAllElements();
2692 unsigned BuiltinID) {
2693 assert(
Call->getArg(0)->getType()->isVectorType() &&
2694 Call->getArg(1)->getType()->isVectorType());
2699 const auto *VT =
Call->getArg(0)->getType()->castAs<
VectorType>();
2701 unsigned SourceLen = VT->getNumElements();
2705 unsigned DstElem = 0;
2706 for (
unsigned I = 0; I != SourceLen; I += 2) {
2710 Elem1 = LHS.elem<
T>(I).toAPSInt();
2711 Elem2 = RHS.
elem<
T>(I).toAPSInt();
2715 switch (BuiltinID) {
2716 case clang::X86::BI__builtin_ia32_pmuludq128:
2717 case clang::X86::BI__builtin_ia32_pmuludq256:
2718 case clang::X86::BI__builtin_ia32_pmuludq512:
2719 Result =
APSInt(llvm::APIntOps::muluExtended(Elem1, Elem2),
2722 case clang::X86::BI__builtin_ia32_pmuldq128:
2723 case clang::X86::BI__builtin_ia32_pmuldq256:
2724 case clang::X86::BI__builtin_ia32_pmuldq512:
2725 Result =
APSInt(llvm::APIntOps::mulsExtended(Elem1, Elem2),
2730 { Dst.elem<
T>(DstElem) =
static_cast<T>(
Result); });
2734 Dst.initializeAllElements();
2741 const APFloat &, llvm::RoundingMode)>
2743 assert(
Call->getNumArgs() == 3);
2780 assert(ElemT->isRealFloatingType());
2787 for (
unsigned I = 0; I != NumElems; ++I) {
2790 APFloat Y = VY.elem<
T>(I).getAPFloat();
2809 unsigned NumElems = LHS.getNumElems();
2810 PrimType ElemT = LHS.getFieldDesc()->getPrimType();
2813 for (
unsigned I = 0; I != NumElems; ++I) {
2821 Elem = Mask[I] ? LHS.elem<
T>(I).toAPSInt() : RHS.
elem<
T>(I).toAPSInt();
2824 { Dst.
elem<
T>(I) =
static_cast<T>(Elem); });
2839 assert(FalseVec.getNumElems() == TrueVec.
getNumElems());
2840 assert(FalseVec.getNumElems() == Dst.getNumElems());
2841 unsigned NumElems = FalseVec.getNumElems();
2842 PrimType ElemT = FalseVec.getFieldDesc()->getPrimType();
2843 PrimType DstElemT = Dst.getFieldDesc()->getPrimType();
2845 for (
unsigned I = 0; I != NumElems; ++I) {
2846 bool MaskBit = Mask[I % 8];
2852 assert(DstElemT == ElemT);
2855 static_cast<T>(MaskBit ? TrueVec.
elem<
T>(I).toAPSInt()
2856 : FalseVec.elem<
T>(I).toAPSInt());
2860 Dst.initializeAllElements();
2869 assert(
Call->getNumArgs() == 3);
2885 unsigned NumElems = VecT->getNumElements();
2886 bool DestUnsigned =
Call->getType()->isUnsignedIntegerOrEnumerationType();
2895 for (
unsigned I = 0; I != NumElems; ++I) {
2897 Dst.elem<
T>(I) =
static_cast<T>(
APSInt(
2898 Fn(Op0.elem<
T>(I).toAPSInt(), Op1.
elem<
T>(I).toAPSInt(), Op2),
2912 for (
unsigned I = 0; I != NumElems; ++I) {
2915 Val0 = Op0.elem<
T>(I).toAPSInt();
2916 Val1 = Op1.elem<
T>(I).toAPSInt();
2917 Val2 = Op2.
elem<
T>(I).toAPSInt();
2921 { Dst.elem<
T>(I) =
static_cast<T>(
Result); });
2931 assert(
Call->getNumArgs() == 3);
2934 uint64_t Index = ImmAPS.getZExtValue();
2949 assert(SubElements != 0 && BaseElements != 0 &&
2950 (BaseElements % SubElements) == 0);
2952 unsigned NumLanes = BaseElements / SubElements;
2953 unsigned Lane =
static_cast<unsigned>(Index % NumLanes);
2954 unsigned InsertPos = Lane * SubElements;
2959 for (
unsigned I = 0; I != BaseElements; ++I)
2961 for (
unsigned I = 0; I != SubElements; ++I)
2962 Dst.
elem<
T>(InsertPos + I) = SubVec.
elem<
T>(I);
2971 uint32_t BuiltinID) {
2976 switch (BuiltinID) {
2977 case Builtin::BI__builtin_is_constant_evaluated:
2980 case Builtin::BI__builtin_assume:
2981 case Builtin::BI__assume:
2984 case Builtin::BI__builtin_strcmp:
2985 case Builtin::BIstrcmp:
2986 case Builtin::BI__builtin_strncmp:
2987 case Builtin::BIstrncmp:
2988 case Builtin::BI__builtin_wcsncmp:
2989 case Builtin::BIwcsncmp:
2990 case Builtin::BI__builtin_wcscmp:
2991 case Builtin::BIwcscmp:
2994 case Builtin::BI__builtin_strlen:
2995 case Builtin::BIstrlen:
2996 case Builtin::BI__builtin_wcslen:
2997 case Builtin::BIwcslen:
3000 case Builtin::BI__builtin_nan:
3001 case Builtin::BI__builtin_nanf:
3002 case Builtin::BI__builtin_nanl:
3003 case Builtin::BI__builtin_nanf16:
3004 case Builtin::BI__builtin_nanf128:
3007 case Builtin::BI__builtin_nans:
3008 case Builtin::BI__builtin_nansf:
3009 case Builtin::BI__builtin_nansl:
3010 case Builtin::BI__builtin_nansf16:
3011 case Builtin::BI__builtin_nansf128:
3014 case Builtin::BI__builtin_huge_val:
3015 case Builtin::BI__builtin_huge_valf:
3016 case Builtin::BI__builtin_huge_vall:
3017 case Builtin::BI__builtin_huge_valf16:
3018 case Builtin::BI__builtin_huge_valf128:
3019 case Builtin::BI__builtin_inf:
3020 case Builtin::BI__builtin_inff:
3021 case Builtin::BI__builtin_infl:
3022 case Builtin::BI__builtin_inff16:
3023 case Builtin::BI__builtin_inff128:
3026 case Builtin::BI__builtin_copysign:
3027 case Builtin::BI__builtin_copysignf:
3028 case Builtin::BI__builtin_copysignl:
3029 case Builtin::BI__builtin_copysignf128:
3032 case Builtin::BI__builtin_fmin:
3033 case Builtin::BI__builtin_fminf:
3034 case Builtin::BI__builtin_fminl:
3035 case Builtin::BI__builtin_fminf16:
3036 case Builtin::BI__builtin_fminf128:
3039 case Builtin::BI__builtin_fminimum_num:
3040 case Builtin::BI__builtin_fminimum_numf:
3041 case Builtin::BI__builtin_fminimum_numl:
3042 case Builtin::BI__builtin_fminimum_numf16:
3043 case Builtin::BI__builtin_fminimum_numf128:
3046 case Builtin::BI__builtin_fmax:
3047 case Builtin::BI__builtin_fmaxf:
3048 case Builtin::BI__builtin_fmaxl:
3049 case Builtin::BI__builtin_fmaxf16:
3050 case Builtin::BI__builtin_fmaxf128:
3053 case Builtin::BI__builtin_fmaximum_num:
3054 case Builtin::BI__builtin_fmaximum_numf:
3055 case Builtin::BI__builtin_fmaximum_numl:
3056 case Builtin::BI__builtin_fmaximum_numf16:
3057 case Builtin::BI__builtin_fmaximum_numf128:
3060 case Builtin::BI__builtin_isnan:
3063 case Builtin::BI__builtin_issignaling:
3066 case Builtin::BI__builtin_isinf:
3069 case Builtin::BI__builtin_isinf_sign:
3072 case Builtin::BI__builtin_isfinite:
3075 case Builtin::BI__builtin_isnormal:
3078 case Builtin::BI__builtin_issubnormal:
3081 case Builtin::BI__builtin_iszero:
3084 case Builtin::BI__builtin_signbit:
3085 case Builtin::BI__builtin_signbitf:
3086 case Builtin::BI__builtin_signbitl:
3089 case Builtin::BI__builtin_isgreater:
3090 case Builtin::BI__builtin_isgreaterequal:
3091 case Builtin::BI__builtin_isless:
3092 case Builtin::BI__builtin_islessequal:
3093 case Builtin::BI__builtin_islessgreater:
3094 case Builtin::BI__builtin_isunordered:
3097 case Builtin::BI__builtin_isfpclass:
3100 case Builtin::BI__builtin_fpclassify:
3103 case Builtin::BI__builtin_fabs:
3104 case Builtin::BI__builtin_fabsf:
3105 case Builtin::BI__builtin_fabsl:
3106 case Builtin::BI__builtin_fabsf128:
3109 case Builtin::BI__builtin_abs:
3110 case Builtin::BI__builtin_labs:
3111 case Builtin::BI__builtin_llabs:
3114 case Builtin::BI__builtin_popcount:
3115 case Builtin::BI__builtin_popcountl:
3116 case Builtin::BI__builtin_popcountll:
3117 case Builtin::BI__builtin_popcountg:
3118 case Builtin::BI__popcnt16:
3119 case Builtin::BI__popcnt:
3120 case Builtin::BI__popcnt64:
3123 case Builtin::BI__builtin_parity:
3124 case Builtin::BI__builtin_parityl:
3125 case Builtin::BI__builtin_parityll:
3128 case Builtin::BI__builtin_clrsb:
3129 case Builtin::BI__builtin_clrsbl:
3130 case Builtin::BI__builtin_clrsbll:
3133 case Builtin::BI__builtin_bitreverse8:
3134 case Builtin::BI__builtin_bitreverse16:
3135 case Builtin::BI__builtin_bitreverse32:
3136 case Builtin::BI__builtin_bitreverse64:
3139 case Builtin::BI__builtin_classify_type:
3142 case Builtin::BI__builtin_expect:
3143 case Builtin::BI__builtin_expect_with_probability:
3146 case Builtin::BI__builtin_rotateleft8:
3147 case Builtin::BI__builtin_rotateleft16:
3148 case Builtin::BI__builtin_rotateleft32:
3149 case Builtin::BI__builtin_rotateleft64:
3150 case Builtin::BI_rotl8:
3151 case Builtin::BI_rotl16:
3152 case Builtin::BI_rotl:
3153 case Builtin::BI_lrotl:
3154 case Builtin::BI_rotl64:
3157 case Builtin::BI__builtin_rotateright8:
3158 case Builtin::BI__builtin_rotateright16:
3159 case Builtin::BI__builtin_rotateright32:
3160 case Builtin::BI__builtin_rotateright64:
3161 case Builtin::BI_rotr8:
3162 case Builtin::BI_rotr16:
3163 case Builtin::BI_rotr:
3164 case Builtin::BI_lrotr:
3165 case Builtin::BI_rotr64:
3168 case Builtin::BI__builtin_ffs:
3169 case Builtin::BI__builtin_ffsl:
3170 case Builtin::BI__builtin_ffsll:
3173 case Builtin::BIaddressof:
3174 case Builtin::BI__addressof:
3175 case Builtin::BI__builtin_addressof:
3179 case Builtin::BIas_const:
3180 case Builtin::BIforward:
3181 case Builtin::BIforward_like:
3182 case Builtin::BImove:
3183 case Builtin::BImove_if_noexcept:
3187 case Builtin::BI__builtin_eh_return_data_regno:
3190 case Builtin::BI__builtin_launder:
3194 case Builtin::BI__builtin_add_overflow:
3195 case Builtin::BI__builtin_sub_overflow:
3196 case Builtin::BI__builtin_mul_overflow:
3197 case Builtin::BI__builtin_sadd_overflow:
3198 case Builtin::BI__builtin_uadd_overflow:
3199 case Builtin::BI__builtin_uaddl_overflow:
3200 case Builtin::BI__builtin_uaddll_overflow:
3201 case Builtin::BI__builtin_usub_overflow:
3202 case Builtin::BI__builtin_usubl_overflow:
3203 case Builtin::BI__builtin_usubll_overflow:
3204 case Builtin::BI__builtin_umul_overflow:
3205 case Builtin::BI__builtin_umull_overflow:
3206 case Builtin::BI__builtin_umulll_overflow:
3207 case Builtin::BI__builtin_saddl_overflow:
3208 case Builtin::BI__builtin_saddll_overflow:
3209 case Builtin::BI__builtin_ssub_overflow:
3210 case Builtin::BI__builtin_ssubl_overflow:
3211 case Builtin::BI__builtin_ssubll_overflow:
3212 case Builtin::BI__builtin_smul_overflow:
3213 case Builtin::BI__builtin_smull_overflow:
3214 case Builtin::BI__builtin_smulll_overflow:
3217 case Builtin::BI__builtin_addcb:
3218 case Builtin::BI__builtin_addcs:
3219 case Builtin::BI__builtin_addc:
3220 case Builtin::BI__builtin_addcl:
3221 case Builtin::BI__builtin_addcll:
3222 case Builtin::BI__builtin_subcb:
3223 case Builtin::BI__builtin_subcs:
3224 case Builtin::BI__builtin_subc:
3225 case Builtin::BI__builtin_subcl:
3226 case Builtin::BI__builtin_subcll:
3229 case Builtin::BI__builtin_clz:
3230 case Builtin::BI__builtin_clzl:
3231 case Builtin::BI__builtin_clzll:
3232 case Builtin::BI__builtin_clzs:
3233 case Builtin::BI__builtin_clzg:
3234 case Builtin::BI__lzcnt16:
3235 case Builtin::BI__lzcnt:
3236 case Builtin::BI__lzcnt64:
3239 case Builtin::BI__builtin_ctz:
3240 case Builtin::BI__builtin_ctzl:
3241 case Builtin::BI__builtin_ctzll:
3242 case Builtin::BI__builtin_ctzs:
3243 case Builtin::BI__builtin_ctzg:
3246 case Builtin::BI__builtin_elementwise_clzg:
3247 case Builtin::BI__builtin_elementwise_ctzg:
3251 case Builtin::BI__builtin_bswap16:
3252 case Builtin::BI__builtin_bswap32:
3253 case Builtin::BI__builtin_bswap64:
3256 case Builtin::BI__atomic_always_lock_free:
3257 case Builtin::BI__atomic_is_lock_free:
3260 case Builtin::BI__c11_atomic_is_lock_free:
3263 case Builtin::BI__builtin_complex:
3266 case Builtin::BI__builtin_is_aligned:
3267 case Builtin::BI__builtin_align_up:
3268 case Builtin::BI__builtin_align_down:
3271 case Builtin::BI__builtin_assume_aligned:
3274 case clang::X86::BI__builtin_ia32_bextr_u32:
3275 case clang::X86::BI__builtin_ia32_bextr_u64:
3276 case clang::X86::BI__builtin_ia32_bextri_u32:
3277 case clang::X86::BI__builtin_ia32_bextri_u64:
3280 case clang::X86::BI__builtin_ia32_bzhi_si:
3281 case clang::X86::BI__builtin_ia32_bzhi_di:
3284 case clang::X86::BI__builtin_ia32_lzcnt_u16:
3285 case clang::X86::BI__builtin_ia32_lzcnt_u32:
3286 case clang::X86::BI__builtin_ia32_lzcnt_u64:
3289 return APInt(Src.getBitWidth(), Src.countLeadingZeros());
3292 case clang::X86::BI__builtin_ia32_tzcnt_u16:
3293 case clang::X86::BI__builtin_ia32_tzcnt_u32:
3294 case clang::X86::BI__builtin_ia32_tzcnt_u64:
3297 return APInt(Src.getBitWidth(), Src.countTrailingZeros());
3300 case clang::X86::BI__builtin_ia32_pdep_si:
3301 case clang::X86::BI__builtin_ia32_pdep_di:
3304 case clang::X86::BI__builtin_ia32_pext_si:
3305 case clang::X86::BI__builtin_ia32_pext_di:
3308 case clang::X86::BI__builtin_ia32_addcarryx_u32:
3309 case clang::X86::BI__builtin_ia32_addcarryx_u64:
3310 case clang::X86::BI__builtin_ia32_subborrow_u32:
3311 case clang::X86::BI__builtin_ia32_subborrow_u64:
3315 case Builtin::BI__builtin_os_log_format_buffer_size:
3318 case Builtin::BI__builtin_ptrauth_string_discriminator:
3321 case Builtin::BI__noop:
3325 case Builtin::BI__builtin_operator_new:
3328 case Builtin::BI__builtin_operator_delete:
3331 case Builtin::BI__arithmetic_fence:
3334 case Builtin::BI__builtin_reduce_add:
3335 case Builtin::BI__builtin_reduce_mul:
3336 case Builtin::BI__builtin_reduce_and:
3337 case Builtin::BI__builtin_reduce_or:
3338 case Builtin::BI__builtin_reduce_xor:
3339 case Builtin::BI__builtin_reduce_min:
3340 case Builtin::BI__builtin_reduce_max:
3343 case Builtin::BI__builtin_elementwise_popcount:
3344 case Builtin::BI__builtin_elementwise_bitreverse:
3348 case Builtin::BI__builtin_elementwise_abs:
3351 case Builtin::BI__builtin_memcpy:
3352 case Builtin::BImemcpy:
3353 case Builtin::BI__builtin_wmemcpy:
3354 case Builtin::BIwmemcpy:
3355 case Builtin::BI__builtin_memmove:
3356 case Builtin::BImemmove:
3357 case Builtin::BI__builtin_wmemmove:
3358 case Builtin::BIwmemmove:
3361 case Builtin::BI__builtin_memcmp:
3362 case Builtin::BImemcmp:
3363 case Builtin::BI__builtin_bcmp:
3364 case Builtin::BIbcmp:
3365 case Builtin::BI__builtin_wmemcmp:
3366 case Builtin::BIwmemcmp:
3369 case Builtin::BImemchr:
3370 case Builtin::BI__builtin_memchr:
3371 case Builtin::BIstrchr:
3372 case Builtin::BI__builtin_strchr:
3373 case Builtin::BIwmemchr:
3374 case Builtin::BI__builtin_wmemchr:
3375 case Builtin::BIwcschr:
3376 case Builtin::BI__builtin_wcschr:
3377 case Builtin::BI__builtin_char_memchr:
3380 case Builtin::BI__builtin_object_size:
3381 case Builtin::BI__builtin_dynamic_object_size:
3384 case Builtin::BI__builtin_is_within_lifetime:
3387 case Builtin::BI__builtin_elementwise_add_sat:
3390 return LHS.isSigned() ? LHS.sadd_sat(RHS) : LHS.uadd_sat(RHS);
3393 case Builtin::BI__builtin_elementwise_sub_sat:
3396 return LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS);
3399 case clang::X86::BI__builtin_ia32_pavgb128:
3400 case clang::X86::BI__builtin_ia32_pavgw128:
3401 case clang::X86::BI__builtin_ia32_pavgb256:
3402 case clang::X86::BI__builtin_ia32_pavgw256:
3403 case clang::X86::BI__builtin_ia32_pavgb512:
3404 case clang::X86::BI__builtin_ia32_pavgw512:
3406 llvm::APIntOps::avgCeilU);
3408 case clang::X86::BI__builtin_ia32_pmulhuw128:
3409 case clang::X86::BI__builtin_ia32_pmulhuw256:
3410 case clang::X86::BI__builtin_ia32_pmulhuw512:
3412 llvm::APIntOps::mulhu);
3414 case clang::X86::BI__builtin_ia32_pmulhw128:
3415 case clang::X86::BI__builtin_ia32_pmulhw256:
3416 case clang::X86::BI__builtin_ia32_pmulhw512:
3418 llvm::APIntOps::mulhs);
3420 case clang::X86::BI__builtin_ia32_psllv2di:
3421 case clang::X86::BI__builtin_ia32_psllv4di:
3422 case clang::X86::BI__builtin_ia32_psllv4si:
3423 case clang::X86::BI__builtin_ia32_psllv8di:
3424 case clang::X86::BI__builtin_ia32_psllv8hi:
3425 case clang::X86::BI__builtin_ia32_psllv8si:
3426 case clang::X86::BI__builtin_ia32_psllv16hi:
3427 case clang::X86::BI__builtin_ia32_psllv16si:
3428 case clang::X86::BI__builtin_ia32_psllv32hi:
3429 case clang::X86::BI__builtin_ia32_psllwi128:
3430 case clang::X86::BI__builtin_ia32_psllwi256:
3431 case clang::X86::BI__builtin_ia32_psllwi512:
3432 case clang::X86::BI__builtin_ia32_pslldi128:
3433 case clang::X86::BI__builtin_ia32_pslldi256:
3434 case clang::X86::BI__builtin_ia32_pslldi512:
3435 case clang::X86::BI__builtin_ia32_psllqi128:
3436 case clang::X86::BI__builtin_ia32_psllqi256:
3437 case clang::X86::BI__builtin_ia32_psllqi512:
3440 if (RHS.uge(LHS.getBitWidth())) {
3441 return APInt::getZero(LHS.getBitWidth());
3443 return LHS.shl(RHS.getZExtValue());
3446 case clang::X86::BI__builtin_ia32_psrav4si:
3447 case clang::X86::BI__builtin_ia32_psrav8di:
3448 case clang::X86::BI__builtin_ia32_psrav8hi:
3449 case clang::X86::BI__builtin_ia32_psrav8si:
3450 case clang::X86::BI__builtin_ia32_psrav16hi:
3451 case clang::X86::BI__builtin_ia32_psrav16si:
3452 case clang::X86::BI__builtin_ia32_psrav32hi:
3453 case clang::X86::BI__builtin_ia32_psravq128:
3454 case clang::X86::BI__builtin_ia32_psravq256:
3455 case clang::X86::BI__builtin_ia32_psrawi128:
3456 case clang::X86::BI__builtin_ia32_psrawi256:
3457 case clang::X86::BI__builtin_ia32_psrawi512:
3458 case clang::X86::BI__builtin_ia32_psradi128:
3459 case clang::X86::BI__builtin_ia32_psradi256:
3460 case clang::X86::BI__builtin_ia32_psradi512:
3461 case clang::X86::BI__builtin_ia32_psraqi128:
3462 case clang::X86::BI__builtin_ia32_psraqi256:
3463 case clang::X86::BI__builtin_ia32_psraqi512:
3466 if (RHS.uge(LHS.getBitWidth())) {
3467 return LHS.ashr(LHS.getBitWidth() - 1);
3469 return LHS.ashr(RHS.getZExtValue());
3472 case clang::X86::BI__builtin_ia32_psrlv2di:
3473 case clang::X86::BI__builtin_ia32_psrlv4di:
3474 case clang::X86::BI__builtin_ia32_psrlv4si:
3475 case clang::X86::BI__builtin_ia32_psrlv8di:
3476 case clang::X86::BI__builtin_ia32_psrlv8hi:
3477 case clang::X86::BI__builtin_ia32_psrlv8si:
3478 case clang::X86::BI__builtin_ia32_psrlv16hi:
3479 case clang::X86::BI__builtin_ia32_psrlv16si:
3480 case clang::X86::BI__builtin_ia32_psrlv32hi:
3481 case clang::X86::BI__builtin_ia32_psrlwi128:
3482 case clang::X86::BI__builtin_ia32_psrlwi256:
3483 case clang::X86::BI__builtin_ia32_psrlwi512:
3484 case clang::X86::BI__builtin_ia32_psrldi128:
3485 case clang::X86::BI__builtin_ia32_psrldi256:
3486 case clang::X86::BI__builtin_ia32_psrldi512:
3487 case clang::X86::BI__builtin_ia32_psrlqi128:
3488 case clang::X86::BI__builtin_ia32_psrlqi256:
3489 case clang::X86::BI__builtin_ia32_psrlqi512:
3492 if (RHS.uge(LHS.getBitWidth())) {
3493 return APInt::getZero(LHS.getBitWidth());
3495 return LHS.lshr(RHS.getZExtValue());
3497 case clang::X86::BI__builtin_ia32_packsswb128:
3498 case clang::X86::BI__builtin_ia32_packsswb256:
3499 case clang::X86::BI__builtin_ia32_packsswb512:
3500 case clang::X86::BI__builtin_ia32_packssdw128:
3501 case clang::X86::BI__builtin_ia32_packssdw256:
3502 case clang::X86::BI__builtin_ia32_packssdw512:
3504 return APInt(Src).truncSSat(Src.getBitWidth() / 2);
3506 case clang::X86::BI__builtin_ia32_packusdw128:
3507 case clang::X86::BI__builtin_ia32_packusdw256:
3508 case clang::X86::BI__builtin_ia32_packusdw512:
3509 case clang::X86::BI__builtin_ia32_packuswb128:
3510 case clang::X86::BI__builtin_ia32_packuswb256:
3511 case clang::X86::BI__builtin_ia32_packuswb512:
3513 unsigned DstBits = Src.getBitWidth() / 2;
3514 if (Src.isNegative())
3515 return APInt::getZero(DstBits);
3516 if (Src.isIntN(DstBits))
3517 return APInt(Src).trunc(DstBits);
3518 return APInt::getAllOnes(DstBits);
3521 case clang::X86::BI__builtin_ia32_vprotbi:
3522 case clang::X86::BI__builtin_ia32_vprotdi:
3523 case clang::X86::BI__builtin_ia32_vprotqi:
3524 case clang::X86::BI__builtin_ia32_vprotwi:
3525 case clang::X86::BI__builtin_ia32_prold128:
3526 case clang::X86::BI__builtin_ia32_prold256:
3527 case clang::X86::BI__builtin_ia32_prold512:
3528 case clang::X86::BI__builtin_ia32_prolq128:
3529 case clang::X86::BI__builtin_ia32_prolq256:
3530 case clang::X86::BI__builtin_ia32_prolq512:
3533 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS.rotl(RHS); });
3535 case clang::X86::BI__builtin_ia32_prord128:
3536 case clang::X86::BI__builtin_ia32_prord256:
3537 case clang::X86::BI__builtin_ia32_prord512:
3538 case clang::X86::BI__builtin_ia32_prorq128:
3539 case clang::X86::BI__builtin_ia32_prorq256:
3540 case clang::X86::BI__builtin_ia32_prorq512:
3543 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS.rotr(RHS); });
3545 case Builtin::BI__builtin_elementwise_max:
3546 case Builtin::BI__builtin_elementwise_min:
3549 case clang::X86::BI__builtin_ia32_pmuldq128:
3550 case clang::X86::BI__builtin_ia32_pmuldq256:
3551 case clang::X86::BI__builtin_ia32_pmuldq512:
3552 case clang::X86::BI__builtin_ia32_pmuludq128:
3553 case clang::X86::BI__builtin_ia32_pmuludq256:
3554 case clang::X86::BI__builtin_ia32_pmuludq512:
3557 case Builtin::BI__builtin_elementwise_fma:
3561 llvm::RoundingMode RM) {
3563 F.fusedMultiplyAdd(Y, Z, RM);
3567 case X86::BI__builtin_ia32_vpshldd128:
3568 case X86::BI__builtin_ia32_vpshldd256:
3569 case X86::BI__builtin_ia32_vpshldd512:
3570 case X86::BI__builtin_ia32_vpshldq128:
3571 case X86::BI__builtin_ia32_vpshldq256:
3572 case X86::BI__builtin_ia32_vpshldq512:
3573 case X86::BI__builtin_ia32_vpshldw128:
3574 case X86::BI__builtin_ia32_vpshldw256:
3575 case X86::BI__builtin_ia32_vpshldw512:
3579 return llvm::APIntOps::fshl(Hi, Lo, Amt);
3582 case X86::BI__builtin_ia32_vpshrdd128:
3583 case X86::BI__builtin_ia32_vpshrdd256:
3584 case X86::BI__builtin_ia32_vpshrdd512:
3585 case X86::BI__builtin_ia32_vpshrdq128:
3586 case X86::BI__builtin_ia32_vpshrdq256:
3587 case X86::BI__builtin_ia32_vpshrdq512:
3588 case X86::BI__builtin_ia32_vpshrdw128:
3589 case X86::BI__builtin_ia32_vpshrdw256:
3590 case X86::BI__builtin_ia32_vpshrdw512:
3595 return llvm::APIntOps::fshr(Hi, Lo, Amt);
3598 case clang::X86::BI__builtin_ia32_blendpd:
3599 case clang::X86::BI__builtin_ia32_blendpd256:
3600 case clang::X86::BI__builtin_ia32_blendps:
3601 case clang::X86::BI__builtin_ia32_blendps256:
3602 case clang::X86::BI__builtin_ia32_pblendw128:
3603 case clang::X86::BI__builtin_ia32_pblendw256:
3604 case clang::X86::BI__builtin_ia32_pblendd128:
3605 case clang::X86::BI__builtin_ia32_pblendd256:
3608 case clang::X86::BI__builtin_ia32_blendvpd:
3609 case clang::X86::BI__builtin_ia32_blendvpd256:
3610 case clang::X86::BI__builtin_ia32_blendvps:
3611 case clang::X86::BI__builtin_ia32_blendvps256:
3615 llvm::RoundingMode) {
return C.isNegative() ?
T : F; });
3617 case clang::X86::BI__builtin_ia32_pblendvb128:
3618 case clang::X86::BI__builtin_ia32_pblendvb256:
3621 return ((
APInt)
C).isNegative() ?
T : F;
3624 case X86::BI__builtin_ia32_selectb_128:
3625 case X86::BI__builtin_ia32_selectb_256:
3626 case X86::BI__builtin_ia32_selectb_512:
3627 case X86::BI__builtin_ia32_selectw_128:
3628 case X86::BI__builtin_ia32_selectw_256:
3629 case X86::BI__builtin_ia32_selectw_512:
3630 case X86::BI__builtin_ia32_selectd_128:
3631 case X86::BI__builtin_ia32_selectd_256:
3632 case X86::BI__builtin_ia32_selectd_512:
3633 case X86::BI__builtin_ia32_selectq_128:
3634 case X86::BI__builtin_ia32_selectq_256:
3635 case X86::BI__builtin_ia32_selectq_512:
3636 case X86::BI__builtin_ia32_selectph_128:
3637 case X86::BI__builtin_ia32_selectph_256:
3638 case X86::BI__builtin_ia32_selectph_512:
3639 case X86::BI__builtin_ia32_selectpbf_128:
3640 case X86::BI__builtin_ia32_selectpbf_256:
3641 case X86::BI__builtin_ia32_selectpbf_512:
3642 case X86::BI__builtin_ia32_selectps_128:
3643 case X86::BI__builtin_ia32_selectps_256:
3644 case X86::BI__builtin_ia32_selectps_512:
3645 case X86::BI__builtin_ia32_selectpd_128:
3646 case X86::BI__builtin_ia32_selectpd_256:
3647 case X86::BI__builtin_ia32_selectpd_512:
3650 case X86::BI__builtin_ia32_kandqi:
3651 case X86::BI__builtin_ia32_kandhi:
3652 case X86::BI__builtin_ia32_kandsi:
3653 case X86::BI__builtin_ia32_kanddi:
3656 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS & RHS; });
3658 case X86::BI__builtin_ia32_kandnqi:
3659 case X86::BI__builtin_ia32_kandnhi:
3660 case X86::BI__builtin_ia32_kandnsi:
3661 case X86::BI__builtin_ia32_kandndi:
3664 [](
const APSInt &LHS,
const APSInt &RHS) {
return ~LHS & RHS; });
3666 case X86::BI__builtin_ia32_korqi:
3667 case X86::BI__builtin_ia32_korhi:
3668 case X86::BI__builtin_ia32_korsi:
3669 case X86::BI__builtin_ia32_kordi:
3672 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS | RHS; });
3674 case X86::BI__builtin_ia32_kxnorqi:
3675 case X86::BI__builtin_ia32_kxnorhi:
3676 case X86::BI__builtin_ia32_kxnorsi:
3677 case X86::BI__builtin_ia32_kxnordi:
3680 [](
const APSInt &LHS,
const APSInt &RHS) {
return ~(LHS ^ RHS); });
3682 case X86::BI__builtin_ia32_kxorqi:
3683 case X86::BI__builtin_ia32_kxorhi:
3684 case X86::BI__builtin_ia32_kxorsi:
3685 case X86::BI__builtin_ia32_kxordi:
3688 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS ^ RHS; });
3690 case X86::BI__builtin_ia32_knotqi:
3691 case X86::BI__builtin_ia32_knothi:
3692 case X86::BI__builtin_ia32_knotsi:
3693 case X86::BI__builtin_ia32_knotdi:
3695 S, OpPC,
Call, [](
const APSInt &Src) {
return ~Src; });
3697 case X86::BI__builtin_ia32_kaddqi:
3698 case X86::BI__builtin_ia32_kaddhi:
3699 case X86::BI__builtin_ia32_kaddsi:
3700 case X86::BI__builtin_ia32_kadddi:
3703 [](
const APSInt &LHS,
const APSInt &RHS) {
return LHS + RHS; });
3705 case Builtin::BI__builtin_elementwise_fshl:
3707 llvm::APIntOps::fshl);
3708 case Builtin::BI__builtin_elementwise_fshr:
3710 llvm::APIntOps::fshr);
3712 case X86::BI__builtin_ia32_insertf32x4_256:
3713 case X86::BI__builtin_ia32_inserti32x4_256:
3714 case X86::BI__builtin_ia32_insertf64x2_256:
3715 case X86::BI__builtin_ia32_inserti64x2_256:
3716 case X86::BI__builtin_ia32_insertf32x4:
3717 case X86::BI__builtin_ia32_inserti32x4:
3718 case X86::BI__builtin_ia32_insertf64x2_512:
3719 case X86::BI__builtin_ia32_inserti64x2_512:
3720 case X86::BI__builtin_ia32_insertf32x8:
3721 case X86::BI__builtin_ia32_inserti32x8:
3722 case X86::BI__builtin_ia32_insertf64x4:
3723 case X86::BI__builtin_ia32_inserti64x4:
3724 case X86::BI__builtin_ia32_vinsertf128_ps256:
3725 case X86::BI__builtin_ia32_vinsertf128_pd256:
3726 case X86::BI__builtin_ia32_vinsertf128_si256:
3727 case X86::BI__builtin_ia32_insert128i256:
3732 diag::note_invalid_subexpr_in_const_expr)
3738 llvm_unreachable(
"Unhandled builtin ID");
3747 unsigned ArrayIndex = 0;
3749 for (
unsigned I = 0; I != N; ++I) {
3755 if (!RD || RD->isInvalidDecl())
3759 assert(FieldIndex < RL.
getFieldCount() &&
"offsetof field in wrong type");
3768 int64_t Index = ArrayIndices[ArrayIndex];
3774 Result += Index * ElementSize;
3785 if (!RD || RD->isInvalidDecl())
3790 CurrentType = BaseSpec->
getType();
3800 llvm_unreachable(
"Dependent OffsetOfExpr?");
3804 IntResult =
Result.getQuantity();
3821 FieldPtr.
deref<
T>() = T::from(IntValue.getSExtValue()));
3831 Dest.deref<T>().~T();
3832 new (&Dest.deref<T>()) T();
3839 for (
const Record::Field &F : R->
fields()) {
3847 for (
unsigned I = 0, N = Desc->
getNumElems(); I != N; ++I) {
3849 Dest.deref<T>().~T();
3850 new (&Dest.deref<T>()) T();
3857 for (
unsigned I = 0, N = Desc->
getNumElems(); I != N; ++I) {
3865static bool copyComposite(InterpState &S, CodePtr OpPC,
const Pointer &Src,
3866 Pointer &Dest,
bool Activate);
3872 auto copyField = [&](
const Record::Field &F,
bool Activate) ->
bool {
3891 for (
const Record::Field &F : R->
fields()) {
3896 if (!copyField(F,
true))
3910 for (
const Record::Base &B : R->
bases()) {
3933 for (
unsigned I = 0, N = DestDesc->
getNumElems(); I != N; ++I) {
3946 for (
unsigned I = 0, N = DestDesc->
getNumElems(); I != N; ++I) {
Defines enum values for all the target-independent builtin functions.
GCCTypeClass
Values returned by __builtin_classify_type, chosen to match the values produced by GCC's builtin.
CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E, UnaryExprOrTypeTrait ExprKind)
GCCTypeClass EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts)
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
static bool isOneByteCharacterType(QualType T)
static bool isUserWritingOffTheEnd(const ASTContext &Ctx, const LValue &LVal)
Attempts to detect a user writing into a piece of memory that's impossible to figure out the size of ...
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.
#define INT_TYPE_SWITCH_NO_BOOL(Expr, B)
#define INT_TYPE_SWITCH(Expr, B)
#define TYPE_SWITCH(Expr, B)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static QualType getPointeeType(const MemRegion *R)
Enumerates target-specific builtins in their own namespaces within namespace clang.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
CharUnits & getLValueOffset()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
unsigned getIntWidth(QualType T) const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
QualType getWCharType() const
Return the unique wchar_t type available in C++ (and available as __wchar_t as a Microsoft extension)...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
const TargetInfo & getTargetInfo() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
CanQualType getCanonicalTagType(const TagDecl *TD) const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
std::string getQuotedName(unsigned ID) const
Return the identifier name for the specified builtin inside single quotes for a diagnostic,...
bool isConstantEvaluated(unsigned ID) const
Return true if this function can be constant evaluated by Clang frontend.
Represents a base class of a C++ class.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits One()
One - Construct a CharUnits quantity of one.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits alignTo(const CharUnits &Align) const
alignTo - Returns the next integer (mod 2**64) that is greater than or equal to this quantity and is ...
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StrictFlexArraysLevelKind
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
const OffsetOfNode & getComponent(unsigned Idx) const
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
FieldDecl * getField() const
For a field offsetof node, returns the field.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Kind getKind() const
Determine what kind of offsetof node this is.
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
virtual int getEHDataRegisterNumber(unsigned RegNo) const
Return the register number that __builtin_eh_return_regno would return with the specified argument.
virtual bool isNan2008() const
Returns true if NaN encoding is IEEE 754-2008.
QualType getType() const
Return the type wrapped by this type source info.
bool isBooleanType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isVectorType() const
bool isFloatingType() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
A memory block, either on the stack or in the heap.
const Descriptor * getDescriptor() const
Returns the block's descriptor.
Wrapper around boolean types.
static Boolean from(T Value)
Pointer into the code segment.
const LangOptions & getLangOpts() const
Returns the language options.
OptPrimType classify(QualType T) const
Classifies a type.
unsigned getEvalID() const
Manages dynamic memory allocations done during bytecode interpretation.
bool deallocate(const Expr *Source, const Block *BlockToDelete, InterpState &S)
Deallocate the given source+block combination.
std::optional< Form > getAllocationForm(const Expr *Source) const
Checks whether the allocation done at the given source is an array allocation.
Block * allocate(const Descriptor *D, unsigned EvalID, Form AllocForm)
Allocate ONE element of the given descriptor.
If a Floating is constructed from Memory, it DOES NOT OWN THAT MEMORY.
void copy(const APFloat &F)
llvm::FPClassTest classify() const
ComparisonCategoryResult compare(const Floating &RHS) const
APFloat::fltCategory getCategory() const
APFloat getAPFloat() const
Base class for stack frames, shared between VM and walker.
virtual const FunctionDecl * getCallee() const =0
Returns the called function's declaration.
If an IntegralAP is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Frame storing local variables.
const Expr * getExpr(CodePtr PC) const
InterpFrame * Caller
The frame of the previous function.
SourceInfo getSource(CodePtr PC) const
Map a location to a source.
CodePtr getRetPC() const
Returns the return address of the frame.
SourceLocation getLocation(CodePtr PC) const
SourceRange getRange(CodePtr PC) const
unsigned getDepth() const
const FunctionDecl * getCallee() const override
Returns the caller.
Stack frame storing temporaries and parameters.
T pop()
Returns the value from the top of the stack and removes it.
void push(Tys &&...Args)
Constructs a value in place on the top of the stack.
void discard()
Discards the top value from the stack.
T & peek() const
Returns a reference to the value on the top of the stack.
Expr::EvalStatus & getEvalStatus() const override
Context & getContext() const
DynamicAllocator & getAllocator()
Context & Ctx
Interpreter Context.
Floating allocFloat(const llvm::fltSemantics &Sem)
llvm::SmallVector< const Block * > InitializingBlocks
List of blocks we're currently running either constructors or destructors for.
ASTContext & getASTContext() const override
InterpStack & Stk
Temporary stack.
const VarDecl * EvaluatingDecl
Declaration we're initializing/evaluting, if any.
InterpFrame * Current
The current frame.
T allocAP(unsigned BitWidth)
const LangOptions & getLangOpts() const
StdAllocatorCaller getStdAllocatorCaller(StringRef Name) const
bool inConstantContext() const
Program & P
Reference to the module containing all bytecode.
PrimType value_or(PrimType PT) const
A pointer to a memory block, live or dead.
Pointer narrow() const
Restricts the scope of an array element pointer.
bool isInitialized() const
Checks if an object was initialized.
Pointer atIndex(uint64_t Idx) const
Offsets a pointer inside an array.
bool isDummy() const
Checks if the pointer points to a dummy value.
int64_t getIndex() const
Returns the index into an array.
bool isActive() const
Checks if the object is active.
Pointer atField(unsigned Off) const
Creates a pointer to a field.
T & deref() const
Dereferences the pointer, if it's live.
unsigned getNumElems() const
Returns the number of elements.
Pointer getArray() const
Returns the parent array.
bool isUnknownSizeArray() const
Checks if the structure is an array of unknown size.
void activate() const
Activats a field.
bool isIntegralPointer() const
QualType getType() const
Returns the type of the innermost field.
bool isArrayElement() const
Checks if the pointer points to an array.
void initializeAllElements() const
Initialize all elements of a primitive array at once.
bool isLive() const
Checks if the pointer is live.
T & elem(unsigned I) const
Dereferences the element at index I.
Pointer getBase() const
Returns a pointer to the object of which this pointer is a field.
std::string toDiagnosticString(const ASTContext &Ctx) const
Converts the pointer to a string usable in diagnostics.
bool isZero() const
Checks if the pointer is null.
bool isRoot() const
Pointer points directly to a block.
const Descriptor * getDeclDesc() const
Accessor for information about the declaration site.
static bool pointToSameBlock(const Pointer &A, const Pointer &B)
Checks if both given pointers point to the same block.
APValue toAPValue(const ASTContext &ASTCtx) const
Converts the pointer to an APValue.
bool isOnePastEnd() const
Checks if the index is one past end.
uint64_t getIntegerRepresentation() const
const FieldDecl * getField() const
Returns the field information.
Pointer expand() const
Expands a pointer to the containing array, undoing narrowing.
bool isBlockPointer() const
const Block * block() const
const Descriptor * getFieldDesc() const
Accessors for information about the innermost field.
bool isVirtualBaseClass() const
bool isBaseClass() const
Checks if a structure is a base class.
size_t elemSize() const
Returns the element size of the innermost field.
bool canBeInitialized() const
If this pointer has an InlineDescriptor we can use to initialize.
Lifetime getLifetime() const
void initialize() const
Initializes a field.
bool isField() const
Checks if the item is a field in an object.
const Record * getRecord() const
Returns the record descriptor of a class.
Descriptor * createDescriptor(const DeclTy &D, PrimType T, const Type *SourceTy=nullptr, Descriptor::MetadataSize MDSize=std::nullopt, bool IsConst=false, bool IsTemporary=false, bool IsMutable=false, bool IsVolatile=false)
Creates a descriptor for a primitive type.
Structure/Class descriptor.
const RecordDecl * getDecl() const
Returns the underlying declaration.
bool isUnion() const
Checks if the record is a union.
const Field * getField(const FieldDecl *FD) const
Returns a field.
llvm::iterator_range< const_base_iter > bases() const
unsigned getNumFields() const
llvm::iterator_range< const_field_iter > fields() const
Describes the statement/declaration an opcode was generated from.
OptionalDiagnostic Note(SourceLocation Loc, diag::kind DiagId)
Add a note to a prior diagnostic.
DiagnosticBuilder report(SourceLocation Loc, diag::kind DiagId)
Directly reports a diagnostic message.
OptionalDiagnostic FFDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation could not be folded (FF => FoldFailure)
OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation does not produce a C++11 core constant expression.
bool checkingPotentialConstantExpression() const
Are we checking whether the expression is a potential constant expression?
Defines the clang::TargetInfo interface.
bool computeOSLogBufferLayout(clang::ASTContext &Ctx, const clang::CallExpr *E, OSLogBufferLayout &layout)
static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC, const CallExpr *Call)
static void assignInteger(InterpState &S, const Pointer &Dest, PrimType ValueT, const APSInt &Value)
bool readPointerToBuffer(const Context &Ctx, const Pointer &FromPtr, BitcastBuffer &Buffer, bool ReturnOnUninit)
static Floating abs(InterpState &S, const Floating &In)
static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_fmax(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin)
static bool interp__builtin_elementwise_maxmin(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinID)
static bool interp__builtin_bswap(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_elementwise_triop(InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APInt(const APSInt &, const APSInt &, const APSInt &)> Fn)
static bool interp__builtin_assume(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC, DynamicAllocator::Form AllocForm, DynamicAllocator::Form DeleteForm, const Descriptor *D, const Expr *NewExpr)
Diagnose mismatched new[]/delete or new/delete[] pairs.
static bool interp__builtin_isnan(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
Defined as __builtin_isnan(...), to accommodate the fact that it can take a float,...
static llvm::RoundingMode getRoundingMode(FPOptions FPO)
static bool interp__builtin_elementwise_countzeroes(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
Can be called with an integer or vector as the first and only parameter.
bool Call(InterpState &S, CodePtr OpPC, const Function *Func, uint32_t VarArgSize)
static bool interp__builtin_classify_type(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin)
static bool interp__builtin_blend(InterpState &S, CodePtr OpPC, const CallExpr *Call)
bool SetThreeWayComparisonField(InterpState &S, CodePtr OpPC, const Pointer &Ptr, const APSInt &IntValue)
Sets the given integral value to the pointer, which is of a std::{weak,partial,strong}...
static bool interp__builtin_operator_delete(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_fabs(InterpState &S, CodePtr OpPC, const InterpFrame *Frame)
static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool interp__builtin_atomic_lock_free(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
bool __atomic_always_lock_free(size_t, void const volatile*) bool __atomic_is_lock_free(size_t,...
static llvm::APSInt convertBoolVectorToInt(const Pointer &Val)
static bool interp__builtin_move(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_clz(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr)
Checks if a pointer points to a mutable field.
static bool interp__builtin_parity(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
__builtin_is_aligned() __builtin_align_up() __builtin_align_down() The first parameter is either an i...
static bool interp__builtin_bitreverse(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, bool Right)
rotateleft(value, amount)
static bool Activate(InterpState &S, CodePtr OpPC)
static bool interp__builtin_ia32_addcarry_subborrow(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
(CarryIn, LHS, RHS, Result)
static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool isOneByteCharacterType(QualType T)
Determine if T is a character type for which we guarantee that sizeof(T) == 1.
static unsigned computePointerOffset(const ASTContext &ASTCtx, const Pointer &Ptr)
Compute the byte offset of Ptr in the full declaration.
static bool interp__builtin_ia32_bzhi(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_strcmp(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
Checks if a value can be loaded from a block.
static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinOp)
static bool interp__builtin_inf(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_isinf(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool CheckSign, const CallExpr *Call)
static bool interp__builtin_os_log_format_buffer_size(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E, ArrayRef< int64_t > ArrayIndices, int64_t &Result)
Interpret an offsetof operation.
static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
Checks if a pointer is in range.
static bool pointsToLastObject(const Pointer &Ptr)
Does Ptr point to the last subobject?
static bool interp__builtin_select(InterpState &S, CodePtr OpPC, const CallExpr *Call)
AVX512 predicated move: "Result = Mask[] ? LHS[] : RHS[]".
static bool interp__builtin_ia32_pmul(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinID)
static void discard(InterpStack &Stk, PrimType T)
bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
Checks if a pointer is live and accessible.
static bool interp__builtin_fpclassify(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
Five int values followed by one floating value.
static bool interp__builtin_abs(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp_floating_comparison(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static bool handleOverflow(InterpState &S, CodePtr OpPC, const T &SrcValue)
static bool copyComposite(InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest, bool Activate)
static bool copyRecord(InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest, bool Activate=false)
static bool interp__builtin_c11_atomic_is_lock_free(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool __c11_atomic_is_lock_free(size_t)
static void zeroAll(Pointer &Dest)
static bool interp__builtin_elementwise_int_binop(InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APInt(const APSInt &, const APSInt &)> Fn)
static bool interp__builtin_issubnormal(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_arithmetic_fence(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
PrimType
Enumeration of the primitive types of the VM.
static bool interp__builtin_isfinite(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, uint32_t BuiltinID)
Interpret a builtin function.
static bool interp__builtin_expect(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_complex(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
__builtin_complex(Float A, float B);
bool CheckDummy(InterpState &S, CodePtr OpPC, const Block *B, AccessKinds AK)
Checks if a pointer is a dummy pointer.
static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
__builtin_assume_aligned(Ptr, Alignment[, ExtraOffset])
static bool interp__builtin_ptrauth_string_discriminator(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static bool interp__builtin_x86_pack(InterpState &S, CodePtr, const CallExpr *E, llvm::function_ref< APInt(const APSInt &)> PackFn)
static void pushInteger(InterpState &S, const APSInt &Val, QualType QT)
Pushes Val on the stack as the type given by QT.
static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr)
Checks if the array is offsetable.
static bool interp__builtin_elementwise_abs(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
static bool interp__builtin_copysign(InterpState &S, CodePtr OpPC, const InterpFrame *Frame)
static bool interp__builtin_iszero(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_elementwise_popcount(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
Can be called with an integer or vector as the first and only parameter.
static bool interp__builtin_addressof(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_signbit(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool Error(InterpState &S, CodePtr OpPC)
Do nothing and just abort execution.
static bool interp__builtin_vector_reduce(InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool interp__builtin_elementwise_triop_fp(InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APFloat(const APFloat &, const APFloat &, const APFloat &, llvm::RoundingMode)> Fn)
static bool interp__builtin_popcount(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_object_size(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
Three integral values followed by a pointer (lhs, rhs, carry, carryOut).
bool CheckArraySize(InterpState &S, CodePtr OpPC, uint64_t NumElems)
static bool interp__builtin_ctz(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
static bool interp__builtin_is_constant_evaluated(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static APSInt popToAPSInt(InterpStack &Stk, PrimType T)
static std::optional< unsigned > computeFullDescSize(const ASTContext &ASTCtx, const Descriptor *Desc)
static bool interp__builtin_isfpclass(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
First parameter to __builtin_isfpclass is the floating value, the second one is an integral value.
static bool interp__builtin_issignaling(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_nan(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, bool Signaling)
static bool interp__builtin_clrsb(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
bool DoMemcpy(InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest)
Copy the contents of Src into Dest.
static bool interp__builtin_elementwise_int_unaryop(InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APInt(const APSInt &)> Fn)
constexpr bool isIntegralType(PrimType T)
static bool interp__builtin_eh_return_data_regno(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static LLVM_ATTRIBUTE_UNUSED bool isNoopBuiltin(unsigned ID)
static void diagnoseNonConstexprBuiltin(InterpState &S, CodePtr OpPC, unsigned ID)
static QualType getElemType(const Pointer &P)
static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static void swapBytes(std::byte *M, size_t N)
The JSON file list parser is used to communicate input to InstallAPI.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
@ Result
The result type of a method or function.
const FunctionProtoType * T
U cast(CodeGen::Address addr)
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Track what bits have been initialized to known values and which ones have indeterminate value.
std::unique_ptr< std::byte[]> Data
size_t getQuantity() const
Describes a memory block created by an allocation site.
unsigned getNumElems() const
Returns the number of elements stored in the block.
bool isPrimitive() const
Checks if the descriptor is of a primitive.
QualType getElemQualType() const
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
const ValueDecl * asValueDecl() const
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
const Decl * asDecl() const
static constexpr MetadataSize InlineDescMD
unsigned getElemSize() const
returns the size of an element when the structure is viewed as an array.
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
const VarDecl * asVarDecl() const
PrimType getPrimType() const
bool isRecord() const
Checks if the descriptor is of a record.
const Record *const ElemRecord
Pointer to the record, if block contains records.
const Expr * asExpr() const
bool isArray() const
Checks if the descriptor is of an array.
Mapping from primitive types to their representation.