From 9c78f9bddc42dbdeb05a7183b4770d33b0bda7d3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 7 Jan 2013 23:06:35 +0000 Subject: [PATCH] Extract the instance-method case for debug info out into a separate function. This is in preparation for using this to construct the function type for pointers to member functions to include the implicit/artificial 'this' parameter in that case as well. (feedback from GDB indicates that this might be all that's necessary to get it to behave well with Clang's pointer-to-member function debug output) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171809 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 20 ++++++++++---------- lib/CodeGen/CGDebugInfo.h | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index d006988936..f5d80dfb86 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -904,16 +904,18 @@ CollectRecordFields(const RecordDecl *record, llvm::DIFile tunit, llvm::DIType CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIFile Unit) { - llvm::DIType FnTy - = getOrCreateType(QualType(Method->getType()->getAs(), - 0), - Unit); - + const FunctionProtoType *Func = Method->getType()->getAs(); if (Method->isStatic()) - return FnTy; + return getOrCreateType(QualType(Func, 0), Unit); + return getOrCreateInstanceMethodType(Method->getThisType(CGM.getContext()), + Func, Unit); +} +llvm::DIType CGDebugInfo::getOrCreateInstanceMethodType( + QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit) { // Add "this" pointer. - llvm::DIArray Args = llvm::DICompositeType(FnTy).getTypeArray(); + llvm::DIArray Args = llvm::DICompositeType( + getOrCreateType(QualType(Func, 0), Unit)).getTypeArray(); assert (Args.getNumElements() && "Invalid number of arguments!"); SmallVector Elts; @@ -922,9 +924,7 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, Elts.push_back(Args.getElement(0)); // "this" pointer is always first argument. - QualType ThisPtr = Method->getThisType(CGM.getContext()); - - const CXXRecordDecl *RD = Method->getParent(); + const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl(); if (isa(RD)) { // Create pointer type directly in this case. const PointerType *ThisPtrTy = cast(ThisPtr); diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index b80dcae13f..4457e43a0a 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -111,6 +111,8 @@ class CGDebugInfo { llvm::DIType getCompletedTypeOrNull(const QualType); llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIFile F); + llvm::DIType getOrCreateInstanceMethodType( + QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit); llvm::DIType getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile F); llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F); -- 2.40.0