diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -176,14 +176,14 @@ /// unlike `OpBuilder::getType`, this method does not implicitly insert a /// context parameter. template - T getChecked(llvm::SMLoc loc, ParamsT &&... params) { + T getChecked(llvm::SMLoc loc, ParamsT &&...params) { return T::getChecked([&] { return emitError(loc); }, std::forward(params)...); } /// A variant of `getChecked` that uses the result of `getNameLoc` to emit /// errors. template - T getChecked(ParamsT &&... params) { + T getChecked(ParamsT &&...params) { return T::getChecked([&] { return emitError(getNameLoc()); }, std::forward(params)...); } @@ -229,7 +229,7 @@ virtual ParseResult parseOptionalEqual() = 0; /// Parse a quoted string token. - ParseResult parseString(StringRef *string) { + ParseResult parseString(std::string *string) { auto loc = getCurrentLocation(); if (parseOptionalString(string)) return emitError(loc, "expected string"); @@ -237,7 +237,7 @@ } /// Parse a quoted string token if present. - virtual ParseResult parseOptionalString(StringRef *string) = 0; + virtual ParseResult parseOptionalString(std::string *string) = 0; /// Parse a given keyword. ParseResult parseKeyword(StringRef keyword, const Twine &msg = "") { diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -70,7 +70,7 @@ return {}; Type type = nullptr; - StringRef identifier; + std::string identifier; llvm::SMLoc idLoc = parser.getCurrentLocation(); OptionalParseResult parsedType = parser.parseOptionalType(type); if (parsedType.hasValue() && failed(parsedType.getValue())) diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -169,7 +169,7 @@ DialectAsmParser &parser, Type type) { if (parser.parseLess()) return Attribute(); - StringRef value; + std::string value; llvm::SMLoc loc = parser.getCurrentLocation(); if (parser.parseOptionalString(&value)) { parser.emitError(loc) << "expected string"; @@ -214,7 +214,7 @@ Type emitc::OpaqueType::parse(MLIRContext *context, DialectAsmParser &parser) { if (parser.parseLess()) return Type(); - StringRef value; + std::string value; llvm::SMLoc loc = parser.getCurrentLocation(); if (parser.parseOptionalString(&value) || value.empty()) { parser.emitError(loc) << "expected non empty string"; diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -139,7 +139,7 @@ return nullptr; // Parse operand. - StringRef operand; + std::string operand; if (failed(parser.parseOptionalString(&operand))) return nullptr; diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp @@ -339,7 +339,7 @@ // If we are parsing a self-reference to a recursive struct, i.e. the parsing // stack already contains a struct with the same identifier, bail out after // the name. - StringRef name; + std::string name; bool isIdentified = succeeded(parser.parseOptionalString(&name)); if (isIdentified) { if (knownStructNames.count(name)) { diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp --- a/mlir/lib/Parser/DialectSymbolParser.cpp +++ b/mlir/lib/Parser/DialectSymbolParser.cpp @@ -238,12 +238,12 @@ } /// Parses a quoted string token if present. - ParseResult parseOptionalString(StringRef *string) override { + ParseResult parseOptionalString(std::string *string) override { if (!parser.getToken().is(Token::string)) return failure(); if (string) - *string = parser.getTokenSpelling().drop_front().drop_back(); + *string = parser.getToken().getStringValue(); parser.consumeToken(); return success(); }