From 1bee63f3250c33d88a8d6e12aa700b3ceeeef1ca Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 27 Oct 2010 23:23:58 +0000 Subject: [PATCH] Fix context info for enums. Radar 8595129 llvm-svn: 117507 --- clang/lib/CodeGen/CGDebugInfo.cpp | 6 ++++-- clang/test/CodeGenCXX/debug-info-namespace.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 clang/test/CodeGenCXX/debug-info-namespace.cpp diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 241b25f2e5fa..6f905c09ba5d 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -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(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/clang/test/CodeGenCXX/debug-info-namespace.cpp b/clang/test/CodeGenCXX/debug-info-namespace.cpp new file mode 100644 index 000000000000..2e0a96d56660 --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp @@ -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;