[Lldb-commits] [lldb] 03310c1 - [lldb][NFC] Give CompilerType's IsArrayType/IsVectorType/IsBlockPointerType out-parameters default values

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 23 02:15:52 PST 2021


Author: Raphael Isemann
Date: 2021-02-23T11:15:31+01:00
New Revision: 03310c1e952d0bf7aa84b8ed06809aa7ea1deb9b

URL: https://github.com/llvm/llvm-project/commit/03310c1e952d0bf7aa84b8ed06809aa7ea1deb9b
DIFF: https://github.com/llvm/llvm-project/commit/03310c1e952d0bf7aa84b8ed06809aa7ea1deb9b.diff

LOG: [lldb][NFC] Give CompilerType's IsArrayType/IsVectorType/IsBlockPointerType out-parameters default values

We already do this for most functions that have out-parameters, so let's do
the same here and avoid all the `nullptr, nullptr, nullptr` in every call.

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/CompilerType.h
    lldb/source/Core/ValueObject.cpp
    lldb/source/DataFormatters/VectorType.cpp
    lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
    lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
    lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
    lldb/source/Symbol/CompilerType.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 5a0e8e57200d..0ad05a27570e 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -71,10 +71,12 @@ class CompilerType {
 
   bool IsValid() const { return m_type != nullptr && m_type_system != nullptr; }
 
-  bool IsArrayType(CompilerType *element_type, uint64_t *size,
-                   bool *is_incomplete) const;
+  bool IsArrayType(CompilerType *element_type = nullptr,
+                   uint64_t *size = nullptr,
+                   bool *is_incomplete = nullptr) const;
 
-  bool IsVectorType(CompilerType *element_type, uint64_t *size) const;
+  bool IsVectorType(CompilerType *element_type = nullptr,
+                    uint64_t *size = nullptr) const;
 
   bool IsArrayOfScalarType() const;
 
@@ -110,7 +112,8 @@ class CompilerType {
 
   bool IsFunctionPointerType() const;
 
-  bool IsBlockPointerType(CompilerType *function_pointer_type_ptr) const;
+  bool
+  IsBlockPointerType(CompilerType *function_pointer_type_ptr = nullptr) const;
 
   bool IsIntegerType(bool &is_signed) const;
 

diff  --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 6f736c3edfb7..8f90ae873160 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -914,7 +914,7 @@ ValueObject::ReadPointedString(lldb::DataBufferSP &buffer_sp, Status &error,
     if (is_array) {
       // We have an array
       uint64_t array_size = 0;
-      if (compiler_type.IsArrayType(nullptr, &array_size, nullptr)) {
+      if (compiler_type.IsArrayType(nullptr, &array_size)) {
         cstr_len = array_size;
         if (cstr_len > max_length) {
           capped_data = true;
@@ -1608,9 +1608,7 @@ ValueObject::GetTypeInfo(CompilerType *pointee_or_element_compiler_type) {
 
 bool ValueObject::IsPointerType() { return GetCompilerType().IsPointerType(); }
 
-bool ValueObject::IsArrayType() {
-  return GetCompilerType().IsArrayType(nullptr, nullptr, nullptr);
-}
+bool ValueObject::IsArrayType() { return GetCompilerType().IsArrayType(); }
 
 bool ValueObject::IsScalarType() { return GetCompilerType().IsScalarType(); }
 

diff  --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp
index cc24bb1de428..11371918830b 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -219,7 +219,7 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
     m_parent_format = m_backend.GetFormat();
     CompilerType parent_type(m_backend.GetCompilerType());
     CompilerType element_type;
-    parent_type.IsVectorType(&element_type, nullptr);
+    parent_type.IsVectorType(&element_type);
     m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type,
                                               parent_type.GetTypeSystem());
     m_num_children = ::CalculateNumChildren(parent_type, m_child_type);

diff  --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
index 8a9be3fb67c7..3e544e0483a7 100644
--- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
@@ -1617,7 +1617,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
         thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) &
         UINT32_MAX;
     value.GetScalar() = ptr;
-  } else if (compiler_type.IsVectorType(nullptr, nullptr)) {
+  } else if (compiler_type.IsVectorType()) {
     if (IsArmHardFloat(thread) && (*byte_size == 8 || *byte_size == 16)) {
       is_vfp_candidate = true;
       vfp_byte_size = 8;
@@ -1704,7 +1704,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
       if (homogeneous_count > 0 && homogeneous_count <= 4) {
         llvm::Optional<uint64_t> base_byte_size =
             base_type.GetByteSize(&thread);
-        if (base_type.IsVectorType(nullptr, nullptr)) {
+        if (base_type.IsVectorType()) {
           if (base_byte_size &&
               (*base_byte_size == 8 || *base_byte_size == 16)) {
             is_vfp_candidate = true;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index d844498fd8a3..714c5ccb824c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1054,7 +1054,7 @@ CPlusPlusLanguage::GetHardcodedSummaries() {
                       .SetSkipReferences(false),
                   lldb_private::formatters::VectorTypeSummaryProvider,
                   "vector_type pointer summary provider"));
-          if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
+          if (valobj.GetCompilerType().IsVectorType()) {
             if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
               return formatter_sp;
           }
@@ -1074,7 +1074,7 @@ CPlusPlusLanguage::GetHardcodedSummaries() {
                       .SetSkipReferences(false),
                   lldb_private::formatters::BlockPointerSummaryProvider,
                   "block pointer summary provider"));
-          if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
+          if (valobj.GetCompilerType().IsBlockPointerType()) {
             return formatter_sp;
           }
           return nullptr;
@@ -1104,7 +1104,7 @@ CPlusPlusLanguage::GetHardcodedSynthetics() {
                   .SetNonCacheable(true),
               "vector_type synthetic children",
               lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
-      if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
+      if (valobj.GetCompilerType().IsVectorType()) {
         if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
           return formatter_sp;
       }
@@ -1123,7 +1123,7 @@ CPlusPlusLanguage::GetHardcodedSynthetics() {
                   .SetNonCacheable(true),
               "block pointer synthetic children",
               lldb_private::formatters::BlockPointerSyntheticFrontEndCreator));
-      if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
+      if (valobj.GetCompilerType().IsBlockPointerType()) {
         return formatter_sp;
       }
       return nullptr;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index 6de4637a6a4a..e5b868fc0fce 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -85,7 +85,7 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) {
   CompilerType type;
   ValueObjectSP chunk;
   // For small bitsets __first_ is not an array, but a plain size_t.
-  if (m_first->GetCompilerType().IsArrayType(&type, nullptr, nullptr)) {
+  if (m_first->GetCompilerType().IsArrayType(&type)) {
     llvm::Optional<uint64_t> bit_size =
         type.GetBitSize(ctx.GetBestExecutionContextScope());
     if (!bit_size || *bit_size == 0)

diff  --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 4f0c3b366af5..ac98352c235e 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -248,7 +248,7 @@ bool CompilerType::IsPointerToScalarType() const {
 
 bool CompilerType::IsArrayOfScalarType() const {
   CompilerType element_type;
-  if (IsArrayType(&element_type, nullptr, nullptr))
+  if (IsArrayType(&element_type))
     return element_type.IsScalarType();
   return false;
 }


        


More information about the lldb-commits mailing list