diff options
Diffstat (limited to 'clang/lib/AST/ByteCode/ByteCodeEmitter.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/ByteCodeEmitter.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp index d474605..8e7206e 100644 --- a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp +++ b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp @@ -135,8 +135,8 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) { /// Helper to write bytecode and bail out if 32-bit offsets become invalid. /// Pointers will be automatically marshalled as 32-bit IDs. template <typename T> -static void emit(Program &P, std::vector<std::byte> &Code, const T &Val, - bool &Success) { +static void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code, + const T &Val, bool &Success) { size_t ValPos = Code.size(); size_t Size; @@ -153,7 +153,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val, // Access must be aligned! assert(aligned(ValPos)); assert(aligned(ValPos + Size)); - Code.resize(ValPos + Size); + Code.resize_for_overwrite(ValPos + Size); if constexpr (!std::is_pointer_v<T>) { new (Code.data() + ValPos) T(Val); @@ -166,7 +166,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val, /// Emits a serializable value. These usually (potentially) contain /// heap-allocated memory and aren't trivially copyable. template <typename T> -static void emitSerialized(std::vector<std::byte> &Code, const T &Val, +static void emitSerialized(llvm::SmallVectorImpl<std::byte> &Code, const T &Val, bool &Success) { size_t ValPos = Code.size(); size_t Size = align(Val.bytesToSerialize()); @@ -179,32 +179,32 @@ static void emitSerialized(std::vector<std::byte> &Code, const T &Val, // Access must be aligned! assert(aligned(ValPos)); assert(aligned(ValPos + Size)); - Code.resize(ValPos + Size); + Code.resize_for_overwrite(ValPos + Size); Val.serialize(Code.data() + ValPos); } template <> -void emit(Program &P, std::vector<std::byte> &Code, const Floating &Val, - bool &Success) { +void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code, + const Floating &Val, bool &Success) { emitSerialized(Code, Val, Success); } template <> -void emit(Program &P, std::vector<std::byte> &Code, +void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code, const IntegralAP<false> &Val, bool &Success) { emitSerialized(Code, Val, Success); } template <> -void emit(Program &P, std::vector<std::byte> &Code, const IntegralAP<true> &Val, - bool &Success) { +void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code, + const IntegralAP<true> &Val, bool &Success) { emitSerialized(Code, Val, Success); } template <> -void emit(Program &P, std::vector<std::byte> &Code, const FixedPoint &Val, - bool &Success) { +void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code, + const FixedPoint &Val, bool &Success) { emitSerialized(Code, Val, Success); } |