9
9
#include " TypeSystemClang.h"
10
10
11
11
#include " clang/AST/DeclBase.h"
12
- #include " llvm/ADT/STLForwardCompat.h"
12
+ #include " clang/AST/DeclCXX.h"
13
+ #include " clang/AST/ExprCXX.h"
13
14
#include " llvm/Support/Casting.h"
14
15
#include " llvm/Support/FormatAdapters.h"
15
16
#include " llvm/Support/FormatVariadic.h"
@@ -3640,6 +3641,15 @@ bool TypeSystemClang::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
3640
3641
return false ;
3641
3642
}
3642
3643
3644
+ // / Returns 'true' if \ref decl has been allocated a definition
3645
+ // / *and* the definition was marked as completed. There are currently
3646
+ // / situations in which LLDB marks a definition as `isCompleteDefinition`
3647
+ // / while no definition was allocated. This function guards against those
3648
+ // / situations.
3649
+ static bool HasCompleteDefinition (clang::CXXRecordDecl *decl) {
3650
+ return decl && decl->hasDefinition () && decl->isCompleteDefinition ();
3651
+ }
3652
+
3643
3653
bool TypeSystemClang::IsPossibleDynamicType (lldb::opaque_compiler_type_t type,
3644
3654
CompilerType *dynamic_pointee_type,
3645
3655
bool check_cplusplus,
@@ -3722,8 +3732,9 @@ bool TypeSystemClang::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
3722
3732
if (check_cplusplus) {
3723
3733
clang::CXXRecordDecl *cxx_record_decl =
3724
3734
pointee_qual_type->getAsCXXRecordDecl ();
3735
+
3725
3736
if (cxx_record_decl) {
3726
- bool is_complete = cxx_record_decl-> isCompleteDefinition ( );
3737
+ bool is_complete = HasCompleteDefinition (cxx_record_decl );
3727
3738
3728
3739
if (is_complete)
3729
3740
success = cxx_record_decl->isDynamicClass ();
@@ -3732,7 +3743,9 @@ bool TypeSystemClang::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
3732
3743
if (metadata)
3733
3744
success = metadata->GetIsDynamicCXXType ();
3734
3745
else {
3735
- is_complete = GetType (pointee_qual_type).GetCompleteType ();
3746
+ // Make sure completion has actually completed the type.
3747
+ is_complete = GetType (pointee_qual_type).GetCompleteType () &&
3748
+ HasCompleteDefinition (cxx_record_decl);
3736
3749
if (is_complete)
3737
3750
success = cxx_record_decl->isDynamicClass ();
3738
3751
else
@@ -5428,8 +5441,12 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
5428
5441
llvm::cast<clang::RecordType>(qual_type.getTypePtr ());
5429
5442
const clang::RecordDecl *record_decl = record_type->getDecl ();
5430
5443
assert (record_decl);
5444
+
5445
+ // CXXBaseSpecifiers are stored on the definition. If we don't have
5446
+ // one at this point that means we "completed" the type without actually
5447
+ // having allocated a definition.
5431
5448
const clang::CXXRecordDecl *cxx_record_decl =
5432
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5449
+ llvm::dyn_cast<clang::CXXRecordDecl>(record_decl)-> getDefinition () ;
5433
5450
if (cxx_record_decl) {
5434
5451
if (omit_empty_base_classes) {
5435
5452
// Check each base classes to see if it or any of its base classes
0 commit comments