[clang] ae27323 - [clang][Interp] Classify ArrayInitIndexExpr type

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 02:11:06 PDT 2022


Author: Timm Bäder
Date: 2022-10-14T11:10:28+02:00
New Revision: ae27323428ff9666b1c4cf32e0ea928681ce778e

URL: https://github.com/llvm/llvm-project/commit/ae27323428ff9666b1c4cf32e0ea928681ce778e
DIFF: https://github.com/llvm/llvm-project/commit/ae27323428ff9666b1c4cf32e0ea928681ce778e.diff

LOG: [clang][Interp] Classify ArrayInitIndexExpr type

We can't just push a uint64 unconditionally here, since on 32bit arches
we later expect a different type, e.g. uint32.

This broke e.g. these builders:
https://lab.llvm.org/buildbot#builders/171/builds/21514
https://lab.llvm.org/buildbot#builders/38/builds/6643

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 b9e7f4e2cdad..5af97ebbcf27 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -330,7 +330,9 @@ template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitArrayInitIndexExpr(
     const ArrayInitIndexExpr *E) {
   assert(ArrayIndex);
-  return this->emitConstUint64(*ArrayIndex, E);
+  QualType IndexType = E->getType();
+  APInt Value(getIntWidth(IndexType), *ArrayIndex);
+  return this->emitConst(classifyPrim(IndexType), 0, Value, E);
 }
 
 template <class Emitter>


        


More information about the cfe-commits mailing list