It almost looks to me like this should be using aggregation instead of inheritance.  That would add a 3rd option (mark it mutable).  That said, nothing wrong with using this approach either <br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 4, 2017 at 5:43 PM Vedant Kumar via Phabricator via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">vsk created this revision.<br>
Herald added a subscriber: javed.absar.<br>
<br>
A few methods in RegisterContext classes accept const objects which are<br>
cast to a non-const thread_state_t. Instead of dropping const-ness, it<br>
might be simpler and more ergonomic to just not mark the objects const.<br>
<br>
This fixes a slew of warnings.<br>
<br>
One alternative is to drop const-ness in a C++-friendly way, e.g:<br>
<br>
  const_cast<thread_state_t>(static_cast<thread_state_t>(&X))<br>
<br>
This would still leave us in a situation where some RegisterContext<br>
methods accept const objects and others don't, and it doesn't seem<br>
feasible to apply const everywhere here, because of non-const methods<br>
like SetRegisterDataFrom_LC_THREAD.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D40821" rel="noreferrer" target="_blank">https://reviews.llvm.org/D40821</a><br>
<br>
Files:<br>
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp<br>
  source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h<br>
  source/Plugins/Process/Utility/RegisterContextDarwin_arm.h<br>
  source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h<br>
  source/Plugins/Process/Utility/RegisterContextDarwin_i386.h<br>
  source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h<br>
  source/Plugins/Process/Utility/RegisterContextMach_arm.cpp<br>
  source/Plugins/Process/Utility/RegisterContextMach_arm.h<br>
  source/Plugins/Process/Utility/RegisterContextMach_i386.cpp<br>
  source/Plugins/Process/Utility/RegisterContextMach_i386.h<br>
  source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp<br>
  source/Plugins/Process/Utility/RegisterContextMach_x86_64.h<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>