From 9ee5f4641ee0d018cb6a2ce16611bfa170a5ecea Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 23 May 2012 00:09:47 +0000 Subject: [PATCH] Emit C++11 enum class information if it exists. Part of rdar://11496790 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157304 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 5 ++++- test/CodeGenCXX/debug-info-enum-class.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/CodeGenCXX/debug-info-enum-class.cpp diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 1df32d85cc..3899604d75 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1586,9 +1586,12 @@ llvm::DIType CGDebugInfo::CreateEnumType(const EnumDecl *ED) { } llvm::DIDescriptor EnumContext = getContextDescriptor(cast(ED->getDeclContext())); + llvm::DIType ClassTy = ED->isScopedUsingClassTag() ? + getOrCreateType(ED->getIntegerType(), DefUnit) : llvm::DIType(); llvm::DIType DbgTy = DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, Line, - Size, Align, EltArray); + Size, Align, EltArray, + ClassTy); return DbgTy; } diff --git a/test/CodeGenCXX/debug-info-enum-class.cpp b/test/CodeGenCXX/debug-info-enum-class.cpp new file mode 100644 index 0000000000..e2d461943c --- /dev/null +++ b/test/CodeGenCXX/debug-info-enum-class.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +enum class A { A1=1 }; // underlying type is int by default +enum class B: unsigned long { B1=1 }; // underlying type is unsigned long +enum C { C1 = 1 }; +A a; +B b; +C c; + +// CHECK: metadata !{i32 {{.*}}, null, metadata !"A", metadata !4, i32 3, i64 32, i64 32, i32 0, i32 0, metadata !5, metadata !6, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"B", metadata !4, i32 4, i64 64, i64 64, i32 0, i32 0, metadata !9, metadata !10, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"C", metadata !4, i32 5, i64 32, i64 32, i32 0, i32 0, null, metadata !13, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] -- 2.40.0