[PATCH] D50809: Remove byte counting from SourceManager [NFC]

Raphael Isemann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 02:20:57 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342121: Remove byte counting from SourceManager [NFC] (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50809?vs=165225&id=165226#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50809

Files:
  lldb/trunk/source/Core/SourceManager.cpp


Index: lldb/trunk/source/Core/SourceManager.cpp
===================================================================
--- lldb/trunk/source/Core/SourceManager.cpp
+++ lldb/trunk/source/Core/SourceManager.cpp
@@ -158,7 +158,9 @@
     const SymbolContextList *bp_locs) {
   if (count == 0)
     return 0;
-  size_t return_value = 0;
+
+  Stream::ByteDelta delta(*s);
+
   if (start_line == 0) {
     if (m_last_line != 0 && m_last_line != UINT32_MAX)
       start_line = m_last_line + m_last_count;
@@ -193,9 +195,8 @@
           ::snprintf(prefix, sizeof(prefix), "    ");
       }
 
-      return_value +=
-          s->Printf("%s%2.2s %-4u\t", prefix,
-                    line == curr_line ? current_line_cstr : "", line);
+      s->Printf("%s%2.2s %-4u\t", prefix,
+                line == curr_line ? current_line_cstr : "", line);
 
       // So far we treated column 0 as a special 'no column value', but
       // DisplaySourceLines starts counting columns from 0 (and no column is
@@ -211,21 +212,20 @@
         // Display caret cursor.
         std::string src_line;
         m_last_file_sp->GetLine(line, src_line);
-        return_value += s->Printf("    \t");
+        s->Printf("    \t");
         // Insert a space for every non-tab character in the source line.
         for (size_t i = 0; i + 1 < column && i < src_line.length(); ++i)
-          return_value += s->PutChar(src_line[i] == '\t' ? '\t' : ' ');
+          s->PutChar(src_line[i] == '\t' ? '\t' : ' ');
         // Now add the caret.
-        return_value += s->Printf("^\n");
+        s->Printf("^\n");
       }
       if (this_line_size == 0) {
         m_last_line = UINT32_MAX;
         break;
-      } else
-        return_value += this_line_size;
+      }
     }
   }
-  return return_value;
+  return *delta;
 }
 
 size_t SourceManager::DisplaySourceLinesWithLineNumbers(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50809.165226.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180913/25080642/attachment.bin>


More information about the llvm-commits mailing list