Skip to content

[lldb][Type Completion] Fix completion of ObjCObjectTypes #8890

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2794,13 +2794,9 @@ static clang::Type const *GetCompleteEnumType(clang::ASTContext *ast,
}

static clang::Type const *
GetCompleteObjCInterfaceType(clang::ASTContext *ast, clang::QualType qual_type,
GetCompleteObjCInterfaceType(clang::ASTContext *ast,
clang::ObjCObjectType const *objc_class_type,
bool allow_completion = true) {
const clang::ObjCObjectType *objc_class_type =
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
if (!objc_class_type)
return nullptr;

clang::ObjCInterfaceDecl *class_interface_decl =
objc_class_type->getInterface();
// We currently can't complete objective C types through the newly added
Expand Down Expand Up @@ -2861,8 +2857,13 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
} break;
case clang::Type::ObjCObject:
case clang::Type::ObjCInterface: {
if (auto const *ty = llvm::dyn_cast_or_null<ObjCInterfaceType>(
GetCompleteObjCInterfaceType(ast, qual_type, allow_completion)))
const clang::ObjCObjectType *objc_class_type =
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
if (!objc_class_type)
return true;

if (auto const *ty = GetCompleteObjCInterfaceType(ast, objc_class_type,
allow_completion))
return TypeSystemClang::UseRedeclCompletion() || !ty->isIncompleteType();

return false;
Expand Down
1 change: 1 addition & 0 deletions lldb/test/Shell/Expr/Inputs/objc-cast.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }
9 changes: 9 additions & 0 deletions lldb/test/Shell/Expr/TestObjCIDCast.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// UNSUPPORTED: system-linux, system-windows
//
// RUN: %clangxx_host %p/Inputs/objc-cast.cpp -g -o %t
// RUN: %lldb %t \
// RUN: -o "b main" -o run -o "expression --language objc -- *(id)0x1" \
// RUN: 2>&1 | FileCheck %s

// CHECK: (lldb) expression --language objc -- *(id)0x1
// CHECK: error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory