[cfe-commits] r150159 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-artificial-arg.cpp

Eric Christopher echristo at apple.com
Wed Feb 8 23:26:21 PST 2012


Author: echristo
Date: Thu Feb  9 01:26:21 2012
New Revision: 150159

URL: http://llvm.org/viewvc/llvm-project?rev=150159&view=rev
Log:
Don't cache the artificial type for the this pointer, there's no
difference in the qual type. This is a workaround for the fact that
the type isn't artificial but the this decl is, however, we don't
have any way of representing it in the current metadata. For now,
however, just don't cache the full type.

Fixes rdar://10831526 and probably a couple of others.

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=150159&r1=150158&r2=150159&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Feb  9 01:26:21 2012
@@ -829,15 +829,17 @@
       uint64_t Size = CGM.getContext().getTargetInfo().getPointerWidth(AS);
       uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy);
       llvm::DIType PointeeType = getOrCreateType(PointeeTy, Unit);
-      llvm::DIType ThisPtrType =
-        DBuilder.createArtificialType
-        (DBuilder.createPointerType(PointeeType, Size, Align));
+      llvm::DIType ThisPtrType = DBuilder.createPointerType(PointeeType, Size, Align);
       TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
+      // TODO: This and the artificial type below are misleading, the
+      // types aren't artificial the argument is, but the current
+      // metadata doesn't represent that.
+      ThisPtrType = DBuilder.createArtificialType(ThisPtrType);
       Elts.push_back(ThisPtrType);
     } else {
-      llvm::DIType ThisPtrType =
-        DBuilder.createArtificialType(getOrCreateType(ThisPtr, Unit));
+      llvm::DIType ThisPtrType = getOrCreateType(ThisPtr, Unit);
       TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
+      ThisPtrType = DBuilder.createArtificialType(ThisPtrType);
       Elts.push_back(ThisPtrType);
     }
   }

Added: cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp?rev=150159&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp Thu Feb  9 01:26:21 2012
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+template<class X> class B {
+public:
+  explicit B(X* p = 0);
+};
+
+class A
+{
+public:
+  A(int value) : m_a_value(value) {};
+  A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}
+
+  virtual ~A() {}
+
+private:
+  int m_a_value;
+  B<A> m_client_A;
+};
+
+int main(int argc, char **argv) {
+  A reallyA (500);
+}
+
+// FIXME: The numbers are truly awful.
+// CHECK: !22 = metadata !{i32 786447, null, metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_pointer_type ]
+// CHECK: metadata !5, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !34, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !36} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !35, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
+// CHECK: !35 = metadata !{null, metadata !30, metadata !13, metadata !22}





More information about the cfe-commits mailing list