The follow-up diagnostic would otherwise be:
array.cpp:111:33: note: undefined constructor '(unnamed struct at
array.cpp:111:11)' cannot be used in a constant expression
array.cpp:111:11: note: declared here
111 | constexpr struct { Unknown U; } InvalidCtor;
| ^
... and complaining about the undefined constructor of a class that is
invalid anyway doesn't make much sense.
Don't return true here in InvalidNewDeleteExpr just because we are in
C++26 mode. This invalid there as well.
Testcase reduced from
libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.pass.cpp
Make lifetime management more explicit. We're only using this for
CXXPseudoDestructorExprs for now but we need this to handle
std::construct_at/placement-new after destructor calls later anyway.
... for the dynamic blocks created for operator new calls. This way we
get the type of memory allocated right. As a side-effect, the
diagnostics now point to the std::allocator calls, which is an
improvement.
Add it as another kind of pointer, saving both a `Type*` for the result
of the typeid() expression as well as one for the type of the typeid
expression.
This is unneeded in almost all circumstances. We only return an APValue
back to clang when the evaluation is finished, and that is always done
by an EvalEmitter - which has its own implementation of the Ret
instructions.
This commit adds an assert statement to the CallBI function to ensure
that the interpreter state (S.Current) is correctly reset to the
previous frame (FrameBefore) after InterpretBuiltin returns true. This
helps catch any potential issues during development and debugging.
Alter the #ifdef values from #110986 and #115292 to use _MSC_VER instead of _WIN32 to stop the pragmas being used on gcc/mingw builds
Noticed by @mstorsjo
This is a subset of #68288, with hopefully narrower scope. It does not
support bitcasting to non-integral types yet.
Bitfields are supported, but only if they result in a full byte-sized
final buffer. It does not support casting from null-pointers yet or
casting from indeterminate bits.
The tests are from #68288 and partially from #74775.
The `BitcastBuffer` struct is currently always working in single bits,
but I plan to (try to) optimize this for the common full-byte case.
```cpp
const int V33 = 4;
const int V34 = 0;
const int V35 = 2;
constexpr int V36 = V33 / V34;
// expected-error@-1 {{constexpr variable 'V36' must be initialized by a constant expression}}
constexpr int V37 = V33 / V35;
// expected-error@-1 {{constexpr variable 'V37' must be initialized by a constant expression}}
```
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
Disable optimizations when building clang/lib/AST/ByteCode/Interp.cpp
with Microsoft's compiler as it has a bug that causes excessive build
times. We do this only when NDEBUG is not defined on the assumption that
building without asserts indicates that a user is strongly invested in
runtime performance.
Partially addresses: https://github.com/llvm/llvm-project/issues/102513.
Once the bug is addressed in the Microsoft compiler this can be removed.
Co-authored-by: dyung
And fix the diagnostics for __builtin_is_constant_evaluated(). We can be
in a non-constant context, but calling an immediate function always
makes the context constant for the duration of that call.
If we have a placement-new destination already, use that instead of
allocating a new one.
Tests are partially based on
`test/SemaCXX/cxx2c-constexpr-placement-new.cpp`.
We were calling checkLiteralType() too many time and rejecting some
things we shouldn't. Add The calls manually when handling
MaterializeTemporaryExprs. Maybe we should call it in other places as
well, but adding more calls is easier than removing them from a generic
code path.