9
9
#include " TypeSystemClang.h"
10
10
11
11
#include " clang/AST/DeclBase.h"
12
+ #include " clang/AST/DeclCXX.h"
12
13
#include " clang/AST/ExprCXX.h"
13
14
#include " llvm/ADT/STLForwardCompat.h"
14
15
#include " llvm/Support/Casting.h"
@@ -3650,6 +3651,15 @@ bool TypeSystemClang::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
3650
3651
return false ;
3651
3652
}
3652
3653
3654
+ // / Returns 'true' if \ref decl has been allocated a definition
3655
+ // / *and* the definition was marked as completed. There are currently
3656
+ // / situations in which LLDB marks a definition as `isCompleteDefinition`
3657
+ // / while no definition was allocated. This function guards against those
3658
+ // / situations.
3659
+ static bool HasCompleteDefinition (clang::CXXRecordDecl *decl) {
3660
+ return decl && decl->hasDefinition () && decl->isCompleteDefinition ();
3661
+ }
3662
+
3653
3663
bool TypeSystemClang::IsPossibleDynamicType (lldb::opaque_compiler_type_t type,
3654
3664
CompilerType *dynamic_pointee_type,
3655
3665
bool check_cplusplus,
@@ -3732,8 +3742,9 @@ bool TypeSystemClang::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
3732
3742
if (check_cplusplus) {
3733
3743
clang::CXXRecordDecl *cxx_record_decl =
3734
3744
pointee_qual_type->getAsCXXRecordDecl ();
3745
+
3735
3746
if (cxx_record_decl) {
3736
- bool is_complete = cxx_record_decl-> isCompleteDefinition ( );
3747
+ bool is_complete = HasCompleteDefinition (cxx_record_decl );
3737
3748
3738
3749
if (is_complete)
3739
3750
success = cxx_record_decl->isDynamicClass ();
@@ -3742,7 +3753,9 @@ bool TypeSystemClang::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
3742
3753
if (metadata)
3743
3754
success = metadata->GetIsDynamicCXXType ();
3744
3755
else {
3745
- is_complete = GetType (pointee_qual_type).GetCompleteType ();
3756
+ // Make sure completion has actually completed the type.
3757
+ is_complete = GetType (pointee_qual_type).GetCompleteType () &&
3758
+ HasCompleteDefinition (cxx_record_decl);
3746
3759
if (is_complete)
3747
3760
success = cxx_record_decl->isDynamicClass ();
3748
3761
else
@@ -5478,8 +5491,12 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
5478
5491
llvm::cast<clang::RecordType>(qual_type.getTypePtr ());
5479
5492
const clang::RecordDecl *record_decl = record_type->getDecl ();
5480
5493
assert (record_decl);
5494
+
5495
+ // CXXBaseSpecifiers are stored on the definition. If we don't have
5496
+ // one at this point that means we "completed" the type without actually
5497
+ // having allocated a definition.
5481
5498
const clang::CXXRecordDecl *cxx_record_decl =
5482
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5499
+ llvm::dyn_cast<clang::CXXRecordDecl>(record_decl)-> getDefinition () ;
5483
5500
if (cxx_record_decl) {
5484
5501
if (omit_empty_base_classes) {
5485
5502
// Check each base classes to see if it or any of its base classes
0 commit comments