[Mlir-commits] [mlir] cbf8155 - [mlir] Avoid nullptr as memcpy arguments after D132758
Vitaly Buka
llvmlistbot at llvm.org
Wed Aug 31 12:30:27 PDT 2022
Author: Vitaly Buka
Date: 2022-08-31T12:30:18-07:00
New Revision: cbf81558ab541802d1b2a859d72680173cafcb10
URL: https://github.com/llvm/llvm-project/commit/cbf81558ab541802d1b2a859d72680173cafcb10
DIFF: https://github.com/llvm/llvm-project/commit/cbf81558ab541802d1b2a859d72680173cafcb10.diff
LOG: [mlir] Avoid nullptr as memcpy arguments after D132758
Added:
Modified:
mlir/lib/AsmParser/AttributeParser.cpp
Removed:
################################################################################
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index 27a870d9627e6..580dbb0eefde7 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -862,11 +862,14 @@ class DenseArrayElementParser {
} // namespace
void DenseArrayElementParser::append(const APInt &data) {
- unsigned byteSize = data.getBitWidth() / 8;
- size_t offset = rawData.size();
- rawData.insert(rawData.end(), byteSize, 0);
- llvm::StoreIntToMemory(
- data, reinterpret_cast<uint8_t *>(rawData.data() + offset), byteSize);
+ if (data.getBitWidth()) {
+ assert(data.getBitWidth() % 8 == 0);
+ unsigned byteSize = data.getBitWidth() / 8;
+ size_t offset = rawData.size();
+ rawData.insert(rawData.end(), byteSize, 0);
+ llvm::StoreIntToMemory(
+ data, reinterpret_cast<uint8_t *>(rawData.data() + offset), byteSize);
+ }
++size;
}
More information about the Mlir-commits
mailing list