Skip to content

Commit d1048cb

Browse files
Merge pull request #8890 from Michael137/lldb/crash/get-complete-objc-type-to-6.0
[lldb][Type Completion] Fix completion of ObjCObjectTypes
2 parents 845ede3 + a92275f commit d1048cb

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,13 +2794,9 @@ static clang::Type const *GetCompleteEnumType(clang::ASTContext *ast,
27942794
}
27952795

27962796
static clang::Type const *
2797-
GetCompleteObjCInterfaceType(clang::ASTContext *ast, clang::QualType qual_type,
2797+
GetCompleteObjCInterfaceType(clang::ASTContext *ast,
2798+
clang::ObjCObjectType const *objc_class_type,
27982799
bool allow_completion = true) {
2799-
const clang::ObjCObjectType *objc_class_type =
2800-
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
2801-
if (!objc_class_type)
2802-
return nullptr;
2803-
28042800
clang::ObjCInterfaceDecl *class_interface_decl =
28052801
objc_class_type->getInterface();
28062802
// We currently can't complete objective C types through the newly added
@@ -2861,8 +2857,13 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
28612857
} break;
28622858
case clang::Type::ObjCObject:
28632859
case clang::Type::ObjCInterface: {
2864-
if (auto const *ty = llvm::dyn_cast_or_null<ObjCInterfaceType>(
2865-
GetCompleteObjCInterfaceType(ast, qual_type, allow_completion)))
2860+
const clang::ObjCObjectType *objc_class_type =
2861+
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
2862+
if (!objc_class_type)
2863+
return true;
2864+
2865+
if (auto const *ty = GetCompleteObjCInterfaceType(ast, objc_class_type,
2866+
allow_completion))
28662867
return TypeSystemClang::UseRedeclCompletion() || !ty->isIncompleteType();
28672868

28682869
return false;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main() { return 0; }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// UNSUPPORTED: system-linux, system-windows
2+
//
3+
// RUN: %clangxx_host %p/Inputs/objc-cast.cpp -g -o %t
4+
// RUN: %lldb %t \
5+
// RUN: -o "b main" -o run -o "expression --language objc -- *(id)0x1" \
6+
// RUN: 2>&1 | FileCheck %s
7+
8+
// CHECK: (lldb) expression --language objc -- *(id)0x1
9+
// CHECK: error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory

0 commit comments

Comments
 (0)