summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2019-08-12 20:03:19 +0000
committerDavide Italiano <davide@freebsd.org>2019-08-12 20:03:19 +0000
commit36f13e49127e56d6db4aeb76c0bbfacab1988157 (patch)
tree30444a46b609ed4b3055d0b4059fbd1fcfa6d454
parentd2e493c3378b4b61e16109c67568f5d642f3c3a1 (diff)
downloadbcm5719-llvm-36f13e49127e56d6db4aeb76c0bbfacab1988157.tar.gz
bcm5719-llvm-36f13e49127e56d6db4aeb76c0bbfacab1988157.zip
[Symbol] GetTypeBitAlign() should return None in case of failure.
Summary: And not `zero`. This is the last API needed to be converted to an Optional<T>. Reviewers: xiaobai, compnerd Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66093 llvm-svn: 368614
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h3
-rw-r--r--lldb/include/lldb/Symbol/CompilerType.h2
-rw-r--r--lldb/include/lldb/Symbol/TypeSystem.h3
-rw-r--r--lldb/source/Expression/Materializer.cpp22
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp6
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp5
-rw-r--r--lldb/source/Symbol/CompilerType.cpp4
7 files changed, 28 insertions, 17 deletions
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 8e2b6a3babe..51e0c42ddc7 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -708,7 +708,8 @@ public:
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override;
- size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
+ llvm::Optional<size_t>
+ GetTypeBitAlign(lldb::opaque_compiler_type_t type) override;
uint32_t GetNumChildren(lldb::opaque_compiler_type_t type,
bool omit_empty_base_classes,
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 62ceb1059e0..16894fda00b 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -257,7 +257,7 @@ public:
lldb::Format GetFormat() const;
- size_t GetTypeBitAlign() const;
+ llvm::Optional<size_t> GetTypeBitAlign() const;
uint32_t GetNumChildren(bool omit_empty_base_classes,
const ExecutionContext *exe_ctx) const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 347d1f8f390..1ef2dacaef8 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -386,7 +386,8 @@ public:
virtual bool IsCStringType(lldb::opaque_compiler_type_t type,
uint32_t &length) = 0;
- virtual size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) = 0;
+ virtual llvm::Optional<size_t>
+ GetTypeBitAlign(lldb::opaque_compiler_type_t type) = 0;
virtual CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) = 0;
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 64dffa3d3bf..c20422ae77c 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -530,12 +530,15 @@ public:
return;
}
- size_t bit_align =
+ llvm::Optional<size_t> opt_bit_align =
m_variable_sp->GetType()->GetLayoutCompilerType().GetTypeBitAlign();
- size_t byte_align = (bit_align + 7) / 8;
+ if (!opt_bit_align) {
+ err.SetErrorStringWithFormat("can't get the type alignment for %s",
+ m_variable_sp->GetName().AsCString());
+ return;
+ }
- if (!byte_align)
- byte_align = 1;
+ size_t byte_align = (*opt_bit_align + 7) / 8;
Status alloc_error;
const bool zero_memory = false;
@@ -788,11 +791,14 @@ public:
err.SetErrorString("can't get size of type");
return;
}
- size_t bit_align = m_type.GetTypeBitAlign();
- size_t byte_align = (bit_align + 7) / 8;
- if (!byte_align)
- byte_align = 1;
+ llvm::Optional<size_t> opt_bit_align = m_type.GetTypeBitAlign();
+ if (!opt_bit_align) {
+ err.SetErrorStringWithFormat("can't get the type alignment");
+ return;
+ }
+
+ size_t byte_align = (*opt_bit_align + 7) / 8;
Status alloc_error;
const bool zero_memory = true;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 29d2bbf43eb..b7d84877a35 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1302,8 +1302,10 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
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;
+ llvm::Optional<size_t> opt_alignment = compiler_type.GetTypeBitAlign();
+ if (!opt_alignment)
+ return false;
+ lldb::offset_t value_alignment = (*opt_alignment + 7ull) / 8ull;
LLDB_LOG(log,
"Type of \"{0}\" is [clang \"{1}\", llvm \"{2}\"] [size {3}, "
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 8c9cbe08ee4..edc8acf2a21 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -5087,10 +5087,11 @@ ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
return None;
}
-size_t ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type) {
+llvm::Optional<size_t>
+ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type) {
if (GetCompleteType(type))
return getASTContext()->getTypeAlign(GetQualType(type));
- return 0;
+ return {};
}
lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index b12c89e749a..f57843e3374 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -503,10 +503,10 @@ CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
return {};
}
-size_t CompilerType::GetTypeBitAlign() const {
+llvm::Optional<size_t> CompilerType::GetTypeBitAlign() const {
if (IsValid())
return m_type_system->GetTypeBitAlign(m_type);
- return 0;
+ return {};
}
lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {
OpenPOWER on IntegriCloud