summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Diagnostics.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-181-11/+9
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Add a flag to dump the current stack trace when emitting a diagnostic.River Riddle2019-12-051-0/+19
| | | | | | It is often desirable to know where within the program that a diagnostic was emitted, without reverting to assert/unreachable which crash the program. This change adds a flag `mlir-print-stacktrace-on-diagnostic` that attaches the current stack trace as a note to every diagnostic that gets emitted. PiperOrigin-RevId: 283996373
* Add a printer flag to use local scope when printing IR.River Riddle2019-11-121-1/+1
| | | | | | This causes the AsmPrinter to use a local value numbering when printing the IR, allowing for the printer to be used safely in a local context, e.g. to ensure thread-safety when printing the IR. This means that the IR printing instrumentation can also be used during multi-threading when module-scope is disabled. Operation::dump and DiagnosticArgument(Operation*) are also updated to always print local scope, as this is the most common use case when debugging. PiperOrigin-RevId: 279988203
* Add @below and @above directives to verify-diagnostics.River Riddle2019-10-231-7/+39
| | | | | | | | | | | | | | | | | | This simplifies defining expected-* directives when there are multiple that apply to the next or previous line. @below applies the directive to the next non-designator line, i.e. the next line that does not contain an expected-* designator. @above applies to the previous non designator line. Examples: // Expect an error on the next line that does not contain a designator. // expected-remark@below {{remark on function below}} // expected-remark@below {{another remark on function below}} func @bar(%a : f32) // Expect an error on the previous line that does not contain a designator. func @baz(%a : f32) // expected-remark@above {{remark on function above}} // expected-remark@above {{another remark on function above}} PiperOrigin-RevId: 276369085
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-201-1/+1
| | | | | | Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
* Pre-allocate space for results from a regex match that uses 3 match strings.MLIR Team2019-10-091-1/+1
| | | | | | | That space is 4 StringRefs, not 3, because element 0 of the match always contains the entire source string. PiperOrigin-RevId: 273875606
* Refactor DiagnosticEngine to support multiple registered diagnostic handlers.River Riddle2019-09-231-67/+69
| | | | | | | | | | | | This fixes a problem with current save-restore pattern of diagnostics handlers, as there may be a thread race between when the previous handler is destroyed. For example, this occurs when using multiple ParallelDiagnosticHandlers asynchronously: Handler A Handler B | - LifeTime - | Restore A here. Handler C | --- LifeTime ---| Restore B after it has been destroyed. The new design allows for multiple handlers to be registered in a stack like fashion. Handlers can return success() to signal that they have fully processed a diagnostic, or failure to propagate otherwise. PiperOrigin-RevId: 270720625
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-231-1/+1
| | | | PiperOrigin-RevId: 270632324
* Forward diagnostics from untracked threads in ParallelDiagnosticHandler.River Riddle2019-09-131-4/+20
| | | | | | This allows for the use of multiple ParallelDiagnosticHandlers without having them conflict with each other. PiperOrigin-RevId: 268967407
* Change from llvm::make_unique to std::make_uniqueJacques Pienaar2019-08-171-1/+1
| | | | | | | | Switch to C++14 standard method as llvm::make_unique has been removed ( https://reviews.llvm.org/D66259). Also mark some targets as c++14 to ease next integrates. PiperOrigin-RevId: 263953918
* Avoid passing in line/col for files not registered with SourceMgr.Jacques Pienaar2019-08-121-6/+4
| | | | | | | | | This can result in index expression overflow in "Loc.getPointer() - ColumnNo" in SourgeMgr. loc could also be prefixed to the message additionally in this case. PiperOrigin-RevId: 262935408
* NFC: Don't print the location of a diagnostic if it is unknown.River Riddle2019-07-121-2/+4
| | | | | | Printing 'loc(unknown)' just clutters the output with unhelpful information. PiperOrigin-RevId: 257883717
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-251-0/+35
| | | | | | | | into the mlir namespace. Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups. PiperOrigin-RevId: 255112791
* Allow converting Diagnostic to LogicalResult::Failure. This matches the ↵River Riddle2019-06-241-0/+3
| | | | | | behavior of InFlightDiagnostic and enables notes to be converted to failure. PiperOrigin-RevId: 254579098
* Refactor the location classes to be attributes instead of separate IR classes.River Riddle2019-06-221-6/+6
| | | | | | This will allow for locations to be used in the same contexts as attributes. Given that attributes are nullable types, the 'Location' class now represents a non-nullable wrapper around a 'LocationAttr'. This preserves the desired semantics we have for non-optional locations. PiperOrigin-RevId: 254505278
* NFC: Append 'Location' to the end of each the location kinds. This is in ↵River Riddle2019-06-191-3/+3
| | | | | | preparation for making the location classes attributes instead of separate IR types. PiperOrigin-RevId: 253860058
* Add support for providing an output stream to the ↵River Riddle2019-06-011-12/+21
| | | | | | | | SourceMgrDiagnosticHandlers. -- PiperOrigin-RevId: 250974331
* Update the type printer for Diagnostic to automatically wrap the type ↵River Riddle2019-06-011-1/+1
| | | | | | | | with ''. -- PiperOrigin-RevId: 249935489
* Introduce a new common diagnostic handler ScopedDiagnosticHandler to ↵River Riddle2019-06-011-1/+17
| | | | | | | | simplify saving and restoring the currently registered handler. -- PiperOrigin-RevId: 249735912
* NFC: Fix the name of a comment header block in Diagnostics.cpp.River Riddle2019-06-011-1/+1
| | | | | | -- PiperOrigin-RevId: 249466645
* Make the ParallelDiagnosticHandler used by the pass manager publicly ↵River Riddle2019-06-011-0/+128
| | | | | | | | available in Diagnostics.h. This provides a common utility for deterministically handling diagnostics in a multi-threaded environment. -- PiperOrigin-RevId: 249325937
* Add support for streaming an OperationName into a Diagnostic.River Riddle2019-05-201-0/+8
| | | | | | -- PiperOrigin-RevId: 248987646
* Add support for streaming Operations into Diagnostics.River Riddle2019-05-201-0/+4
| | | | | | -- PiperOrigin-RevId: 248967563
* When converting a location to an SMLoc, advance to the first ↵River Riddle2019-05-201-3/+16
| | | | | | | | | | | | | | | | | | | | | | non-whitespace if the column is unknown(zero). This also fixes a small bug with call stack printing. Example: /tmp/file_C.py:21:5: error: 'foo.bar' op attribute 'something' raise app.UsageError('Too many command-line arguments.') ^ /tmp/file_D.py:20:3: note: called from if len(argv) > 1: ^ /tmp/file_E.py:19:1: note: called from def main(argv): ^ /tmp/file_F.py:24:3: note: called from app.run(main) ^ -- PiperOrigin-RevId: 248151212
* Add initial support to the SourceMgrDiagnosticHandler for printing call ↵River Riddle2019-05-201-33/+63
| | | | | | | | | | | | | | | | | | | | | | | stacks. Example: /tmp/file_C.py:17:1: error: 'foo.bar' op attribute 'something' ... app.run(main) ^ /tmp/file_D.py:14:1: note: called from raise app.UsageError('Too many command-line arguments.') ^ /tmp/file_E.py:12:1: note: called from def main(argv): ^ /tmp/file_F.py:13:1: note: called from if len(argv) > 1: ^ -- PiperOrigin-RevId: 248074804
* Remove several heavy includes from Diagnostics.h by a moving a couple of ↵River Riddle2019-05-201-20/+60
| | | | | | | | fields/methods to the .cpp file. -- PiperOrigin-RevId: 247768443
* Change the diagnostic handler to accept Diagnostic instead of ↵River Riddle2019-05-101-48/+43
| | | | | | | | location/message/kind. This opens the door for many more powerful use cases: fixits, colors, etc. -- PiperOrigin-RevId: 247705673
* Add support to the SourceMgrDiagnosticHandlers to auto-load new source ↵River Riddle2019-05-101-3/+4
| | | | | | | | files seen in diagnostics. -- PiperOrigin-RevId: 247681779
* Add llvm_unreachable in unreachable path to silence GCC warning (NFC)Mehdi Amini2019-05-101-0/+2
| | | | | | | | | The switch is supposed to be fully covered, but GCC warns that: "control reaches end of non-void function" -- PiperOrigin-RevId: 247672430
* Refactor the SourceMgrDiagnosticHandlers to support more locations than ↵River Riddle2019-05-101-9/+30
| | | | | | | | FileLineColLoc. -- PiperOrigin-RevId: 247662828
* Add support to SourceMgrDiagnosticHandler for handling the case where ↵River Riddle2019-05-101-13/+22
| | | | | | | | the llvm::SourceMgr has no main file. -- PiperOrigin-RevId: 247605584
* Move the diagnostic verification functionality out of mlir-opt and into ↵River Riddle2019-05-101-0/+200
| | | | | | | | a new llvm::SourceMgr diagnostic handler 'SourceMgrDiagnosticVerifierHandler'. This will allow for other tools to reuse the 'expected-*' functionality. -- PiperOrigin-RevId: 247514684
* Add support in the SourceMgrDiagnosticHandler for handling source ↵River Riddle2019-05-101-5/+25
| | | | | | | | managers with multiple buffers. -- PiperOrigin-RevId: 247482733
* Simplify the emission of a few op parser diagnostics. This also adds the ↵River Riddle2019-05-101-0/+16
| | | | | | | | ability to stream an attribute into a Diagnostic. -- PiperOrigin-RevId: 247359911
* Add a utility diagnostic handler class, SourceMgrDiagnosticHandler, to ↵River Riddle2019-05-101-0/+85
| | | | | | | | interface with llvm::SourceMgr. This lowers the barrier of entry for tools to get rich diagnostic handling when using llvm::SourceMgr. -- PiperOrigin-RevId: 247358610
* Add support for using the new diagnostics infrastructure in the parser. ↵River Riddle2019-05-101-2/+8
| | | | | | | | This also adds support for streaming in ranges(e.g. ArrayRef) into a diagnostic with an optional element delimiter. -- PiperOrigin-RevId: 247239436
* Simplify the emission of various diagnostics emitted by the different ↵River Riddle2019-05-101-0/+3
| | | | | | | | dialects (Affine/Standard/etc.) by using the new stream interface instead of Twine. -- PiperOrigin-RevId: 246842016
* Make the Twine parameter of the current diagnostic emit functions ↵River Riddle2019-05-061-0/+9
| | | | | | | | optional. This allows for the ability to exclusively use the new diagnostic interface without breaking all of the existing usages. Several diagnostics emitted in lib/IR have been updated to make use of this functionality. -- PiperOrigin-RevId: 246546044
* Add the ability to attach notes to Diagnostic/InFlightDiagnostic.River Riddle2019-05-061-3/+25
| | | | | | | | | | | | | Notes are a way to add additional context to a diagnostic, but don't really make sense as standalone diagnostics. Moving forward, notes will no longer be able to be constructed directly and must be attached to a parent Diagnostic. Notes can be attached via `attachNote`: auto diag = ...; diag.attachNote() << "This is a note"; -- PiperOrigin-RevId: 246545971
* Introduce a new API for emitting diagnostics with Diagnostic and ↵River Riddle2019-05-061-32/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | InFlightDiagnostic. The Diagnostic class contains all of the information necessary to report a diagnostic to the DiagnosticEngine. It should generally not be constructed directly, and instead used transitively via InFlightDiagnostic. A diagnostic is currently comprised of several different elements: * A severity level. * A source Location. * A list of DiagnosticArguments that help compose and comprise the output message. * A DiagnosticArgument represents any value that may be part of the diagnostic, e.g. string, integer, Type, Attribute, etc. * Arguments can be added to the diagnostic via the stream(<<) operator. * (In a future cl) A list of attached notes. * These are in the form of other diagnostics that provide supplemental information to the main diagnostic, but do not have context on their own. The InFlightDiagnostic class represents an RAII wrapper around a Diagnostic that is set to be reported with the diagnostic engine. This allows for the user to modify a diagnostic that is inflight. The internally wrapped diagnostic can be reported directly or automatically upon destruction. These classes allow for more natural composition of diagnostics by removing the restriction that the message of a diagnostic is comprised of a single Twine. They should also allow for nice incremental improvements to the diagnostics experience in the future, e.g. formatv style diagnostics. Simple Example: emitError(loc, "integer bitwidth is limited to " + Twine(IntegerType::kMaxWidth) + " bits"); emitError(loc) << "integer bitwidth is limited to " << IntegerType::kMaxWidth << " bits"; -- PiperOrigin-RevId: 246526439
* Start sketching out a new diagnostics infrastructure. Create a new class ↵River Riddle2019-05-061-0/+103
'DiagnosticEngine' and move the diagnostic handler support and final diagnostic emission from the MLIRContext to it. -- PiperOrigin-RevId: 246163897
OpenPOWER on IntegriCloud