summaryrefslogtreecommitdiffstats
path: root/mlir/lib
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/IR/FunctionSupport.cpp8
-rw-r--r--mlir/lib/IR/Module.cpp4
-rw-r--r--mlir/lib/Parser/Parser.cpp16
3 files changed, 14 insertions, 14 deletions
diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp
index 29cae177cec..6b27eb833bf 100644
--- a/mlir/lib/IR/FunctionSupport.cpp
+++ b/mlir/lib/IR/FunctionSupport.cpp
@@ -159,12 +159,10 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState &result,
auto &builder = parser.getBuilder();
// Parse the name as a symbol reference attribute.
- FlatSymbolRefAttr nameAttr;
- if (parser.parseAttribute(nameAttr, ::mlir::SymbolTable::getSymbolAttrName(),
- result.attributes))
+ StringAttr nameAttr;
+ if (parser.parseSymbolName(nameAttr, ::mlir::SymbolTable::getSymbolAttrName(),
+ result.attributes))
return failure();
- // Convert the parsed function attr into a string attr.
- result.attributes.back().second = builder.getStringAttr(nameAttr.getValue());
// Parse the function signature.
auto signatureLocation = parser.getCurrentLocation();
diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp
index f5cc98e39cf..79e04521e9c 100644
--- a/mlir/lib/IR/Module.cpp
+++ b/mlir/lib/IR/Module.cpp
@@ -44,8 +44,8 @@ ModuleOp ModuleOp::create(Location loc, Optional<StringRef> name) {
ParseResult ModuleOp::parse(OpAsmParser &parser, OperationState &result) {
// If the name is present, parse it.
StringAttr nameAttr;
- (void)parser.parseSymbolName(nameAttr, mlir::SymbolTable::getSymbolAttrName(),
- result.attributes);
+ (void)parser.parseOptionalSymbolName(
+ nameAttr, mlir::SymbolTable::getSymbolAttrName(), result.attributes);
// If module attributes are present, parse them.
if (parser.parseOptionalAttrDictWithKeyword(result.attributes))
diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index 2843aae4bb8..9dd6d507ab9 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -847,12 +847,13 @@ static T parseSymbol(llvm::StringRef inputStr, MLIRContext *context,
//===----------------------------------------------------------------------===//
InFlightDiagnostic Parser::emitError(SMLoc loc, const Twine &message) {
+ auto diag = mlir::emitError(getEncodedSourceLocation(loc), message);
+
// If we hit a parse error in response to a lexer error, then the lexer
// already reported the error.
if (getToken().is(Token::error))
- return InFlightDiagnostic();
-
- return mlir::emitError(getEncodedSourceLocation(loc), message);
+ diag.abandon();
+ return diag;
}
//===----------------------------------------------------------------------===//
@@ -3937,10 +3938,11 @@ public:
return success();
}
- /// Parse an @-identifier and store it (without the '@' symbol) in a string
- /// attribute named 'attrName'.
- ParseResult parseSymbolName(StringAttr &result, StringRef attrName,
- SmallVectorImpl<NamedAttribute> &attrs) override {
+ /// Parse an optional @-identifier and store it (without the '@' symbol) in a
+ /// string attribute named 'attrName'.
+ ParseResult
+ parseOptionalSymbolName(StringAttr &result, StringRef attrName,
+ SmallVectorImpl<NamedAttribute> &attrs) override {
Token atToken = parser.getToken();
if (atToken.isNot(Token::at_identifier))
return failure();
OpenPOWER on IntegriCloud