[cfe-commits] r143227 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-limit.cpp

Devang Patel dpatel at apple.com
Fri Oct 28 14:12:13 PDT 2011


Author: dpatel
Date: Fri Oct 28 16:12:13 2011
New Revision: 143227

URL: http://llvm.org/viewvc/llvm-project?rev=143227&view=rev
Log:
In case of template specialization, do not try to delay emitting debug info for concrete type in -flimit-debug-info mode. This fixes some of the failures from bs15503.exp tests in gdb testsuite.

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-template-limit.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=143227&r1=143226&r2=143227&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Oct 28 16:12:13 2011
@@ -745,11 +745,27 @@
   if (!Method->isStatic()) {
     // "this" pointer is always first argument.
     QualType ThisPtr = Method->getThisType(CGM.getContext());
-    llvm::DIType ThisPtrType =
-      DBuilder.createArtificialType(getOrCreateType(ThisPtr, Unit));
-    
-    TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
-    Elts.push_back(ThisPtrType);
+
+    const CXXRecordDecl *RD = Method->getParent();
+    if (isa<ClassTemplateSpecializationDecl>(RD)) {
+      // Create pointer type directly in this case.
+      const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
+      QualType PointeeTy = ThisPtrTy->getPointeeType();
+      unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
+      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));
+      TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
+      Elts.push_back(ThisPtrType);
+    } else {
+      llvm::DIType ThisPtrType =
+        DBuilder.createArtificialType(getOrCreateType(ThisPtr, Unit));
+      TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
+      Elts.push_back(ThisPtrType);
+    }
   }
 
   // Copy rest of the arguments.

Added: cfe/trunk/test/CodeGenCXX/debug-info-template-limit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-limit.cpp?rev=143227&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template-limit.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-limit.cpp Fri Oct 28 16:12:13 2011
@@ -0,0 +1,15 @@
+// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
+
+// Check that this pointer type is TC<int>
+// CHECK: !10} ; [ DW_TAG_pointer_type
+// CHECK-NEXT: !10 ={{.*}}"TC<int>"
+
+template<typename T>
+class TC {
+public:
+  TC(const TC &) {}
+  TC() {}
+};
+
+TC<int> tci;
+





More information about the cfe-commits mailing list