[Lldb-commits] [lldb] r221906 - Refactor NativeProcessLinux::AttachToProcess in order to avoid reinterpret_cast from NativeProcessProtocol* to NativeProcessLinux*.

Oleksiy Vyalov ovyalov at google.com
Thu Nov 13 10:22:16 PST 2014


Author: ovyalov
Date: Thu Nov 13 12:22:16 2014
New Revision: 221906

URL: http://llvm.org/viewvc/llvm-project?rev=221906&view=rev
Log:
Refactor NativeProcessLinux::AttachToProcess in order to avoid reinterpret_cast from NativeProcessProtocol* to NativeProcessLinux*.

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=221906&r1=221905&r2=221906&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Nov 13 12:22:16 2014
@@ -1298,22 +1298,19 @@ NativeProcessLinux::AttachToProcess (
     if (!error.Success ())
         return error;
 
-    native_process_sp.reset (new NativeProcessLinux ());
+    std::shared_ptr<NativeProcessLinux> native_process_linux_sp (new NativeProcessLinux ());
 
-    if (!native_process_sp->RegisterNativeDelegate (native_delegate))
+    if (!native_process_linux_sp->RegisterNativeDelegate (native_delegate))
     {
-        native_process_sp.reset (new NativeProcessLinux ());
         error.SetErrorStringWithFormat ("failed to register the native delegate");
         return error;
     }
 
-    reinterpret_cast<NativeProcessLinux*> (native_process_sp.get ())->AttachToInferior (pid, error);
+    native_process_linux_sp->AttachToInferior (pid, error);
     if (!error.Success ())
-    {
-        native_process_sp.reset ();
         return error;
-    }
 
+    native_process_sp = native_process_linux_sp;
     return error;
 }
 





More information about the lldb-commits mailing list