[mlir][Parser] Make parse{Attribute,Type} null-terminate input
authorRahul Kayaith <rkayaith@gmail.com>
Thu, 2 Mar 2023 21:06:44 +0000 (16:06 -0500)
committerRahul Kayaith <rkayaith@gmail.com>
Fri, 3 Mar 2023 22:03:27 +0000 (17:03 -0500)
commit55cf53fd0f5594eb701b5760729fdc2bd4a70584
treed3cff40e16e45ce3901e278f7628d809f06d03b8
parentae12e57a777f2287a656e17a6ce86ca6b86edb6e
[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
mlir/include/mlir/AsmParser/AsmParser.h
mlir/lib/AsmParser/DialectSymbolParser.cpp
mlir/lib/Bytecode/Reader/BytecodeReader.cpp
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/unittests/Parser/ParserTest.cpp