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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143227 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 4448153..b7107d5 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -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.