[Lldb-commits] [lldb] r319939 - Fix const-correctness in RegisterContext methods, NFC

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 6 11:21:12 PST 2017


Author: vedantk
Date: Wed Dec  6 11:21:12 2017
New Revision: 319939

URL: http://llvm.org/viewvc/llvm-project?rev=319939&view=rev
Log:
Fix const-correctness in RegisterContext methods, NFC

A few methods in RegisterContext classes accept const objects which are
cast to a non-const thread_state_t. Drop const-ness more explicitly
where we mean to do so. This fixes a slew of warnings.

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

Modified:
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp?rev=319939&r1=319938&r2=319939&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp Wed Dec  6 11:21:12 2017
@@ -50,22 +50,30 @@ int RegisterContextMach_arm::DoReadDBG(l
 
 int RegisterContextMach_arm::DoWriteGPR(lldb::tid_t tid, int flavor,
                                         const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),
+      GPRWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor,
                                         const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),
+      FPUWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor,
                                         const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),
+      EXCWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor,
                                         const DBG &dbg) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&dbg, DBGWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<DBG *>(&dbg)),
+      DBGWordCount);
 }
 
 #endif

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp?rev=319939&r1=319938&r2=319939&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp Wed Dec  6 11:21:12 2017
@@ -43,17 +43,23 @@ int RegisterContextMach_i386::DoReadEXC(
 
 int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
                                          const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),
+      GPRWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
                                          const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),
+      FPUWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
                                          const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),
+      EXCWordCount);
 }
 
 #endif

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp?rev=319939&r1=319938&r2=319939&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp Wed Dec  6 11:21:12 2017
@@ -46,17 +46,23 @@ int RegisterContextMach_x86_64::DoReadEX
 
 int RegisterContextMach_x86_64::DoWriteGPR(lldb::tid_t tid, int flavor,
                                            const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),
+      GPRWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor,
                                            const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),
+      FPUWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor,
                                            const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+      tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),
+      EXCWordCount);
 }
 
 #endif




More information about the lldb-commits mailing list