[Lldb-commits] [PATCH] D19086: [clang-analyzer] fix warnings emitted on lldb code base

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 13 17:51:20 PDT 2016


jingham added a subscriber: jingham.
jingham requested changes to this revision.
jingham added a reviewer: jingham.
This revision now requires changes to proceed.

================
Comment at: source/API/SBThread.cpp:926
@@ -925,3 +925,3 @@
         Thread *thread = exe_ctx.GetThreadPtr();
-        if (sb_frame.GetThread().GetThreadID() != thread->GetID())
+        if (sb_frame.GetThread().GetThreadID() != thread->GetID() && log)
         {
----------------
Can you switch this around and check for log first?  We generally don't like to do any work that the log might do if there's no log, and also it makes it easier to see that this whole block is only for logging.

================
Comment at: source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp:309-329
@@ -308,19 +308,23 @@
             {
-                const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+                const RegisterInfo *r2_info = nullptr;
+
+                if (reg_ctx)
+                  r2_info = reg_ctx->GetRegisterInfoByName("r2", 0);
+
                 if (num_bytes <= 8)
                 {
                     uint64_t raw_value = data.GetMaxU64(&offset, num_bytes);
                         
-                    if (!reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value))
+                    if (reg_ctx && !reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value))
                         error.SetErrorString ("failed to write register r2");
                 }
                 else
                 {
                     uint64_t raw_value = data.GetMaxU64(&offset, 8);
-                    if (reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value))
+                    if (reg_ctx && reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value))
                     {
                         const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0);
                         raw_value = data.GetMaxU64(&offset, num_bytes - offset);
                         
-                        if (!reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value))
+                        if (reg_ctx && !reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value))
                             error.SetErrorString ("failed to write register r3");
----------------
Seems to me this whole section of code doesn't do anything reasonable if reg_ctx is null.  It would be better to move the reg_ctx check higher up.


http://reviews.llvm.org/D19086





More information about the lldb-commits mailing list