https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/231886
>From 7f7b315e5f1cf05e017eb8a83f33d81e851ca7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Wed, 14 Oct 2026 13:12:46 +0200 Subject: [PATCH] asdf --- clang/lib/AST/ByteCode/Compiler.cpp | 49 +++++++++++++++++-- .../AST/static-compound-literals-reeval.cpp | 1 + clang/test/SemaCXX/source_location.cpp | 12 ++--- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 6ba5099a78b877..a37c606bec8b6f 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2795,8 +2795,15 @@ bool Compiler<Emitter>::VisitConstantExpr(const ConstantExpr *E) { return this->visitAPValue(E->getAPValueResult(), *T, E); } - // Fall back to the subexpr for non-primitive APValues. - return this->delegate(E->getSubExpr()); + assert(!DiscardResult); + if (!Initializing) { + UnsignedOrNone LocalIndex = allocateLocal(E); + if (!LocalIndex) + return false; + if (!this->emitGetPtrLocal(*LocalIndex, E)) + return false; + } + return this->visitAPValueInitializer(E->getAPValueResult(), E, E->getType()); } template <class Emitter> @@ -6234,8 +6241,44 @@ bool Compiler<Emitter>::visitAPValueInitializer(const APValue &Val, } return true; } - // TODO: Other types. + if (Val.isComplexFloat()) { + assert(T->isComplexType()); + if (!this->emitFloat(Val.getComplexFloatReal(), Info)) + return false; + if (!this->emitInitElemFloat(0, Info)) + return false; + if (!this->emitFloat(Val.getComplexFloatImag(), Info)) + return false; + if (!this->emitInitElemFloat(1, Info)) + return false; + return true; + } + if (Val.isComplexInt()) { + assert(T->isComplexIntegerType()); + PrimType IntT = classifyPrim(T->getAs<ComplexType>()->getElementType()); + if (!this->emitConst(Val.getComplexIntReal(), IntT, Info)) + return false; + if (!this->emitInitElem(IntT, 0, Info)) + return false; + if (!this->emitConst(Val.getComplexIntImag(), IntT, Info)) + return false; + if (!this->emitInitElem(IntT, 1, Info)) + return false; + return true; + } + if (Val.isVector()) { + assert(T->isVectorType()); + PrimType IntT = classifyPrim(T->getAs<VectorType>()->getElementType()); + for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I) { + if (!this->visitAPValue(Val.getVectorElt(I), IntT, Info)) + return false; + if (!this->emitInitElem(IntT, I, Info)) + return false; + } + return true; + } + // TODO: Other types. return false; } diff --git a/clang/test/AST/static-compound-literals-reeval.cpp b/clang/test/AST/static-compound-literals-reeval.cpp index 29e21798b9295c..07c92a785264b6 100644 --- a/clang/test/AST/static-compound-literals-reeval.cpp +++ b/clang/test/AST/static-compound-literals-reeval.cpp @@ -1,5 +1,6 @@ // Test that we can successfully compile this code, especially under ASAN. // RUN: %clang_cc1 -emit-llvm -std=c++20 %s -o- | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -std=c++20 %s -o- -fexperimental-new-constant-interpreter | FileCheck %s struct RR { int r; }; struct Z { int x; const RR* y; int z; }; constinit Z z = { 10, (const RR[1]){__builtin_constant_p(z.x)}, z.y->r }; diff --git a/clang/test/SemaCXX/source_location.cpp b/clang/test/SemaCXX/source_location.cpp index 8049430738654c..663eece399d1f7 100644 --- a/clang/test/SemaCXX/source_location.cpp +++ b/clang/test/SemaCXX/source_location.cpp @@ -4,11 +4,11 @@ // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -fms-compatibility -verify %s // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -fms-compatibility -verify %s // -// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s -// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s -// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -DUSE_CONSTEVAL -DPAREN_INIT -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s -// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -fms-compatibility -verify %s -// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify -fms-compatibility %s +// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -fexperimental-new-constant-interpreter -verify %s +// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -verify %s +// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -DUSE_CONSTEVAL -DPAREN_INIT -fexceptions -fexperimental-new-constant-interpreter -verify %s +// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -fexperimental-new-constant-interpreter -fms-compatibility -verify %s +// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -verify -fms-compatibility %s // expected-no-diagnostics #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42) @@ -874,7 +874,7 @@ constexpr int test_init_capture(int a = [b = SL::current().line()] { return b; }()) { return a; } -#if defined(USE_CONSTEVAL) && !defined(NEW_INTERP) +#if defined(USE_CONSTEVAL) static_assert(test_init_capture() == __LINE__ - 4); #else static_assert(test_init_capture() == __LINE__ ); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
