]> granicus.if.org Git - clang/commitdiff
Fix context info for enums.
authorDevang Patel <dpatel@apple.com>
Wed, 27 Oct 2010 23:23:58 +0000 (23:23 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 27 Oct 2010 23:23:58 +0000 (23:23 +0000)
Radar 8595129

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117507 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-namespace.cpp [new file with mode: 0644]

index 241b25f2e5fa4bcb1cf09be88076a320e11929c0..6f905c09ba5d5a2a4b26cd1e815cd342152ce08c 100644 (file)
@@ -1376,10 +1376,12 @@ llvm::DIType CGDebugInfo::CreateEnumType(const EnumDecl *ED, llvm::DIFile Unit){
     Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
     Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl());
   }
+  llvm::DIDescriptor EnumContext = 
+    getContextDescriptor(dyn_cast<Decl>(ED->getDeclContext()), Unit);
   llvm::DIType DbgTy = 
     DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
-                                     Unit, ED->getName(), DefUnit, Line,
-                                     Size, Align, 0, 0,
+                                     EnumContext, ED->getName(),
+                                     DefUnit, Line, Size, Align, 0, 0,
                                      llvm::DIType(), EltArray);
   return DbgTy;
 }
diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp
new file mode 100644 (file)
index 0000000..2e0a96d
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang  -g -S %s -o - | FileCheck %s
+
+// CHECK: TAG_namespace
+namespace A {
+  enum numbers {
+    ZERO,
+    ONE
+  };
+}
+
+using namespace A;
+numbers n;