]> granicus.if.org Git - clang/commitdiff
Fix debug tag type of forward declarations of struct/class in C++.
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 2 Nov 2012 20:49:01 +0000 (20:49 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 2 Nov 2012 20:49:01 +0000 (20:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167308 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/debug-info.c
test/CodeGenCXX/debug-info-class.cpp

index 57c4e9e41752efba2c0d1f7cd77b291fade6c8bd..e873806b914464ad3ec92d49968961dc1c18a5aa 100644 (file)
@@ -518,21 +518,17 @@ llvm::DIType CGDebugInfo::createRecordFwdDecl(const RecordDecl *RD,
                                               llvm::DIDescriptor Ctx) {
   llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation());
   unsigned Line = getLineNumber(RD->getLocation());
-  StringRef RDName = RD->getName();
+  StringRef RDName = getClassName(RD);
 
-  // Get the tag.
-  const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
   unsigned Tag = 0;
-  if (CXXDecl) {
-    RDName = getClassName(RD);
-    Tag = llvm::dwarf::DW_TAG_class_type;
-  }
-  else if (RD->isStruct() || RD->isInterface())
+  if (RD->isStruct() || RD->isInterface())
     Tag = llvm::dwarf::DW_TAG_structure_type;
   else if (RD->isUnion())
     Tag = llvm::dwarf::DW_TAG_union_type;
-  else
-    llvm_unreachable("Unknown RecordDecl type!");
+  else {
+    assert(RD->isClass());
+    Tag = llvm::dwarf::DW_TAG_class_type;
+  }
 
   // Create the type.
   return DBuilder.createForwardDecl(Tag, RDName, Ctx, DefUnit, Line);
index af2ce969bcebbabc5bb2aef829b9cd330676f18b..12ba6058d39ede43f714645ec9d84c158ce88009 100644 (file)
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unk-unk -o %t -emit-llvm -g %s
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -g %s | FileCheck %s
 
 // PR3023
 void convert(void) {
@@ -8,7 +7,7 @@ void convert(void) {
 
 
 // PR2784
-struct OPAQUE;
+struct OPAQUE; // CHECK: DW_TAG_structure_type
 typedef struct OPAQUE *PTR;
 PTR p;
 
index 151c5f90534c505d0107da64986d37699c7d636f..dca8535fb2b430a23c4065325ae8db54ccbdf144 100644 (file)
@@ -1,12 +1,24 @@
-// RUN: %clang  -emit-llvm -g -S %s -o - | grep HdrSize
-struct A {
+// RUN: %clang  -emit-llvm -g -S %s -o - | FileCheck %s
+struct foo;
+void func(foo *f) { // CHECK: DW_TAG_structure_type
+}
+class bar;
+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
   int one;
-  static const int HdrSize = 52;
+  static const int HdrSize = 52; // CHECK: HdrSize
   int two;
   A() {
     int x = 1;
   }
 };
+class B { // CHECK: DW_TAG_class_type
+};
 int main() {
   A a;
+  B b;
 }