diff options
Diffstat (limited to 'source/Plugins/ExpressionParser/Clang/IRForTarget.cpp')
| -rw-r--r-- | source/Plugins/ExpressionParser/Clang/IRForTarget.cpp | 42 | 
1 files changed, 19 insertions, 23 deletions
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index e51c9ee07b9ff..3a7cd58b70ab1 100644 --- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -25,7 +25,6 @@  #include "clang/AST/ASTContext.h" -#include "lldb/Core/Scalar.h"  #include "lldb/Core/dwarf.h"  #include "lldb/Expression/IRExecutionUnit.h"  #include "lldb/Expression/IRInterpreter.h" @@ -36,6 +35,7 @@  #include "lldb/Utility/DataBufferHeap.h"  #include "lldb/Utility/Endian.h"  #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h"  #include "lldb/Utility/StreamString.h"  #include <map> @@ -310,12 +310,14 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {    lldb::TargetSP target_sp(m_execution_unit.GetTarget());    lldb_private::ExecutionContext exe_ctx(target_sp, true); -  if (m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope()) == 0) { +  llvm::Optional<uint64_t> bit_size = +      m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope()); +  if (!bit_size) {      lldb_private::StreamString type_desc_stream;      m_result_type.DumpTypeDescription(&type_desc_stream);      if (log) -      log->Printf("Result type has size 0"); +      log->Printf("Result type has unknown size");      m_error_stream.Printf("Error [IRForTarget]: Size of result type '%s' "                            "couldn't be determined\n", @@ -334,7 +336,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {    if (log)      log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64, -                m_result_name.GetCString(), m_result_type.GetByteSize(nullptr)); +                m_result_name.GetCString(), +                m_result_type.GetByteSize(nullptr).getValueOr(0));    // Construct a new result global and set up its metadata @@ -778,11 +781,8 @@ bool IRForTarget::RewriteObjCConstStrings() {  static bool IsObjCSelectorRef(Value *value) {    GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value); -  if (!global_variable || !global_variable->hasName() || -      !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")) -    return false; - -  return true; +  return !(!global_variable || !global_variable->hasName() || +           !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_"));  }  // This function does not report errors; its callers are responsible. @@ -953,11 +953,8 @@ bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) {  static bool IsObjCClassReference(Value *value) {    GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value); -  if (!global_variable || !global_variable->hasName() || -      !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_")) -    return false; - -  return true; +  return !(!global_variable || !global_variable->hasName() || +           !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_"));  }  // This function does not report errors; its callers are responsible. @@ -1259,12 +1256,9 @@ bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) {          llvm::NextPowerOf2(constant_size) * 8);      lldb_private::Status get_data_error; -    if (!scalar.GetAsMemoryData(data, constant_size, -                                lldb_private::endian::InlHostByteOrder(), -                                get_data_error)) -      return false; - -    return true; +    return scalar.GetAsMemoryData(data, constant_size, +                                  lldb_private::endian::InlHostByteOrder(), +                                  get_data_error) != 0;    } else if (ConstantDataArray *array_initializer =                   dyn_cast<ConstantDataArray>(initializer)) {      if (array_initializer->isString()) { @@ -1376,7 +1370,9 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {        value_type = global_variable->getType();      } -    const uint64_t value_size = compiler_type.GetByteSize(nullptr); +    llvm::Optional<uint64_t> value_size = compiler_type.GetByteSize(nullptr); +    if (!value_size) +      return false;      lldb::offset_t value_alignment =          (compiler_type.GetTypeBitAlign() + 7ull) / 8ull; @@ -1387,13 +1383,13 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {                    lldb_private::ClangUtil::GetQualType(compiler_type)                        .getAsString()                        .c_str(), -                  PrintType(value_type).c_str(), value_size, value_alignment); +                  PrintType(value_type).c_str(), *value_size, value_alignment);      }      if (named_decl &&          !m_decl_map->AddValueToStruct(              named_decl, lldb_private::ConstString(name.c_str()), llvm_value_ptr, -            value_size, value_alignment)) { +            *value_size, value_alignment)) {        if (!global_variable->hasExternalLinkage())          return true;        else  | 
