[MLIR Parser] Improve QoI for "expected token" errors
authorChris Lattner <clattner@nondot.org>
Tue, 10 May 2022 09:22:25 +0000 (10:22 +0100)
committerChris Lattner <clattner@nondot.org>
Tue, 10 May 2022 14:44:17 +0000 (15:44 +0100)
commitad3b358180e8e1d723b790cf5f68264e486c0b1a
tree1b46b91cfd39baf9749898c1ba3eee5147880e08
parent0c1000cbd6d25d749c78f9c27fa985a2608ff217
[MLIR Parser] Improve QoI for "expected token" errors

A typical problem with missing a token is that the missing
token is at the end of a line.  The problem with this is that
the error message gets reported on the start of the following
line (which is where the next / invalid token is) which can
be confusing.

Handle this by noticing this case and backing up to the end of
the previous line.

Differential Revision: https://reviews.llvm.org/D125295
mlir/lib/Parser/Parser.cpp
mlir/lib/Parser/Parser.h
mlir/test/Dialect/ControlFlow/invalid.mlir
mlir/test/Dialect/LLVMIR/global.mlir
mlir/test/Dialect/Linalg/invalid.mlir
mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
mlir/test/Dialect/SPIRV/IR/logical-ops.mlir
mlir/test/Dialect/SPIRV/IR/memory-ops.mlir
mlir/test/Dialect/SPIRV/IR/misc-ops.mlir
mlir/test/IR/invalid-locations.mlir
mlir/test/IR/invalid.mlir