r179879 - Emit the underlying type in the debug info for all kinds of fixed enums
Adrian Prantl
aprantl at apple.com
Fri Apr 19 12:56:39 PDT 2013
Author: adrian
Date: Fri Apr 19 14:56:39 2013
New Revision: 179879
URL: http://llvm.org/viewvc/llvm-project?rev=179879&view=rev
Log:
Emit the underlying type in the debug info for all kinds of fixed enums
instead of only C++11-scoped-with-class-tag enums.
rdar://problem/13463793
Added:
cfe/trunk/test/CodeGenObjC/objc-fixed-enum.m
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/scoped-enums.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=179879&r1=179878&r2=179879&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Apr 19 14:56:39 2013
@@ -2397,7 +2397,7 @@ protected:
bool IsScopedUsingClassTag : 1;
/// IsFixed - True if this is an enumeration with fixed underlying type. Only
- /// possible in C++11 or Microsoft extensions mode.
+ /// possible in C++11, Microsoft extensions, or Objective C mode.
bool IsFixed : 1;
/// \brief Indicates whether it is possible for declarations of this kind
@@ -2793,8 +2793,8 @@ public:
return IsScopedUsingClassTag;
}
- /// \brief Returns true if this is a C++11 enumeration with fixed underlying
- /// type.
+ /// \brief Returns true if this is an Objective-C, C++11, or
+ /// Microsoft-style enumeration with a fixed underlying type.
bool isFixed() const {
return IsFixed;
}
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=179879&r1=179878&r2=179879&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 19 14:56:39 2013
@@ -1696,7 +1696,7 @@ llvm::DIType CGDebugInfo::CreateEnumType
unsigned Line = getLineNumber(ED->getLocation());
llvm::DIDescriptor EnumContext =
getContextDescriptor(cast<Decl>(ED->getDeclContext()));
- llvm::DIType ClassTy = ED->isScopedUsingClassTag() ?
+ llvm::DIType ClassTy = ED->isFixed() ?
getOrCreateType(ED->getIntegerType(), DefUnit) : llvm::DIType();
llvm::DIType DbgTy =
DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, Line,
Modified: cfe/trunk/test/CodeGenCXX/scoped-enums.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/scoped-enums.cpp?rev=179879&r1=179878&r2=179879&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/scoped-enums.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/scoped-enums.cpp Fri Apr 19 14:56:39 2013
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -g -o - %s
// PR9923
enum class Color { red, blue, green };
@@ -7,3 +7,12 @@ void f(Color);
void g() {
f(Color::red);
}
+
+// See that struct is handled equally.
+// CHECK: [ DW_TAG_enumeration_type ] [Colour]
+enum struct Colour { grey };
+
+void h(Colour);
+void i() {
+ h(Colour::grey);
+}
Added: cfe/trunk/test/CodeGenObjC/objc-fixed-enum.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-fixed-enum.m?rev=179879&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc-fixed-enum.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc-fixed-enum.m Fri Apr 19 14:56:39 2013
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -g -emit-llvm -Werror -o - %s | FileCheck %s
+
+// The DWARF standard says the underlying data type of an enum may be
+// stored in an DW_AT_type() entry in the enum DIE.
+
+typedef long NSInteger;
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+
+// Enum with no specified underlying type
+typedef enum {
+ Enum0One,
+ Enum0Two
+} Enum0;
+
+// Enum declared with the NS_ENUM macro
+typedef NS_ENUM(NSInteger, Enum1) {
+ Enum1One = -1,
+ Enum1Two
+};
+
+// Enum declared with a fixed underlying type
+typedef enum : NSInteger {
+ Enum2One = -1,
+ Enum2Two
+} Enum2;
+
+// Typedef and declaration separately
+enum : NSInteger
+{
+ Enum3One = -1,
+ Enum3Two
+};
+typedef NSInteger Enum3;
+
+int main() {
+ Enum0 e0 = Enum0One;
+ // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM0:[0-9]+]])
+ Enum1 e1 = Enum1One;
+ // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM1:[0-9]+]])
+ Enum2 e2 = Enum2One;
+ // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM2:[0-9]+]])
+ Enum3 e3 = Enum3One;
+ // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM3:[0-9]+]])
+
+ // -Werror and the following line ensures that these enums are not
+ // -treated as C++11 strongly typed enums.
+ return e0 != e1 && e1 == e2 && e2 == e3;
+}
+// CHECK: ![[ENUMERATOR0:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 10
+// CHECK: ![[ENUMERATOR1:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [Enum1] [line 16{{.*}}] [from NSInteger]
+// CHECK: ![[ENUMERATOR3:[0-9]+]] = {{.*}}; [ DW_TAG_typedef ] [NSInteger] [line 6{{.*}}] [from long int]
+// CHECK: ![[ENUMERATOR2:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 22{{.*}}] [from NSInteger]
+
+// CHECK: ![[ENUM0]] = metadata !{{{.*}}!"e0", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE0:[0-9]+]]
+// CHECK: ![[TYPE0]] = metadata !{{{.*}}!"Enum0", {{.*}} metadata ![[ENUMERATOR0]]} ; [ DW_TAG_typedef ] [Enum0]
+
+// CHECK: ![[ENUM1]] = metadata !{{{.*}}!"e1", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE1:[0-9]+]]
+// CHECK: ![[TYPE1]] = metadata !{{{.*}}!"Enum1", {{.*}} metadata ![[ENUMERATOR1]]} ; [ DW_TAG_typedef ] [Enum1]
+
+// CHECK: ![[ENUM2]] = metadata !{{{.*}}!"e2", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE2:[0-9]+]]
+// CHECK: ![[TYPE2]] = metadata !{{{.*}}!"Enum2", {{.*}} metadata ![[ENUMERATOR2]]} ; [ DW_TAG_typedef ] [Enum2]
+
+// CHECK: ![[ENUM3]] = metadata !{{{.*}}!"e3", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE3:[0-9]+]]
+// CHECK: ![[TYPE3]] = metadata !{{{.*}}!"Enum3", {{.*}} metadata ![[ENUMERATOR3]]} ; [ DW_TAG_typedef ] [Enum3]
More information about the cfe-commits
mailing list