Reflow paragraphs in comments.

This is intended as a clean up after the big clang-format commit
(r280751), which unfortunately resulted in many of the comment
paragraphs in LLDB being very hard to read.

FYI, the script I used was:

import textwrap
import commands
import os
import sys
import re
tmp = "%s.tmp"%sys.argv[1]
out = open(tmp, "w+")
with open(sys.argv[1], "r") as f:
  header = ""
  text = ""
  comment = re.compile(r'^( *//) ([^ ].*)$')
  special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$')
  for line in f:
      match = comment.match(line)
      if match and not special.match(match.group(2)):
          # skip intentionally short comments.
          if not text and len(match.group(2)) < 40:
              out.write(line)
              continue

          if text:
              text += " " + match.group(2)
          else:
              header = match.group(1)
              text = match.group(2)

          continue

      if text:
          filled = textwrap.wrap(text, width=(78-len(header)),
                                 break_long_words=False)
          for l in filled:
              out.write(header+" "+l+'\n')
              text = ""

      out.write(line)

os.rename(tmp, sys.argv[1])

Differential Revision: https://reviews.llvm.org/D46144

llvm-svn: 331197
This commit is contained in:
Adrian Prantl
2018-04-30 16:49:04 +00:00
parent add59c052d
commit 05097246f3
604 changed files with 11186 additions and 13434 deletions

View File

@@ -21,12 +21,10 @@ using namespace lldb_private;
namespace {
// This is a simple helper class to package up the information needed to return
// from a Read/Write
// operation function. Since there is a lot of code to be run before exit
// regardless of whether the
// operation succeeded or failed, combined with many possible return paths, this
// is the cleanest
// way to represent it.
// from a Read/Write operation function. Since there is a lot of code to be
// run before exit regardless of whether the operation succeeded or failed,
// combined with many possible return paths, this is the cleanest way to
// represent it.
class ReturnInfo {
public:
void Set(size_t bytes, ConnectionStatus status, DWORD error_code) {
@@ -78,11 +76,9 @@ void ConnectionGenericFile::InitializeEventHandles() {
m_event_handles[kInterruptEvent] = CreateEvent(NULL, FALSE, FALSE, NULL);
// Note, we should use a manual reset event for the hEvent argument of the
// OVERLAPPED. This
// is because both WaitForMultipleObjects and GetOverlappedResult (if you set
// the bWait
// argument to TRUE) will wait for the event to be signalled. If we use an
// auto-reset event,
// OVERLAPPED. This is because both WaitForMultipleObjects and
// GetOverlappedResult (if you set the bWait argument to TRUE) will wait for
// the event to be signalled. If we use an auto-reset event,
// WaitForMultipleObjects will reset the event, return successfully, and then
// GetOverlappedResult will block since the event is no longer signalled.
m_event_handles[kBytesAvailableEvent] =
@@ -147,8 +143,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) {
return eConnectionStatusSuccess;
// Reset the handle so that after we unblock any pending reads, subsequent
// calls to Read() will
// see a disconnected state.
// calls to Read() will see a disconnected state.
HANDLE old_file = m_file;
m_file = INVALID_HANDLE_VALUE;
@@ -157,8 +152,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) {
::CancelIoEx(old_file, &m_overlapped);
// Close the file handle if we owned it, but don't close the event handles.
// We could always
// reconnect with the same Connection instance.
// We could always reconnect with the same Connection instance.
if (m_owns_file)
::CloseHandle(old_file);
@@ -190,8 +184,7 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len,
if (result || ::GetLastError() == ERROR_IO_PENDING) {
if (!result) {
// The expected return path. The operation is pending. Wait for the
// operation to complete
// or be interrupted.
// operation to complete or be interrupted.
DWORD milliseconds =
timeout
? std::chrono::duration_cast<std::chrono::milliseconds>(*timeout)
@@ -219,11 +212,9 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len,
// The data is ready. Figure out how much was read and return;
if (!::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) {
DWORD result_error = ::GetLastError();
// ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during a
// blocking read.
// This triggers a call to CancelIoEx, which causes the operation to
// complete and the
// result to be ERROR_OPERATION_ABORTED.
// ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during
// a blocking read. This triggers a call to CancelIoEx, which causes the
// operation to complete and the result to be ERROR_OPERATION_ABORTED.
if (result_error == ERROR_HANDLE_EOF ||
result_error == ERROR_OPERATION_ABORTED ||
result_error == ERROR_BROKEN_PIPE)
@@ -250,9 +241,9 @@ finish:
if (error_ptr)
*error_ptr = return_info.GetError();
// kBytesAvailableEvent is a manual reset event. Make sure it gets reset here
// so that any
// subsequent operations don't immediately see bytes available.
// kBytesAvailableEvent is a manual reset event. Make sure it gets reset
// here so that any subsequent operations don't immediately see bytes
// available.
ResetEvent(m_event_handles[kBytesAvailableEvent]);
IncrementFilePointer(return_info.GetBytes());
@@ -284,7 +275,8 @@ size_t ConnectionGenericFile::Write(const void *src, size_t src_len,
m_overlapped.hEvent = NULL;
// Writes are not interruptible like reads are, so just block until it's done.
// Writes are not interruptible like reads are, so just block until it's
// done.
result = ::WriteFile(m_file, src, src_len, NULL, &m_overlapped);
if (!result && ::GetLastError() != ERROR_IO_PENDING) {
return_info.Set(0, eConnectionStatusError, ::GetLastError());