diff options
author | Eric Christopher <echristo@apple.com> | 2012-03-13 23:40:48 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2012-03-13 23:40:48 +0000 |
commit | 3b10cfe6b804cef041ddf85854d2d536f7a82cb6 (patch) | |
tree | f690ee8dfc248c75830b2d54dc4d555b10bbb646 /lib/CodeGen/CGDebugInfo.cpp | |
parent | e7591c511831aa66afe06902a408647535da6a4d (diff) |
When adding member functions to a class add any specializations of
function templates as well.
A future commit will mangle the added name with the template args
like classes are mangled.
Fixes rdar://10986010
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152683 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index bd37197ae3..d88f24339a 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -831,7 +831,7 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, = getOrCreateType(QualType(Method->getType()->getAs<FunctionProtoType>(), 0), Unit); - + // Add "this" pointer. llvm::DIArray Args = llvm::DICompositeType(FnTy).getTypeArray(); assert (Args.getNumElements() && "Invalid number of arguments!"); @@ -946,14 +946,16 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, } if (Method->hasPrototype()) Flags |= llvm::DIDescriptor::FlagPrototyped; - + + llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit); llvm::DISubprogram SP = DBuilder.createMethod(RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine, MethodTy, /*isLocalToUnit=*/false, /* isDefinition=*/ false, Virtuality, VIndex, ContainingType, - Flags, CGM.getLangOpts().Optimize); + Flags, CGM.getLangOpts().Optimize, NULL, + TParamsArray); SPCache[Method->getCanonicalDecl()] = llvm::WeakVH(SP); @@ -967,14 +969,25 @@ void CGDebugInfo:: CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, SmallVectorImpl<llvm::Value *> &EltTys, llvm::DIType RecordTy) { - for(CXXRecordDecl::method_iterator I = RD->method_begin(), - E = RD->method_end(); I != E; ++I) { - const CXXMethodDecl *Method = *I; - - if (Method->isImplicit() && !Method->isUsed()) + + // Since we want more than just the individual member decls if we + // have templated functions iterate over every declaration to gather + // the functions. + for(DeclContext::decl_iterator I = RD->decls_begin(), + E = RD->decls_end(); I != E; ++I) { + Decl *D = *I; + if (D->isImplicit() && !D->isUsed()) continue; - EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy)); + if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) + EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy)); + else if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D)) + for (FunctionTemplateDecl::spec_iterator SI = FTD->spec_begin(), + SE = FTD->spec_end(); SI != SE; ++SI) { + FunctionDecl *FD = *SI; + if (CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(FD)) + EltTys.push_back(CreateCXXMemberFunction(M, Unit, RecordTy)); + } } } |