@@ -112,17 +112,21 @@ void RenderDiagnosticDetails(Stream &stream,
112112 // Print a line with caret indicator(s) below the lldb prompt + command.
113113 const size_t padding = *offset_in_command;
114114 stream << std::string (padding, ' ' );
115- size_t offset = 1 ;
116- for (const DiagnosticDetail &detail : remaining_details) {
117- auto &loc = *detail.source_location ;
118-
119- if (offset > loc.column )
120- continue ;
121-
122- stream << std::string (loc.column - offset, ' ' ) << cursor;
123- for (unsigned i = 0 ; i + 1 < loc.length ; ++i)
124- stream << underline;
125- offset = loc.column + 1 ;
115+ {
116+ size_t x_pos = 1 ;
117+ for (const DiagnosticDetail &detail : remaining_details) {
118+ auto &loc = *detail.source_location ;
119+
120+ if (x_pos > loc.column )
121+ continue ;
122+
123+ stream << std::string (loc.column - x_pos, ' ' ) << cursor;
124+ ++x_pos;
125+ for (unsigned i = 0 ; i + 1 < loc.length ; ++i) {
126+ stream << underline;
127+ ++x_pos;
128+ }
129+ }
126130 }
127131 stream << ' \n ' ;
128132
@@ -134,19 +138,19 @@ void RenderDiagnosticDetails(Stream &stream,
134138 // Get the information to print this detail and remove it from the stack.
135139 // Print all the lines for all the other messages first.
136140 stream << std::string (padding, ' ' );
137- size_t offset = 1 ;
141+ size_t x_pos = 1 ;
138142 for (auto &remaining_detail :
139143 llvm::ArrayRef (remaining_details).drop_back (1 )) {
140144 uint16_t column = remaining_detail.source_location ->column ;
141- if (offset <= column)
142- stream << std::string (column - offset , ' ' ) << vbar;
143- offset = column + 1 ;
145+ if (x_pos <= column)
146+ stream << std::string (column - x_pos , ' ' ) << vbar;
147+ x_pos = column + 1 ;
144148 }
145149
146150 // Print the line connecting the ^ with the error message.
147151 uint16_t column = detail->source_location ->column ;
148- if (offset <= column)
149- stream << std::string (column - offset , ' ' ) << joint << hbar << spacer;
152+ if (x_pos <= column)
153+ stream << std::string (column - x_pos , ' ' ) << joint << hbar << spacer;
150154
151155 // Print a colorized string based on the message's severity type.
152156 PrintSeverity (stream, detail->severity );
0 commit comments