]> granicus.if.org Git - clang/commitdiff
Do not use DIGlobalVariable to emit debugging information for enums.
authorDevang Patel <dpatel@apple.com>
Tue, 10 Aug 2010 18:27:15 +0000 (18:27 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 10 Aug 2010 18:27:15 +0000 (18:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110697 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/enum2.c [new file with mode: 0644]

index a75ff104767da23af21e923b7bfe8fe8c8985948..4e020f92cea032b7789e128c10665b69a9900e73 100644 (file)
@@ -1808,6 +1808,10 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
   // Create the descriptor for the variable.
   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
   llvm::StringRef Name = VD->getName();
+  llvm::DIType Ty = getOrCreateType(VD->getType(), Unit);
+  // Do not use DIGlobalVariable for enums.
+  if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type)
+    return;
   DebugFactory.CreateGlobalVariable(Unit, Name, Name, Name, Unit,
                                     getLineNumber(VD->getLocation()),
                                     getOrCreateType(VD->getType(), Unit),
diff --git a/test/CodeGen/enum2.c b/test/CodeGen/enum2.c
new file mode 100644 (file)
index 0000000..3203627
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -g -emit-llvm -o /dev/null
+int v;
+enum e { MAX };
+
+void foo (void)
+{
+  v = MAX;
+}