From 8ed46b99353f5b427d73aaddb7b0c2e2a0a8f26c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 2 Nov 2012 23:40:00 +0000 Subject: [PATCH] Emit debug info for C++ struct definitions as DW_TAG_structure_type (instead of class_type). llvm-svn: 167336 --- clang/lib/CodeGen/CGDebugInfo.cpp | 6 ++---- clang/test/CodeGenCXX/debug-info-class.cpp | 2 +- clang/test/CodeGenCXX/debug-info-fwd-ref.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e873806..7dfaaa47 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1875,7 +1875,7 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { // Get overall information about the record type for the debug info. llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation()); unsigned Line = getLineNumber(RD->getLocation()); - StringRef RDName = RD->getName(); + StringRef RDName = getClassName(RD); llvm::DIDescriptor RDContext; if (CGM.getCodeGenOpts().getDebugInfo() == CodeGenOptions::LimitedDebugInfo) @@ -1896,9 +1896,7 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { if (RD->isUnion()) RealDecl = DBuilder.createUnionType(RDContext, RDName, DefUnit, Line, Size, Align, 0, llvm::DIArray()); - else if (CXXDecl) { - RDName = getClassName(RD); - + else if (RD->isClass()) { // FIXME: This could be a struct type giving a default visibility different // than C++ class type, but needs llvm metadata changes first. RealDecl = DBuilder.createClassType(RDContext, RDName, DefUnit, Line, diff --git a/clang/test/CodeGenCXX/debug-info-class.cpp b/clang/test/CodeGenCXX/debug-info-class.cpp index dca8535..062227a 100644 --- a/clang/test/CodeGenCXX/debug-info-class.cpp +++ b/clang/test/CodeGenCXX/debug-info-class.cpp @@ -8,7 +8,7 @@ void func(bar *f) { // CHECK: DW_TAG_class_type union baz; void func(baz *f) { // CHECK: DW_TAG_union_type } -struct A { // FIXME: we're still emitting this as DW_TAG_class_type +struct A { // CHECK: DW_TAG_structure_type int one; static const int HdrSize = 52; // CHECK: HdrSize int two; diff --git a/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp b/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp index e7f2ed1..9135032 100644 --- a/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp +++ b/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp @@ -16,11 +16,10 @@ int main(int argc, char** argv) { return 0; } -// Make sure we have two DW_TAG_class_types for baz and bar and no forward +// Make sure we have two DW_TAG_structure_types for baz and bar and no forward // references. -// FIXME: These should be struct types to match the declaration. -// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !21, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ] -// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, null, null} ; [ DW_TAG_structure_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !21, i32 0, null, null} ; [ DW_TAG_structure_type ] +// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_structure_type ] +// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_structure_type ] -- 2.7.4