Make CompilerType::getBitSize() / getByteSize() return an optional result. NFC
authorAdrian Prantl <aprantl@apple.com>
Tue, 15 Jan 2019 18:07:52 +0000 (18:07 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 15 Jan 2019 18:07:52 +0000 (18:07 +0000)
commitd963a7c39891ae33e87500502d5199946af22bde
tree1a5d123b49e1e9e039a62b08a9011cb91560883f
parent5e54bc18e27b7fa2af240ff93f1771faa425c319
Make CompilerType::getBitSize() / getByteSize() return an optional result. NFC

The code in LLDB assumes that CompilerType and friends use the size 0
as a sentinel value to signal an error. This works for C++, where no
zero-sized type exists, but in many other programming languages
(including I believe C) types of size zero are possible and even
common. This is a particular pain point in swift-lldb, where extra
code exists to double-check that a type is *really* of size zero and
not an error at various locations.

To remedy this situation, this patch starts by converting
CompilerType::getBitSize() and getByteSize() to return an optional
result. To avoid wasting space, I hand-rolled my own optional data
type assuming that no type is larger than what fits into 63
bits. Follow-up patches would make similar changes to the ValueObject
hierarchy.

rdar://problem/47178964

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

llvm-svn: 351214
36 files changed:
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Target/ProcessStructReader.h
lldb/source/API/SBType.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Core/Value.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectConstResult.cpp
lldb/source/Core/ValueObjectMemory.cpp
lldb/source/Core/ValueObjectVariable.cpp
lldb/source/DataFormatters/TypeFormat.cpp
lldb/source/DataFormatters/VectorType.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/source/Symbol/CompilerType.cpp
lldb/source/Symbol/Type.cpp