This revision was automatically updated to reflect the committed changes.
Closed by commit rL368614: [Symbol] GetTypeBitAlign() should return None in 
case of failure. (authored by davide, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66093?vs=214647&id=214693#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66093/new/

https://reviews.llvm.org/D66093

Files:
  lldb/trunk/include/lldb/Symbol/ClangASTContext.h
  lldb/trunk/include/lldb/Symbol/CompilerType.h
  lldb/trunk/include/lldb/Symbol/TypeSystem.h
  lldb/trunk/source/Expression/Materializer.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/CompilerType.cpp

Index: lldb/trunk/include/lldb/Symbol/CompilerType.h
===================================================================
--- lldb/trunk/include/lldb/Symbol/CompilerType.h
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h
@@ -257,7 +257,7 @@
 
   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;
Index: lldb/trunk/include/lldb/Symbol/TypeSystem.h
===================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h
@@ -386,7 +386,8 @@
   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;
 
Index: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
===================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h
@@ -708,7 +708,8 @@
 
   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,
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1302,8 +1302,10 @@
     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}, "
Index: lldb/trunk/source/Expression/Materializer.cpp
===================================================================
--- lldb/trunk/source/Expression/Materializer.cpp
+++ lldb/trunk/source/Expression/Materializer.cpp
@@ -530,12 +530,15 @@
           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 @@
         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;
Index: lldb/trunk/source/Symbol/CompilerType.cpp
===================================================================
--- lldb/trunk/source/Symbol/CompilerType.cpp
+++ lldb/trunk/source/Symbol/CompilerType.cpp
@@ -503,10 +503,10 @@
   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 {
Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -5087,10 +5087,11 @@
   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,
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to