@@ -644,24 +644,8 @@ llvm::DIDescriptor CGDebugInfo::createContextChain(const Decl *Context) {
644
644
645
645
if (const RecordDecl *RD = dyn_cast<RecordDecl>(Context)) {
646
646
if (!RD->isDependentType ()) {
647
- llvm::DICompositeType T (getTypeOrNull (CGM.getContext ().getRecordType (RD)));
648
- llvm::DICompositeType Ty (getOrCreateLimitedType (
649
- CGM.getContext ().getRecordType (RD)->castAs <RecordType>(),
650
- getOrCreateMainFile ()));
651
- if (!Ty.getTypeArray ().getNumElements ()) {
652
- if (T) {
653
- llvm::DIArray PrevMem = T.getTypeArray ();
654
- unsigned NumElements = PrevMem.getNumElements ();
655
- if (NumElements == 1 && !PrevMem.getElement (0 ))
656
- NumElements = 0 ;
657
- SmallVector<llvm::Value *, 16 > EltTys;
658
- EltTys.reserve (NumElements);
659
- for (unsigned i = 0 ; i != NumElements; ++i)
660
- EltTys.push_back (PrevMem.getElement (i));
661
- llvm::DIArray Elements = DBuilder.getOrCreateArray (EltTys);
662
- Ty.setTypeArray (Elements);
663
- }
664
- }
647
+ llvm::DIType Ty = getOrCreateLimitedType (
648
+ CGM.getContext ().getRecordType (RD)->castAs <RecordType>(), getOrCreateMainFile ());
665
649
return llvm::DIDescriptor (Ty);
666
650
}
667
651
}
@@ -881,7 +865,7 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
881
865
}
882
866
}
883
867
884
- // / Helper for CollectRecordFields.
868
+ // / CollectRecordStaticField - Helper for CollectRecordFields.
885
869
llvm::DIDerivedType
886
870
CGDebugInfo::CreateRecordStaticField (const VarDecl *Var,
887
871
llvm::DIType RecordTy) {
@@ -964,7 +948,7 @@ void CGDebugInfo::CollectRecordFields(const RecordDecl *record,
964
948
for (RecordDecl::decl_iterator I = record->decls_begin (),
965
949
E = record->decls_end (); I != E; ++I)
966
950
if (const VarDecl *V = dyn_cast<VarDecl>(*I))
967
- elements.push_back (getOrCreateStaticDataMemberDeclaration (V, RecordTy));
951
+ elements.push_back (CreateRecordStaticField (V, RecordTy));
968
952
else if (FieldDecl *field = dyn_cast<FieldDecl>(*I)) {
969
953
CollectRecordNormalField (field, layout.getFieldOffset (fieldNo),
970
954
tunit, elements, RecordTy);
@@ -1139,14 +1123,8 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit,
1139
1123
if (D->isImplicit ())
1140
1124
continue ;
1141
1125
1142
- if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
1143
- llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator MI =
1144
- SPCache.find (Method->getCanonicalDecl ());
1145
- if (MI == SPCache.end ())
1146
- EltTys.push_back (CreateCXXMemberFunction (Method, Unit, RecordTy));
1147
- else
1148
- EltTys.push_back (MI->second );
1149
- }
1126
+ if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1127
+ EltTys.push_back (CreateCXXMemberFunction (Method, Unit, RecordTy));
1150
1128
}
1151
1129
}
1152
1130
@@ -1430,18 +1408,10 @@ void CGDebugInfo::completeType(const RecordDecl *RD) {
1430
1408
}
1431
1409
1432
1410
void CGDebugInfo::completeRequiredType (const RecordDecl *RD) {
1433
- if (const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD))
1434
- if (CXXDecl->isDynamicClass ())
1435
- return ;
1436
-
1437
1411
QualType Ty = CGM.getContext ().getRecordType (RD);
1438
1412
llvm::DIType T = getTypeOrNull (Ty);
1439
- if (T && T.isForwardDecl ())
1440
- completeClassData (RD);
1441
- }
1442
-
1443
- void CGDebugInfo::completeClassData (const RecordDecl *RD) {
1444
- QualType Ty = CGM.getContext ().getRecordType (RD);
1413
+ if (!T || !T.isForwardDecl ())
1414
+ return ;
1445
1415
void * TyPtr = Ty.getAsOpaquePtr ();
1446
1416
if (CompletedTypeCache.count (TyPtr))
1447
1417
return ;
@@ -1454,23 +1424,14 @@ void CGDebugInfo::completeClassData(const RecordDecl *RD) {
1454
1424
// / CreateType - get structure or union type.
1455
1425
llvm::DIType CGDebugInfo::CreateType (const RecordType *Ty, bool Declaration) {
1456
1426
RecordDecl *RD = Ty->getDecl ();
1457
- const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
1458
1427
// Limited debug info should only remove struct definitions that can
1459
1428
// safely be replaced by a forward declaration in the source code.
1460
- if ((DebugKind <= CodeGenOptions::LimitedDebugInfo && Declaration &&
1461
- !RD->isCompleteDefinitionRequired () && CGM.getLangOpts ().CPlusPlus ) ||
1462
- (CXXDecl && CXXDecl->hasDefinition () && CXXDecl->isDynamicClass ())) {
1429
+ if (DebugKind <= CodeGenOptions::LimitedDebugInfo && Declaration &&
1430
+ !RD->isCompleteDefinitionRequired () && CGM.getLangOpts ().CPlusPlus ) {
1463
1431
llvm::DIDescriptor FDContext =
1464
1432
getContextDescriptor (cast<Decl>(RD->getDeclContext ()));
1465
1433
llvm::DIType RetTy = getOrCreateRecordFwdDecl (RD, FDContext);
1466
- // FIXME: This is conservatively correct. If we return a non-forward decl
1467
- // that's not a full definition (such as those created by
1468
- // createContextChain) then getOrCreateType will record is as a complete
1469
- // type and we'll never record all its members. But this means we're
1470
- // emitting full debug info in TUs where GCC successfully emits a partial
1471
- // definition of the type.
1472
- if (RetTy.isForwardDecl ())
1473
- return RetTy;
1434
+ return RetTy;
1474
1435
}
1475
1436
1476
1437
return CreateTypeDefinition (Ty);
@@ -1508,7 +1469,6 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
1508
1469
1509
1470
// Convert all the elements.
1510
1471
SmallVector<llvm::Value *, 16 > EltTys;
1511
- // what about nested types?
1512
1472
1513
1473
// Note: The split of CXXDecl information here is intentional, the
1514
1474
// gdb tests will depend on a certain ordering at printout. The debug
@@ -2350,7 +2310,7 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) {
2350
2310
llvm::DenseMap<const FunctionDecl *, llvm::WeakVH>::iterator
2351
2311
MI = SPCache.find (FD->getCanonicalDecl ());
2352
2312
if (MI == SPCache.end ()) {
2353
- if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD-> getCanonicalDecl () )) {
2313
+ if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
2354
2314
llvm::DICompositeType T (S);
2355
2315
llvm::DISubprogram SP = CreateCXXMemberFunction (MD, getOrCreateFile (MD->getLocation ()), T);
2356
2316
T.addMember (SP);
@@ -3065,35 +3025,19 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
3065
3025
DbgDecl->setDebugLoc (llvm::DebugLoc::get (line, column, scope));
3066
3026
}
3067
3027
3068
- // / If D is an out-of-class definition of a static data member of a class, find
3069
- // / its corresponding in-class declaration.
3070
- llvm::DIDerivedType
3071
- CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull (const VarDecl *D) {
3072
- if (!D->isStaticDataMember ())
3073
- return llvm::DIDerivedType ();
3074
- llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
3075
- StaticDataMemberCache.find (D->getCanonicalDecl ());
3076
- if (MI != StaticDataMemberCache.end ()) {
3077
- assert (MI->second && " Static data member declaration should still exist" );
3078
- return llvm::DIDerivedType (cast<llvm::MDNode>(MI->second ));
3079
- }
3080
- llvm::DICompositeType Ctxt (
3081
- getContextDescriptor (cast<Decl>(D->getDeclContext ())));
3082
- llvm::DIDerivedType T = CreateRecordStaticField (D, Ctxt);
3083
- Ctxt.addMember (T);
3084
- return T;
3085
- }
3086
-
3087
- llvm::DIDerivedType
3088
- CGDebugInfo::getOrCreateStaticDataMemberDeclaration (const VarDecl *D,
3089
- llvm::DICompositeType Ctxt) {
3090
- llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI =
3091
- StaticDataMemberCache.find (D->getCanonicalDecl ());
3092
- if (MI != StaticDataMemberCache.end ()) {
3093
- assert (MI->second && " Static data member declaration should still exist" );
3094
- return llvm::DIDerivedType (cast<llvm::MDNode>(MI->second ));
3028
+ // / getStaticDataMemberDeclaration - If D is an out-of-class definition of
3029
+ // / a static data member of a class, find its corresponding in-class
3030
+ // / declaration.
3031
+ llvm::DIDerivedType CGDebugInfo::getStaticDataMemberDeclaration (const VarDecl *D) {
3032
+ if (D->isStaticDataMember ()) {
3033
+ llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator
3034
+ MI = StaticDataMemberCache.find (D->getCanonicalDecl ());
3035
+ if (MI != StaticDataMemberCache.end ())
3036
+ // Verify the info still exists.
3037
+ if (llvm::Value *V = MI->second )
3038
+ return llvm::DIDerivedType (cast<llvm::MDNode>(V));
3095
3039
}
3096
- return CreateRecordStaticField (D, Ctxt );
3040
+ return llvm::DIDerivedType ( );
3097
3041
}
3098
3042
3099
3043
// / EmitGlobalVariable - Emit information about a global variable.
@@ -3125,10 +3069,11 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
3125
3069
LinkageName = StringRef ();
3126
3070
llvm::DIDescriptor DContext =
3127
3071
getContextDescriptor (dyn_cast<Decl>(D->getDeclContext ()));
3128
- llvm::DIGlobalVariable GV = DBuilder.createStaticVariable (
3129
- DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType (T, Unit),
3130
- Var->hasInternalLinkage (), Var,
3131
- getOrCreateStaticDataMemberDeclarationOrNull (D));
3072
+ llvm::DIGlobalVariable GV =
3073
+ DBuilder.createStaticVariable (DContext, DeclName, LinkageName, Unit,
3074
+ LineNo, getOrCreateType (T, Unit),
3075
+ Var->hasInternalLinkage (), Var,
3076
+ getStaticDataMemberDeclaration (D));
3132
3077
DeclCache.insert (std::make_pair (D->getCanonicalDecl (), llvm::WeakVH (GV)));
3133
3078
}
3134
3079
@@ -3176,7 +3121,7 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
3176
3121
return ;
3177
3122
llvm::DIGlobalVariable GV = DBuilder.createStaticVariable (
3178
3123
Unit, Name, Name, Unit, getLineNumber (VD->getLocation ()), Ty, true , Init,
3179
- getOrCreateStaticDataMemberDeclarationOrNull (cast<VarDecl>(VD)));
3124
+ getStaticDataMemberDeclaration (cast<VarDecl>(VD)));
3180
3125
DeclCache.insert (std::make_pair (VD->getCanonicalDecl (), llvm::WeakVH (GV)));
3181
3126
}
3182
3127
0 commit comments