aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
diff options
context:
space:
mode:
authorRahul Kayaith <rkayaith@gmail.com>2023-03-02 16:06:44 -0500
committerRahul Kayaith <rkayaith@gmail.com>2023-03-03 17:03:27 -0500
commit55cf53fd0f5594eb701b5760729fdc2bd4a70584 (patch)
treed3cff40e16e45ce3901e278f7628d809f06d03b8 /mlir/lib/Bytecode/Reader/BytecodeReader.cpp
parentae12e57a777f2287a656e17a6ce86ca6b86edb6e (diff)
downloadllvm-55cf53fd0f5594eb701b5760729fdc2bd4a70584.zip
llvm-55cf53fd0f5594eb701b5760729fdc2bd4a70584.tar.gz
llvm-55cf53fd0f5594eb701b5760729fdc2bd4a70584.tar.bz2
[mlir][Parser] Make parse{Attribute,Type} null-terminate input
`parseAttribute` and `parseType` require null-terminated strings as input, but this isn't great considering the argument type is `StringRef`. This changes them to copy to a null-terminated buffer by default, with a `isKnownNullTerminated` flag added to disable the copying. closes #58964 Reviewed By: rriddle, kuhar, lattner Differential Revision: https://reviews.llvm.org/D145182
Diffstat (limited to 'mlir/lib/Bytecode/Reader/BytecodeReader.cpp')
-rw-r--r--mlir/lib/Bytecode/Reader/BytecodeReader.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index f009621..5e71c3a 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -1031,9 +1031,11 @@ LogicalResult AttrTypeReader::parseAsmEntry(T &result, EncodingReader &reader,
size_t numRead = 0;
MLIRContext *context = fileLoc->getContext();
if constexpr (std::is_same_v<T, Type>)
- result = ::parseType(asmStr, context, &numRead);
+ result =
+ ::parseType(asmStr, context, &numRead, /*isKnownNullTerminated=*/true);
else
- result = ::parseAttribute(asmStr, context, Type(), &numRead);
+ result = ::parseAttribute(asmStr, context, Type(), &numRead,
+ /*isKnownNullTerminated=*/true);
if (!result)
return failure();