aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-04 19:20:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:02:26 +0000
commit81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch)
tree311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp
parent5fff09660e06a66bed6482da9c70df328e16bbb6 (diff)
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp b/contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp
index 8c9efa0ed9a9..dc4ea200c7be 100644
--- a/contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp
+++ b/contrib/llvm-project/llvm/lib/Support/BinaryStreamWriter.cpp
@@ -8,7 +8,6 @@
#include "llvm/Support/BinaryStreamWriter.h"
-#include "llvm/Support/BinaryStreamError.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/LEB128.h"
@@ -94,10 +93,11 @@ BinaryStreamWriter::split(uint64_t Off) const {
Error BinaryStreamWriter::padToAlignment(uint32_t Align) {
uint64_t NewOffset = alignTo(Offset, Align);
- if (NewOffset > getLength())
- return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
+ const uint64_t ZerosSize = 64;
+ static constexpr char Zeros[ZerosSize] = {};
while (Offset < NewOffset)
- if (auto EC = writeInteger('\0'))
- return EC;
+ if (auto E = writeArray(
+ ArrayRef<char>(Zeros, std::min(ZerosSize, NewOffset - Offset))))
+ return E;
return Error::success();
}