[clang] 99f5fcb - [clang][Interp] Try to fix #embed on big-endian machines
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 20 11:29:45 PDT 2024
Author: Timm Bäder
Date: 2024-06-20T20:29:27+02:00
New Revision: 99f5fcb0d1e04125daa404ff14c9cd14b7a2c40b
URL: https://github.com/llvm/llvm-project/commit/99f5fcb0d1e04125daa404ff14c9cd14b7a2c40b
DIFF: https://github.com/llvm/llvm-project/commit/99f5fcb0d1e04125daa404ff14c9cd14b7a2c40b.diff
LOG: [clang][Interp] Try to fix #embed on big-endian machines
Insert a cast to the proper value.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index b18873287ffcc..034e479ff3a32 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1346,13 +1346,22 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
}
}
- auto Eval = [&](Expr *Init, unsigned ElemIndex) {
- return visitArrayElemInit(ElemIndex, Init);
- };
-
unsigned ElementIndex = 0;
for (const Expr *Init : Inits) {
- if (auto *EmbedS = dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
+ if (const auto *EmbedS =
+ dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
+ PrimType TargetT = classifyPrim(Init->getType());
+
+ auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
+ PrimType InitT = classifyPrim(Init->getType());
+ if (!this->visit(Init))
+ return false;
+ if (InitT != TargetT) {
+ if (!this->emitCast(InitT, TargetT, E))
+ return false;
+ }
+ return this->emitInitElem(TargetT, ElemIndex, Init);
+ };
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
return false;
} else {
More information about the cfe-commits
mailing list