amccarth created this revision. amccarth added a reviewer: rnk. amccarth added a subscriber: cfe-commits.
This includes nested types in the member list, even if there are no members of that type. Note that structs and classes have themselves as an "implicit struct" as the first member, so we skip implicit ones. Most of the work (for me) was figuring out the tests that broke as a result of the ordering changes. In particular, please scrutinize the Objective C one, which doesn't actually nest a struct but has a member function with a pointer to an incomplete struct type. http://reviews.llvm.org/D21705 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h test/CodeGenCXX/debug-info-dup-fwd-decl.cpp test/CodeGenCXX/debug-info-indirect-field-decl.cpp test/CodeGenCXX/debug-info-ms-abi.cpp test/CodeGenObjCXX/debug-info-cyclic.mm
Index: test/CodeGenObjCXX/debug-info-cyclic.mm =================================================================== --- test/CodeGenObjCXX/debug-info-cyclic.mm +++ test/CodeGenObjCXX/debug-info-cyclic.mm @@ -8,7 +8,7 @@ // CHECK-NOT: DIFlagFwdDecl // CHECK-SAME: elements: ![[BMEMBERS:[0-9]+]] // CHECK-SAME: identifier: -// CHECK: ![[BMEMBERS]] = !{![[BB:[0-9]+]]} +// CHECK: ![[BMEMBERS]] = !{![[A:[0-9]+]], ![[BB:[0-9]+]]} B(struct A *); // CHECK: ![[BB]] = !DISubprogram(name: "B", scope: ![[B]] // CHECK-SAME: line: [[@LINE-2]], Index: test/CodeGenCXX/debug-info-ms-abi.cpp =================================================================== --- test/CodeGenCXX/debug-info-ms-abi.cpp +++ test/CodeGenCXX/debug-info-ms-abi.cpp @@ -14,6 +14,9 @@ // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", // CHECK-SAME: identifier: ".?AUFoo@@" +// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", +// CHECK-SAME: identifier: ".?AUNested@Foo@@" + // CHECK: !DISubprogram(name: "f", // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, @@ -25,6 +28,3 @@ // CHECK: !DISubprogram(name: "h", // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual, - -// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", -// CHECK-SAME: identifier: ".?AUNested@Foo@@" Index: test/CodeGenCXX/debug-info-indirect-field-decl.cpp =================================================================== --- test/CodeGenCXX/debug-info-indirect-field-decl.cpp +++ test/CodeGenCXX/debug-info-indirect-field-decl.cpp @@ -8,18 +8,18 @@ struct Bar { int i1; // CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int" - // CHECK: !DIDerivedType(tag: DW_TAG_member, scope: - // CHECK-SAME: line: [[@LINE+4]] - // CHECK-SAME: baseType: ![[UNION:[0-9]+]] - // CHECK-SAME: size: 32, align: 32, offset: 32 - // CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E") + // CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E") union { // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i2", - // CHECK-SAME: line: [[@LINE+5]] + // CHECK-SAME: line: [[@LINE+9]] // CHECK-SAME: baseType: ![[INT]] // CHECK-SAME: size: 32, align: 32 // CHECK-NOT: offset: // CHECK-SAME: ){{$}} + // CHECK: !DIDerivedType(tag: DW_TAG_member, scope: + // CHECK-SAME: line: [[@LINE-8]] + // CHECK-SAME: baseType: ![[UNION]] + // CHECK-SAME: size: 32, align: 32, offset: 32 int i2; }; }; Index: test/CodeGenCXX/debug-info-dup-fwd-decl.cpp =================================================================== --- test/CodeGenCXX/debug-info-dup-fwd-decl.cpp +++ test/CodeGenCXX/debug-info-dup-fwd-decl.cpp @@ -19,6 +19,6 @@ Test t; -// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data" +// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data" Index: lib/CodeGen/CGDebugInfo.h =================================================================== --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -249,6 +249,8 @@ llvm::DIFile *F, SmallVectorImpl<llvm::Metadata *> &E, llvm::DIType *RecordTy, const RecordDecl *RD); + void CollectRecordNestedRecord(const RecordDecl *RD, + SmallVectorImpl<llvm::Metadata *> &E); void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F, SmallVectorImpl<llvm::Metadata *> &E, llvm::DICompositeType *RecordTy); Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -1028,6 +1028,13 @@ elements.push_back(fieldType); } +void CGDebugInfo::CollectRecordNestedRecord( + const RecordDecl *RD, SmallVectorImpl<llvm::Metadata *> &elements) { + QualType Ty = CGM.getContext().getTypeDeclType(RD); + llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile()); + elements.push_back(nestedType); +} + void CGDebugInfo::CollectRecordFields( const RecordDecl *record, llvm::DIFile *tunit, SmallVectorImpl<llvm::Metadata *> &elements, @@ -1064,6 +1071,9 @@ // Bump field number for next field. ++fieldNo; + } else if (const auto *nestedRec = dyn_cast<CXXRecordDecl>(I)) { + if (!nestedRec->isImplicit()) + CollectRecordNestedRecord(nestedRec, elements); } } } @@ -3562,8 +3572,8 @@ if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo) return; const NamespaceDecl *NSDecl = UD.getNominatedNamespace(); - if (!NSDecl->isAnonymousNamespace() || - CGM.getCodeGenOpts().DebugExplicitImport) { + if (!NSDecl->isAnonymousNamespace() || + CGM.getCodeGenOpts().DebugExplicitImport) { DBuilder.createImportedModule( getCurrentContextDescriptor(cast<Decl>(UD.getDeclContext())), getOrCreateNameSpace(NSDecl),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits