[mlir] Add support to SourceMgrDiagnosticHandler for filtering FileLineColLocs
authorRiver Riddle <riddleriver@gmail.com>
Fri, 18 Jun 2021 20:30:16 +0000 (20:30 +0000)
committerRiver Riddle <riddleriver@gmail.com>
Fri, 18 Jun 2021 21:12:28 +0000 (21:12 +0000)
commitd1baf2895467735ab14f4b3415fce204c0cc8e7f
treec9a41f93d7758d6b885510df789a6b6472bf51f4
parentbef299286104c2b6383a43b9d1eb0e47838cb5b6
[mlir] Add support to SourceMgrDiagnosticHandler for filtering FileLineColLocs

This revision adds support for passing a functor to SourceMgrDiagnosticHandler for filtering out FileLineColLocs when emitting a diagnostic. More specifically, this can be useful in situations where there may be large CallSiteLocs with locations that aren't necessarily important/useful for users.

For now the filtering support is limited to FileLineColLocs, but conceptually we could allow filtering for all locations types if a need arises in the future.

Differential Revision: https://reviews.llvm.org/D103649
mlir/docs/Diagnostics.md
mlir/include/mlir/IR/Diagnostics.h
mlir/lib/IR/Diagnostics.cpp
mlir/test/IR/diagnostic-handler-filter.mlir [new file with mode: 0644]
mlir/test/lib/IR/CMakeLists.txt
mlir/test/lib/IR/TestDiagnostics.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp