gAlfonso-bit created this revision.
gAlfonso-bit requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is especially important at the end of the function, where originally there 
was a strange cast from optional to bool


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107704

Files:
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===================================================================
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -384,7 +384,7 @@
 
   if (!got_line && !in && m_input_sp) {
     // there is no FILE*, fall back on just reading bytes from the stream.
-    while (!got_line) {
+    do {
       size_t bytes_read = sizeof(buffer);
       Status error = m_input_sp->Read((void *)buffer, bytes_read);
       if (error.Success() && !bytes_read) {
@@ -395,12 +395,12 @@
         break;
       m_line_buffer += StringRef(buffer, bytes_read);
       got_line = SplitLine(m_line_buffer);
-    }
+    } while (!got_line);
   }
 
   if (!got_line && in) {
     m_editing = true;
-    while (!got_line) {
+    do {
       char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
       // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
@@ -424,7 +424,7 @@
       }
       m_line_buffer += buffer;
       got_line = SplitLine(m_line_buffer);
-    }
+    } while (!got_line);
     m_editing = false;
   }
 
@@ -432,9 +432,10 @@
     line = got_line.getValue();
     if (m_data_recorder)
       m_data_recorder->Record(line, true);
+    return true;
   }
 
-  return (bool)got_line;
+  return false;
 }
 
 #if LLDB_ENABLE_LIBEDIT


Index: lldb/source/Core/IOHandler.cpp
===================================================================
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -384,7 +384,7 @@
 
   if (!got_line && !in && m_input_sp) {
     // there is no FILE*, fall back on just reading bytes from the stream.
-    while (!got_line) {
+    do {
       size_t bytes_read = sizeof(buffer);
       Status error = m_input_sp->Read((void *)buffer, bytes_read);
       if (error.Success() && !bytes_read) {
@@ -395,12 +395,12 @@
         break;
       m_line_buffer += StringRef(buffer, bytes_read);
       got_line = SplitLine(m_line_buffer);
-    }
+    } while (!got_line);
   }
 
   if (!got_line && in) {
     m_editing = true;
-    while (!got_line) {
+    do {
       char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
       // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
@@ -424,7 +424,7 @@
       }
       m_line_buffer += buffer;
       got_line = SplitLine(m_line_buffer);
-    }
+    } while (!got_line);
     m_editing = false;
   }
 
@@ -432,9 +432,10 @@
     line = got_line.getValue();
     if (m_data_recorder)
       m_data_recorder->Record(line, true);
+    return true;
   }
 
-  return (bool)got_line;
+  return false;
 }
 
 #if LLDB_ENABLE_LIBEDIT
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to