Skip to content

Commit d82790b

Browse files
committed
[lldb][Type Completion] Fix completion of ObjCObjectTypes
The problem was introduced in: ``` commit e68f76a9e59104e2bfb972155af8ff04310cd078 Author: Michael Buch <[email protected]> Date: Fri Feb 16 14:35:34 2024 +0000 [lldb][TypeSystemClang][NFCI] Factor completion logic out of GetCompleteQualType ``` This introduced an incorrect `llvm::dyn_cast_or_null` check causing us to incorrectly claim that we failed to complete a type. This manifested in a crash when running following expression: ``` expr -l objc -- *(id)0x1234 ``` rdar://129633122
1 parent 176f71b commit d82790b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

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

27542754
static clang::Type const *
2755-
GetCompleteObjCInterfaceType(clang::ASTContext *ast, clang::QualType qual_type,
2755+
GetCompleteObjCInterfaceType(clang::ASTContext *ast,
2756+
clang::ObjCObjectType const *objc_class_type,
27562757
bool allow_completion = true) {
2757-
const clang::ObjCObjectType *objc_class_type =
2758-
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
2759-
if (!objc_class_type)
2760-
return nullptr;
2761-
27622758
clang::ObjCInterfaceDecl *class_interface_decl =
27632759
objc_class_type->getInterface();
27642760
// We currently can't complete objective C types through the newly added
@@ -2819,8 +2815,13 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
28192815
} break;
28202816
case clang::Type::ObjCObject:
28212817
case clang::Type::ObjCInterface: {
2822-
if (auto const *ty = llvm::dyn_cast_or_null<ObjCInterfaceType>(
2823-
GetCompleteObjCInterfaceType(ast, qual_type, allow_completion)))
2818+
const clang::ObjCObjectType *objc_class_type =
2819+
llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
2820+
if (!objc_class_type)
2821+
return true;
2822+
2823+
if (auto const *ty = GetCompleteObjCInterfaceType(ast, objc_class_type,
2824+
allow_completion))
28242825
return TypeSystemClang::UseRedeclCompletion() || !ty->isIncompleteType();
28252826

28262827
return false;

0 commit comments

Comments
 (0)