Skip to content

Commit c7b34b0

Browse files
[mlir] Use a new constructor of ArrayRef (NFC) (llvm#146009)
ArrayRef now has a new constructor that takes a parameter whose type has data() and size(). This patch migrates: ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X)
1 parent 26ec66d commit c7b34b0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

mlir/lib/AsmParser/AttributeParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, ShapedType type) {
717717
if (parseElementAttrHexValues(p, *hexStorage, data))
718718
return nullptr;
719719

720-
ArrayRef<char> rawData(data.data(), data.size());
720+
ArrayRef<char> rawData(data);
721721
bool detectedSplat = false;
722722
if (!DenseElementsAttr::isValidRawBuffer(type, rawData, detectedSplat)) {
723723
p.emitError(loc) << "elements hex data size is invalid for provided type: "

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,8 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
727727
}
728728

729729
if (auto stringAttr = dyn_cast<StringAttr>(attr)) {
730-
return llvm::ConstantDataArray::get(
731-
moduleTranslation.getLLVMContext(),
732-
ArrayRef<char>{stringAttr.getValue().data(),
733-
stringAttr.getValue().size()});
730+
return llvm::ConstantDataArray::get(moduleTranslation.getLLVMContext(),
731+
ArrayRef<char>{stringAttr.getValue()});
734732
}
735733

736734
// Handle arrays of structs that cannot be represented as DenseElementsAttr

0 commit comments

Comments
 (0)