Instead of (ab)using incomplete array types for this, add a 'Dummy' bit
to Descriptor. We need to be able to differentiate between the two when
adding an offset.
We do a similar thing a few lines above for `Index`:
```c++
// Get a version of the index comparable to the type.
T Index = T::from(Ptr.getIndex(), Offset.bitWidth());
```
Make sure we pass the expected bitwidth around when casting to
IntAP/IntAPS.
This makes it easier to test the `IntegralAP` code for different bit
widths than 128.
This adds `IntegralAP` backing the two new primtypes `IntAP` (unsigned
arbitrary-precision int) and `IntAPS` (same but signed).
We use this for `int128` support (which isn't available on all host
systems we support AFAIK) and I think we can also use this for `_BitInt`
later.
Rename CheckBaseDerived to something more general and call it in
GetPtrField() as well, so we don't crash later in Pointer::toAPValue().
Differential Revision: https://reviews.llvm.org/D149149
We can implement these similarly to DerivedToBase casts. We just have to
walk the class hierarchy, sum the base offsets and subtract it from the
current base offset of the pointer.
Differential Revision: https://reviews.llvm.org/D149133
We only did this for primitive temporaries.
Unfortunately, the existing Pointer::toAPValue() won't do here, since
we're expected to set an rvalue on the LifetimeExtendedTemporaryDecl.
Differential Revision: https://reviews.llvm.org/D144457
BEFORE:
```
overflow.cpp:1:21: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
1 | int x = __INT_MAX__ + 1 + 3;
| ^
overflow.cpp:2:9: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
2 | int a = -(1 << 31) + 1;
| ^
```
AFTER:
```
overflow.cpp:1:21: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
1 | int x = __INT_MAX__ + 1 + 3;
| ~~~~~~~~~~~~^~~
overflow.cpp:2:9: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
2 | int a = -(1 << 31) + 1;
| ^~~~~~~~~~
```
Reviewed By: tbaeder
Differential Revision: https://reviews.llvm.org/D157383
The Floating class wraps a APFloat, which might heap allocate memory to
represent large floating values. When writing those to bytecode, we
would free() the heap allocation after writing, when destroying the
actual APFloat we wrote.
Fix this by seralizing a Floating as Semantics + APInt.
This will be neccessary in more cases later, when we support
arbitrary-precision integers or _BitInt.
Differential Revision: https://reviews.llvm.org/D155165
For some builtins, we need to do quite a bit of type checking ourselves,
so pass the call expression along. This way we can inspect arguments,
expected return value, etc.
Differential Revision: https://reviews.llvm.org/D155545
clang::StreamingDiagnostic doesn't have a uint8_t overload,
which makes MSVC without /permissive- decide it's ambiguous.
Pre-approved in replies to D153276.
The previous version was using llvm::reverse(CallExpr::arguments()),
which causes problems when clang is compiled with GCC.
Differential Revision: https://reviews.llvm.org/D155369
We will use this opcode for conditionally executed statements that are
invalid in a constant expression.
Differential Revision: https://reviews.llvm.org/D150364
When calling functions in the checkingPotentialConstantExpression mode,
we cannot have arguments (including This + RVO pointers) for the
toplevel callee, but the functions called from within can work just
fine, or at least we succeed in pushing their arguments on the stack, so
we must also succeed in removing them again.
Differential Revision: https://reviews.llvm.org/D150358
Make our Function class keep a list of parameter offsets so we can
simply get a parameter by index when evaluating builtin functions.
Differential Revision: https://reviews.llvm.org/D149816