Skip to content

[lldb] Restore ObjC incomplete type dereferencing fix #139567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

kuilpd
Copy link
Contributor

@kuilpd kuilpd commented May 12, 2025

Attempt an ObjC incomplete type fix even if GetDereferencedType returns an error.

@kuilpd kuilpd requested a review from felipepiovezan May 12, 2025 15:51
@kuilpd kuilpd added the lldb label May 12, 2025
@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@llvm/pr-subscribers-lldb

Author: Ilia Kuklin (kuilpd)

Changes

Attempt an ObjC incomplete type fix even if GetDereferencedType returns an error.


Full diff: https://github.com/llvm/llvm-project/pull/139567.diff

1 Files Affected:

  • (modified) lldb/source/ValueObject/ValueObject.cpp (+35-34)
diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp
index 6f0fe9a5b83f9..46426ae499be9 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2810,46 +2810,47 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   std::string deref_error;
   if (deref_compiler_type_or_err) {
     deref_compiler_type = *deref_compiler_type_or_err;
-    if (deref_compiler_type && deref_byte_size) {
-      ConstString deref_name;
-      if (!deref_name_str.empty())
-        deref_name.SetCString(deref_name_str.c_str());
-
-      m_deref_valobj =
-          new ValueObjectChild(*this, deref_compiler_type, deref_name,
-                               deref_byte_size, deref_byte_offset, 0, 0, false,
-                               true, eAddressTypeInvalid, language_flags);
-    }
-
-    // In case of incomplete deref compiler type, use the pointee type and try
-    // to recreate a new ValueObjectChild using it.
-    if (!m_deref_valobj) {
-      // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
-      // `std::vector<int> &`). Remove ObjC restriction once that's resolved.
-      if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
-          HasSyntheticValue()) {
-        deref_compiler_type = compiler_type.GetPointeeType();
-
-        if (deref_compiler_type) {
-          ConstString deref_name;
-          if (!deref_name_str.empty())
-            deref_name.SetCString(deref_name_str.c_str());
-
-          m_deref_valobj = new ValueObjectChild(
-              *this, deref_compiler_type, deref_name, deref_byte_size,
-              deref_byte_offset, 0, 0, false, true, eAddressTypeInvalid,
-              language_flags);
-        }
-      }
-    }
   } else {
     deref_error = llvm::toString(deref_compiler_type_or_err.takeError());
     LLDB_LOG(GetLog(LLDBLog::Types), "could not find child: {0}", deref_error);
-    if (IsSynthetic()) {
-      m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
+  }
+
+  if (deref_compiler_type && deref_byte_size) {
+    ConstString deref_name;
+    if (!deref_name_str.empty())
+      deref_name.SetCString(deref_name_str.c_str());
+
+    m_deref_valobj =
+        new ValueObjectChild(*this, deref_compiler_type, deref_name,
+                             deref_byte_size, deref_byte_offset, 0, 0, false,
+                             true, eAddressTypeInvalid, language_flags);
+  }
+
+  // In case of incomplete deref compiler type, use the pointee type and try
+  // to recreate a new ValueObjectChild using it.
+  if (!m_deref_valobj) {
+    // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g.
+    // `std::vector<int> &`). Remove ObjC restriction once that's resolved.
+    if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) &&
+        HasSyntheticValue()) {
+      deref_compiler_type = compiler_type.GetPointeeType();
+
+      if (deref_compiler_type) {
+        ConstString deref_name;
+        if (!deref_name_str.empty())
+          deref_name.SetCString(deref_name_str.c_str());
+
+        m_deref_valobj = new ValueObjectChild(
+            *this, deref_compiler_type, deref_name, deref_byte_size,
+            deref_byte_offset, 0, 0, false, true, eAddressTypeInvalid,
+            language_flags);
+      }
     }
   }
 
+  if (!m_deref_valobj && IsSynthetic())
+    m_deref_valobj = GetChildMemberWithName("$$dereference$$").get();
+
   if (m_deref_valobj) {
     error.Clear();
     return m_deref_valobj->GetSP();

@kuilpd
Copy link
Contributor Author

kuilpd commented May 12, 2025

@felipepiovezan
I don't have a machine to run ObjC tests on, could you apply this patch and see if it fixes the issue in #135843 ?

@medismailben
Copy link
Member

@felipepiovezan I don't have a machine to run ObjC tests on, could you apply this patch and see if it fixes the issue in #135843 ?

I'll try that for you.

@medismailben
Copy link
Member

medismailben commented May 12, 2025

@felipepiovezan I don't have a machine to run ObjC tests on, could you apply this patch and see if it fixes the issue in #135843 ?

@kuilpd The test passes after applying this patch. Feel free to land this whenever :)

@medismailben medismailben self-requested a review May 12, 2025 17:56
@kuilpd kuilpd marked this pull request as ready for review May 12, 2025 17:58
@kuilpd kuilpd requested a review from JDevlieghere as a code owner May 12, 2025 17:58
@kuilpd
Copy link
Contributor Author

kuilpd commented May 12, 2025

Thank you!

@kuilpd kuilpd merged commit c8a0513 into llvm:main May 12, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants