diff options
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 53049943a..7b35701d4 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1902,6 +1902,21 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { } } + // Prints debug info for a delimiter in an expression. + void printDebugDelimiterLocation(Expression* curr, Index i) { + if (currFunction && debugInfo) { + auto iter = currFunction->delimiterLocations.find(curr); + if (iter != currFunction->delimiterLocations.end()) { + auto& locations = iter->second; + Colors::grey(o); + o << ";; code offset: 0x" << std::hex << locations[i] << std::dec + << '\n'; + restoreNormalColor(o); + doIndent(o, indent); + } + } + } + void visit(Expression* curr) { printDebugLocation(curr); OverriddenVisitor<PrintSExpression>::visit(curr); @@ -2020,6 +2035,10 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { printFullLine(curr->condition); maybePrintImplicitBlock(curr->ifTrue, false); if (curr->ifFalse) { + // Note: debug info here is not used as LLVM does not emit ifs, and since + // LLVM is the main source of DWARF, effectively we never encounter ifs + // with DWARF. + printDebugDelimiterLocation(curr, BinaryLocations::Else); maybePrintImplicitBlock(curr->ifFalse, false); } decIndent(); @@ -2380,6 +2399,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { o << "\n"; for (size_t i = 0; i < curr->catchEvents.size(); i++) { doIndent(o, indent); + printDebugDelimiterLocation(curr, i); o << "(catch "; printName(curr->catchEvents[i], o); incIndent(); @@ -2389,6 +2409,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { } if (curr->hasCatchAll()) { doIndent(o, indent); + printDebugDelimiterLocation(curr, curr->catchEvents.size()); o << "(catch_all"; incIndent(); maybePrintImplicitBlock(curr->catchBodies.back(), true); |