Remove null checks of results of new expressions
authorPavel Labath <pavel@labath.sk>
Mon, 1 Jul 2019 11:09:15 +0000 (11:09 +0000)
committerPavel Labath <pavel@labath.sk>
Mon, 1 Jul 2019 11:09:15 +0000 (11:09 +0000)
operator new doesn't return a null pointer, even if one turns off
exceptions (it calls std::terminate instead). Therefore, all of this is
dead code.

llvm-svn: 364744

15 files changed:
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp

index 7d7453c..eaf973d 100644 (file)
@@ -246,14 +246,12 @@ size_t ObjectFileJIT::ReadSectionData(
   if (section->GetFileSize()) {
     const void *src = (void *)(uintptr_t)section->GetFileOffset();
 
-    DataBufferSP data_sp(
-        new lldb_private::DataBufferHeap(src, section->GetFileSize()));
-    if (data_sp) {
-      section_data.SetData(data_sp, 0, data_sp->GetByteSize());
-      section_data.SetByteOrder(GetByteOrder());
-      section_data.SetAddressByteSize(GetAddressByteSize());
-      return section_data.GetByteSize();
-    }
+    DataBufferSP data_sp =
+        std::make_shared<DataBufferHeap>(src, section->GetFileSize());
+    section_data.SetData(data_sp, 0, data_sp->GetByteSize());
+    section_data.SetByteOrder(GetByteOrder());
+    section_data.SetAddressByteSize(GetAddressByteSize());
+    return section_data.GetByteSize();
   }
   section_data.Clear();
   return 0;
index 89677d4..f0c4526 100644 (file)
@@ -155,7 +155,7 @@ bool RegisterContextPOSIXProcessMonitor_arm::ReadAllRegisterValues(
     DataBufferSP &data_sp) {
   bool success = false;
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR() && ReadFPR()) {
+  if (ReadGPR() && ReadFPR()) {
     uint8_t *dst = data_sp->GetBytes();
     success = dst != 0;
 
index 801d1c4..147f4b5 100644 (file)
@@ -164,7 +164,7 @@ bool RegisterContextPOSIXProcessMonitor_arm64::ReadAllRegisterValues(
     lldb::DataBufferSP &data_sp) {
   bool success = false;
   data_sp.reset(new lldb_private::DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR() && ReadFPR()) {
+  if (ReadGPR() && ReadFPR()) {
     uint8_t *dst = data_sp->GetBytes();
     success = dst != 0;
 
index 706e5ce..db9b5a6 100644 (file)
@@ -160,7 +160,7 @@ bool RegisterContextPOSIXProcessMonitor_mips64::ReadAllRegisterValues(
     DataBufferSP &data_sp) {
   bool success = false;
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR() && ReadFPR()) {
+  if (ReadGPR() && ReadFPR()) {
     uint8_t *dst = data_sp->GetBytes();
     success = dst != 0;
 
index d94638d..7769473 100644 (file)
@@ -170,7 +170,7 @@ bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues(
     DataBufferSP &data_sp) {
   bool success = false;
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR() && ReadFPR()) {
+  if (ReadGPR() && ReadFPR()) {
     uint8_t *dst = data_sp->GetBytes();
     success = dst != 0;
 
index 01e1224..3046d97 100644 (file)
@@ -344,7 +344,7 @@ bool RegisterContextPOSIXProcessMonitor_x86_64::ReadAllRegisterValues(
     DataBufferSP &data_sp) {
   bool success = false;
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (data_sp && ReadGPR() && ReadFPR()) {
+  if (ReadGPR() && ReadFPR()) {
     uint8_t *dst = data_sp->GetBytes();
     success = dst != 0;
 
index 3c6e014..6204dbe 100644 (file)
@@ -276,10 +276,6 @@ Status NativeRegisterContextLinux_arm::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp)
-    return Status("failed to allocate DataBufferHeap instance of size %" PRIu64,
-                  (uint64_t)REG_CONTEXT_SIZE);
-
   error = ReadGPR();
   if (error.Fail())
     return error;
index 8e0c459..3a232e0 100644 (file)
@@ -277,10 +277,6 @@ Status NativeRegisterContextLinux_arm64::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp)
-    return Status("failed to allocate DataBufferHeap instance of size %" PRIu64,
-                  REG_CONTEXT_SIZE);
-
   error = ReadGPR();
   if (error.Fail())
     return error;
index 3ca9b43..4f91596 100644 (file)
@@ -381,13 +381,6 @@ Status NativeRegisterContextLinux_mips64::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp) {
-    error.SetErrorStringWithFormat(
-        "failed to allocate DataBufferHeap instance of size %" PRIu64,
-        REG_CONTEXT_SIZE);
-    return error;
-  }
-
   error = ReadGPR();
   if (!error.Success()) {
     error.SetErrorString("ReadGPR() failed");
index 697f6f4..8e99a09 100644 (file)
@@ -354,10 +354,6 @@ Status NativeRegisterContextLinux_ppc64le::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp)
-    return Status("failed to allocate DataBufferHeap instance of size %" PRIu64,
-                  REG_CONTEXT_SIZE);
-
   error = ReadGPR();
   if (error.Fail())
     return error;
index 5d13557..5a26898 100644 (file)
@@ -336,13 +336,6 @@ Status NativeRegisterContextLinux_s390x::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp) {
-    error.SetErrorStringWithFormat(
-        "failed to allocate DataBufferHeap instance of size %" PRIu64,
-        REG_CONTEXT_SIZE);
-    return error;
-  }
-
   uint8_t *dst = data_sp->GetBytes();
   if (dst == nullptr) {
     error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
index da11198..1a4d453 100644 (file)
@@ -572,13 +572,6 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
   Status error;
 
   data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
-  if (!data_sp) {
-    error.SetErrorStringWithFormat(
-        "failed to allocate DataBufferHeap instance of size %" PRIu64,
-        REG_CONTEXT_SIZE);
-    return error;
-  }
-
   error = ReadRegisterSet(GPRegSet);
   if (error.Fail())
     return error;
index e0d67d1..85d518a 100644 (file)
@@ -646,8 +646,8 @@ bool RegisterContextDarwin_arm64::WriteRegister(const RegisterInfo *reg_info,
 bool RegisterContextDarwin_arm64::ReadAllRegisterValues(
     lldb::DataBufferSP &data_sp) {
   data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
-  if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
-      ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
+  if (ReadGPR(false) == KERN_SUCCESS && ReadFPU(false) == KERN_SUCCESS &&
+      ReadEXC(false) == KERN_SUCCESS) {
     uint8_t *dst = data_sp->GetBytes();
     ::memcpy(dst, &gpr, sizeof(gpr));
     dst += sizeof(gpr);
index 69b5624..820d280 100644 (file)
@@ -830,8 +830,7 @@ bool RegisterContextDarwin_i386::WriteRegister(const RegisterInfo *reg_info,
 bool RegisterContextDarwin_i386::ReadAllRegisterValues(
     lldb::DataBufferSP &data_sp) {
   data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
-  if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 &&
-      ReadEXC(false) == 0) {
+  if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) {
     uint8_t *dst = data_sp->GetBytes();
     ::memcpy(dst, &gpr, sizeof(gpr));
     dst += sizeof(gpr);
index e908c6d..62e512a 100644 (file)
@@ -910,8 +910,7 @@ bool RegisterContextDarwin_x86_64::WriteRegister(const RegisterInfo *reg_info,
 bool RegisterContextDarwin_x86_64::ReadAllRegisterValues(
     lldb::DataBufferSP &data_sp) {
   data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
-  if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 &&
-      ReadEXC(false) == 0) {
+  if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) {
     uint8_t *dst = data_sp->GetBytes();
     ::memcpy(dst, &gpr, sizeof(gpr));
     dst += sizeof(gpr);