From ef8857dfdd4d6b4d139278c52d32e3f2e055c5d7 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Fri, 28 Oct 2011 21:12:13 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGDebugInfo.cpp | 26 +++++++++++++++---- test/CodeGenCXX/debug-info-template-limit.cpp | 15 +++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 test/CodeGenCXX/debug-info-template-limit.cpp diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 4448153591..b7107d5883 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -745,11 +745,27 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, 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(RD)) { + // Create pointer type directly in this case. + const PointerType *ThisPtrTy = cast(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. diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp new file mode 100644 index 0000000000..796a80fd62 --- /dev/null +++ b/test/CodeGenCXX/debug-info-template-limit.cpp @@ -0,0 +1,15 @@ +// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s + +// Check that this pointer type is TC +// CHECK: !10} ; [ DW_TAG_pointer_type +// CHECK-NEXT: !10 ={{.*}}"TC" + +template +class TC { +public: + TC(const TC &) {} + TC() {} +}; + +TC tci; + -- 2.40.0