@@ -117,7 +117,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
117117
118118 Module* currModule = nullptr ;
119119 Function* currFunction = nullptr ;
120- Function::DebugLocation lastPrintedLocation;
120+ std::optional< Function::DebugLocation> lastPrintedLocation;
121121 bool debugInfo;
122122
123123 // Used to print delegate's depth argument when it throws to the caller
@@ -247,7 +247,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
247247 return o;
248248 }
249249
250- void printDebugLocation (const Function::DebugLocation& location);
250+ void
251+ printDebugLocation (const std::optional<Function::DebugLocation>& location);
251252 void printDebugLocation (Expression* curr);
252253
253254 // Prints debug info for a delimiter in an expression.
@@ -2473,21 +2474,20 @@ std::ostream& PrintSExpression::printPrefixedTypes(const char* prefix,
24732474}
24742475
24752476void PrintSExpression::printDebugLocation (
2476- const Function::DebugLocation& location) {
2477+ const std::optional< Function::DebugLocation> & location) {
24772478 // Do not skip repeated debug info in full mode, for less-confusing debugging:
24782479 // full mode prints out everything in the most verbose manner.
24792480 if (lastPrintedLocation == location && indent > lastPrintIndent && !full) {
24802481 return ;
24812482 }
24822483 lastPrintedLocation = location;
24832484 lastPrintIndent = indent;
2484- Function::DebugLocation noLocation = {0 , 0 , 0 };
2485- if (location == noLocation) {
2485+ if (!location) {
24862486 o << " ;;@\n " ;
24872487 } else {
2488- auto fileName = currModule->debugInfoFileNames [location. fileIndex ];
2489- o << " ;;@ " << fileName << " :" << location. lineNumber << " :"
2490- << location. columnNumber << ' \n ' ;
2488+ auto fileName = currModule->debugInfoFileNames [location-> fileIndex ];
2489+ o << " ;;@ " << fileName << " :" << location-> lineNumber << " :"
2490+ << location-> columnNumber << ' \n ' ;
24912491 }
24922492 doIndent (o, indent);
24932493}
@@ -2500,7 +2500,7 @@ void PrintSExpression::printDebugLocation(Expression* curr) {
25002500 if (iter != debugLocations.end ()) {
25012501 printDebugLocation (iter->second );
25022502 } else {
2503- printDebugLocation ({ 0 , 0 , 0 } );
2503+ printDebugLocation (std:: nullopt );
25042504 }
25052505 // show a binary position, if there is one
25062506 if (debugInfo) {
@@ -2963,7 +2963,7 @@ void PrintSExpression::visitFunction(Function* curr) {
29632963void PrintSExpression::visitImportedFunction (Function* curr) {
29642964 doIndent (o, indent);
29652965 currFunction = curr;
2966- lastPrintedLocation = { 0 , 0 , 0 } ;
2966+ lastPrintedLocation = std:: nullopt ;
29672967 o << ' (' ;
29682968 emitImportHeader (curr);
29692969 handleSignature (curr->type , curr->name );
@@ -2974,7 +2974,7 @@ void PrintSExpression::visitImportedFunction(Function* curr) {
29742974void PrintSExpression::visitDefinedFunction (Function* curr) {
29752975 doIndent (o, indent);
29762976 currFunction = curr;
2977- lastPrintedLocation = { 0 , 0 , 0 } ;
2977+ lastPrintedLocation = std:: nullopt ;
29782978 lastPrintIndent = 0 ;
29792979 if (currFunction->prologLocation .size ()) {
29802980 printDebugLocation (*currFunction->prologLocation .begin ());
0 commit comments