diff options
| author | River Riddle <riverriddle@google.com> | 2019-11-13 09:31:45 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-11-13 09:32:20 -0800 |
| commit | 6df83699418c6a6d6105728cdec59c78212aa841 (patch) | |
| tree | 7368b187b45efb25e89423a4c8b588aebf24868b /mlir/lib/Parser/Parser.cpp | |
| parent | 85d7fb3324a6442e865c87ea766992ab096f8859 (diff) | |
| download | bcm5719-llvm-6df83699418c6a6d6105728cdec59c78212aa841.tar.gz bcm5719-llvm-6df83699418c6a6d6105728cdec59c78212aa841.zip | |
Rename the current parseSymbolName to parseOptionalSymbolName
The current implementation silently fails if the '@' identifier isn't present, making it similar to the 'optional' parse methods. This change renames the current implementation to 'Optional' and adds a new 'parseSymbolName' that emits an error.
PiperOrigin-RevId: 280214610
Diffstat (limited to 'mlir/lib/Parser/Parser.cpp')
| -rw-r--r-- | mlir/lib/Parser/Parser.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
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(); |

