```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.
The comment already explains that this is only true for _some_ builtin
functions. This also brings the time it takes me to run the
builtin-functions.cpp test locally from 50s down to 47s.
The new constant interpreter's `clang::interp::InterpState` contains
both `clang::interp::Context` and `clang::ASTContext`. So using `S.Ctx`
and `S.getCtx()` was a bit confusing. This PR rename `getCtx()` to
`getASTContext` to make things more clearer.
Signed-off-by: yronglin <yronglin777@gmail.com>