Skip to content

Commit fa59ac3

Browse files
author
Devang Patel
committed
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.
llvm-svn: 143227
1 parent d443641 commit fa59ac3

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,27 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
745745
if (!Method->isStatic()) {
746746
// "this" pointer is always first argument.
747747
QualType ThisPtr = Method->getThisType(CGM.getContext());
748-
llvm::DIType ThisPtrType =
749-
DBuilder.createArtificialType(getOrCreateType(ThisPtr, Unit));
750-
751-
TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
752-
Elts.push_back(ThisPtrType);
748+
749+
const CXXRecordDecl *RD = Method->getParent();
750+
if (isa<ClassTemplateSpecializationDecl>(RD)) {
751+
// Create pointer type directly in this case.
752+
const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
753+
QualType PointeeTy = ThisPtrTy->getPointeeType();
754+
unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
755+
uint64_t Size = CGM.getContext().getTargetInfo().getPointerWidth(AS);
756+
uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy);
757+
llvm::DIType PointeeType = getOrCreateType(PointeeTy, Unit);
758+
llvm::DIType ThisPtrType =
759+
DBuilder.createArtificialType
760+
(DBuilder.createPointerType(PointeeType, Size, Align));
761+
TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
762+
Elts.push_back(ThisPtrType);
763+
} else {
764+
llvm::DIType ThisPtrType =
765+
DBuilder.createArtificialType(getOrCreateType(ThisPtr, Unit));
766+
TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType;
767+
Elts.push_back(ThisPtrType);
768+
}
753769
}
754770

755771
// Copy rest of the arguments.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
2+
3+
// Check that this pointer type is TC<int>
4+
// CHECK: !10} ; [ DW_TAG_pointer_type
5+
// CHECK-NEXT: !10 ={{.*}}"TC<int>"
6+
7+
template<typename T>
8+
class TC {
9+
public:
10+
TC(const TC &) {}
11+
TC() {}
12+
};
13+
14+
TC<int> tci;
15+

0 commit comments

Comments
 (0)