[Lldb-commits] [PATCH] D51445: Remove undefined behavior around the use of StateType

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 29 11:00:55 PDT 2018


shafik created this revision.
shafik added reviewers: jingham, aprantl, davide.

lldb::StateType is an enum without an explicit underlying type.

According to [dcl.enum]p8 http://eel.is/c++draft/dcl.enum#8 and [expr.static.cast]p10  http://eel.is/c++draft/expr.static.cast#10 we are limited to setting StateType to values bound with a value range based on the values of the enumerators. Currently we have a test and SWIG interface that either explicitly set StateType to a value outside of the allowed range or in the case of SWIG does not prevent it.

In both cases using UBSan generates a runtime error when we load a value outside of the range allowed by the standard.

This change refactors StateType to keep track of the largest value and range checking to the SWIG interface and removes the invalid test case.


https://reviews.llvm.org/D51445

Files:
  include/lldb/lldb-enumerations.h
  scripts/Python/python-typemaps.swig
  source/Interpreter/CommandObject.cpp
  source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Target/Process.cpp
  source/Utility/State.cpp
  unittests/Utility/StateTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51445.163140.patch
Type: text/x-patch
Size: 6049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180829/a175a798/attachment-0001.bin>


More information about the lldb-commits mailing list