diff options
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 05a639158..4346fe705 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -96,9 +96,28 @@ struct TypeNamePrinter { void print(const Struct& struct_); void print(const Array& array); void print(const Rtt& rtt); + + // FIXME: This hard limit on how many times we call print() avoids extremely + // large outputs, which can be inconveniently large in some cases, but + // we should have a better mechanism for this. + static const size_t MaxPrints = 100; + + size_t prints = 0; + + bool exceededLimit() { + if (prints >= MaxPrints) { + os << "?"; + return true; + } + prints++; + return false; + } }; void TypeNamePrinter::print(Type type) { + if (exceededLimit()) { + return; + } if (type.isBasic()) { os << type; } else if (type.isTuple()) { @@ -119,6 +138,9 @@ void TypeNamePrinter::print(Type type) { } void TypeNamePrinter::print(HeapType type) { + if (exceededLimit()) { + return; + } if (type.isBasic()) { os << type; return; |