[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
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user