llvm-project/mlir/lib/Parser
River Riddle 06e25d5645 [mlir][IR] Refactor the `getChecked` and `verifyConstructionInvariants` methods on Attributes/Types
`verifyConstructionInvariants` is intended to allow for verifying the invariants of an attribute/type on construction, and `getChecked` is intended to enable more graceful error handling aside from an assert. There are a few problems with the current implementation of these methods:
* `verifyConstructionInvariants` requires an mlir::Location for emitting errors, which is prohibitively costly in the situations that would most likely use them, e.g. the parser.
This creates an unfortunate code duplication between the verifier code and the parser code, given that the parser operates on llvm::SMLoc and it is an undesirable overhead to pre-emptively convert from that to an mlir::Location.
* `getChecked` effectively requires duplicating the definition of the `get` method, creating a quite clunky workflow due to the subtle different in its signature.

This revision aims to talk the above problems by refactoring the implementation to use a callback for error emission. Using a callback allows for deferring the costly part of error emission until it is actually necessary.

Due to the necessary signature change in each instance of these methods, this revision also takes this opportunity to cleanup the definition of these methods by:
* restructuring the signature of `getChecked` such that it can be generated from the same code block as the `get` method.
* renaming `verifyConstructionInvariants` to `verify` to match the naming scheme of the rest of the compiler.

Differential Revision: https://reviews.llvm.org/D97100
2021-02-22 17:37:49 -08:00
..
AffineParser.cpp [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
AttributeParser.cpp Revert "Revert "Reorder MLIRContext location in BuiltinAttributes.h"" 2021-02-08 10:39:58 +01:00
CMakeLists.txt [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
DialectSymbolParser.cpp [mlir][IR] Refactor the `getChecked` and `verifyConstructionInvariants` methods on Attributes/Types 2021-02-22 17:37:49 -08:00
Lexer.cpp Import llvm::StringSwitch into mlir namespace. 2020-10-08 11:39:24 +02:00
Lexer.h Mass update the MLIR license header to mention "Part of the LLVM project" 2020-01-26 03:58:30 +00:00
LocationParser.cpp [mlir][Asm] Add support for resolving operation locations after parsing has finished 2020-11-12 23:34:36 -08:00
Parser.cpp [mlir][IR] Remove the concept of `OperationProperties` 2021-02-09 12:00:15 -08:00
Parser.h [mlir][OpAsmParser] Add support for parsing integer literals without going through IntegerAttr 2020-12-14 12:00:43 -08:00
ParserState.h [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
Token.cpp [AsmParser] Fix support for zero bit integer types. 2020-12-12 21:24:18 -08:00
Token.h [mlir] Optimize the parsing of ElementsAttr hex strings 2020-10-28 16:58:06 -07:00
TokenKinds.def [mlir] Add better support for f80 and f128 2021-01-15 10:29:48 -05:00
TypeParser.cpp [mlir] Add better support for f80 and f128 2021-01-15 10:29:48 -05:00