Skip to content

Commit 8815c50

Browse files
authored
[MLIR] Allow setting call stack limit for SourceMgrDiagnosticHandler (#123373)
Otherwise for deeply nested code, the callstack will always be truncated
1 parent c7ea4c1 commit 8815c50

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

mlir/include/mlir/IR/Diagnostics.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ class SourceMgrDiagnosticHandler : public ScopedDiagnosticHandler {
578578
void emitDiagnostic(Location loc, Twine message, DiagnosticSeverity kind,
579579
bool displaySourceLine = true);
580580

581+
/// Set the maximum depth that a call stack will be printed. Defaults to 10.
582+
void setCallStackLimit(unsigned limit);
583+
581584
protected:
582585
/// Emit the given diagnostic with the held source manager.
583586
void emitDiagnostic(Diagnostic &diag);
@@ -605,7 +608,6 @@ class SourceMgrDiagnosticHandler : public ScopedDiagnosticHandler {
605608
std::optional<Location> findLocToShow(Location loc);
606609

607610
/// The maximum depth that a call stack will be printed.
608-
/// TODO: This should be a tunable flag.
609611
unsigned callStackLimit = 10;
610612

611613
std::unique_ptr<detail::SourceMgrDiagnosticHandlerImpl> impl;

mlir/lib/IR/Diagnostics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ void SourceMgrDiagnosticHandler::emitDiagnostic(Diagnostic &diag) {
519519
}
520520
}
521521

522+
void SourceMgrDiagnosticHandler::setCallStackLimit(unsigned limit) {
523+
callStackLimit = limit;
524+
}
525+
522526
/// Get a memory buffer for the given file, or nullptr if one is not found.
523527
const llvm::MemoryBuffer *
524528
SourceMgrDiagnosticHandler::getBufferForFile(StringRef filename) {

0 commit comments

Comments
 (0)