[llvm-commits] [llvm] r120986 - /llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp

Michael J. Spencer bigcheesegs at gmail.com
Sun Dec 5 20:28:02 PST 2010


Author: mspencer
Date: Sun Dec  5 22:28:01 2010
New Revision: 120986

URL: http://llvm.org/viewvc/llvm-project?rev=120986&view=rev
Log:
KillTheDoctor: Cleanup error_code usage.

Modified:
    llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp

Modified: llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp?rev=120986&r1=120985&r2=120986&view=diff
==============================================================================
--- llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp (original)
+++ llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp Sun Dec  5 22:28:01 2010
@@ -164,10 +164,6 @@
   typedef ScopedHandle<ThreadHandle>            ThreadScopedHandle;
   typedef ScopedHandle<TokenHandle>             TokenScopedHandle;
   typedef ScopedHandle<FileHandle>              FileScopedHandle;
-
-  error_code get_windows_last_error() {
-    return make_error_code(windows_error(::GetLastError()));
-  }
 }
 
 static error_code GetFileNameFromHandle(HANDLE FileHandle,
@@ -181,7 +177,7 @@
   Sucess = ::GetFileSizeEx(FileHandle, &FileSize);
 
   if (!Sucess)
-   return get_windows_last_error();
+    return windows_error(::GetLastError());
 
   // Create a file mapping object.
   FileMappingScopedHandle FileMapping(
@@ -193,14 +189,14 @@
                          NULL));
 
   if (!FileMapping)
-    return get_windows_last_error();
+    return windows_error(::GetLastError());
 
   // Create a file mapping to get the file name.
   MappedViewOfFileScopedHandle MappedFile(
     ::MapViewOfFile(FileMapping, FILE_MAP_READ, 0, 0, 1));
 
   if (!MappedFile)
-    return get_windows_last_error();
+    return windows_error(::GetLastError());
 
   Sucess = ::GetMappedFileNameA(::GetCurrentProcess(),
                                 MappedFile,
@@ -208,7 +204,7 @@
                                 array_lengthof(Filename) - 1);
 
   if (!Sucess)
-    return get_windows_last_error();
+    return windows_error(::GetLastError());
   else {
     Name = Filename;
     return windows_error::success;
@@ -256,10 +252,10 @@
                                  PathName,
                                  NULL);
     if (length == 0)
-      ec = get_windows_last_error();
+      ec = windows_error(::GetLastError());
     else if (length > array_lengthof(PathName)) {
       // This may have been the file, return with error.
-      ec = error_code(windows_error::buffer_overflow);
+      ec = windows_error::buffer_overflow;
       break;
     } else {
       // We found the path! Return it.
@@ -279,7 +275,7 @@
                                     TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
                                     &TokenHandle);
   if (!success)
-    return error_code(::GetLastError(), system_category());
+    return windows_error(::GetLastError());
 
   TokenScopedHandle Token(TokenHandle);
   TOKEN_PRIVILEGES  TokenPrivileges;
@@ -289,7 +285,7 @@
                                     SE_DEBUG_NAME,
                                     &LocallyUniqueID);
   if (!success)
-    return error_code(::GetLastError(), system_category());
+    return windows_error(::GetLastError());
 
   TokenPrivileges.PrivilegeCount = 1;
   TokenPrivileges.Privileges[0].Luid = LocallyUniqueID;
@@ -303,7 +299,7 @@
                                     NULL);
   // The value of success is basically useless. Either way we are just returning
   // the value of ::GetLastError().
-  return error_code(::GetLastError(), system_category());
+  return windows_error(::GetLastError());
 }
 
 static StringRef ExceptionCodeToString(DWORD ExceptionCode) {
@@ -404,7 +400,7 @@
                                   &ProcessInfo);
   if (!success) {
     errs() << ToolName << ": Failed to run program: '" << ProgramToRun
-           << "': " << error_code(::GetLastError(), system_category()).message()
+           << "': " << error_code(windows_error(::GetLastError())).message()
            << '\n';
     return -1;
   }
@@ -432,7 +428,7 @@
                                   &KernelTime,
                                   &UserTime);
       if (!success) {
-        ec = error_code(::GetLastError(), system_category());
+        ec = windows_error(::GetLastError());
 
         errs() << ToolName << ": Failed to get process times: "
                << ec.message() << '\n';
@@ -467,9 +463,9 @@
     success = WaitForDebugEvent(&DebugEvent, TimeLeft);
 
     if (!success) {
-      ec = error_code(::GetLastError(), system_category());
+      ec = windows_error(::GetLastError());
 
-      if (ec == error_condition(errc::timed_out)) {
+      if (ec == errc::timed_out) {
         errs() << ToolName << ": Process timed out.\n";
         ::TerminateProcess(ProcessInfo.hProcess, -1);
         // Otherwise other stuff starts failing...
@@ -586,7 +582,7 @@
                                  DebugEvent.dwThreadId,
                                  dwContinueStatus);
     if (!success) {
-      ec = error_code(::GetLastError(), system_category());
+      ec = windows_error(::GetLastError());
       errs() << ToolName << ": Failed to continue debugging program: '"
              << ProgramToRun << "': " << ec.message() << '\n';
       return -1;





More information about the llvm-commits mailing list