Author: Timm Bäder
Date: 2022-11-30T16:07:57+01:00
New Revision: 89b009559cea546f16f45105bb1ce90265f79c9c

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

LOG: Revert "[clang][Interp] Use placement new to construct opcode args into 
vector"

This reverts commit aaf73ae266db44fce107a0b73fcb33527bfb52eb.

This breaks sanitized builds because the constructor is called with an
unaligned address.

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index b67e6969c37e..ff2136d34872 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -163,10 +163,8 @@ static void emit(Program &P, std::vector<char> &Code, 
const T &Val,
   }
 
   if constexpr (!std::is_pointer_v<T>) {
-    // Construct the value directly into our storage vector.
-    size_t ValPos = Code.size();
-    Code.resize(Code.size() + Size);
-    new (Code.data() + ValPos) T(Val);
+    const char *Data = reinterpret_cast<const char *>(&Val);
+    Code.insert(Code.end(), Data, Data + Size);
   } else {
     uint32_t ID = P.getOrCreateNativePointer(Val);
     const char *Data = reinterpret_cast<const char *>(&ID);


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to