From f00f8032949d1d6676ca7da4a5046d3034878375 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 8 Jun 2016 20:41:54 +0000 Subject: [DebugInfo] Add calling conventions to DISubroutineType Summary: This should have been a very simple change, but it was greatly complicated by the construction of new Decls during IR generation. In particular, we reconstruct the AST function type in order to get the implicit 'this' parameter into C++ method types. We also have to worry about FunctionDecls whose types are not FunctionTypes because CGBlocks.cpp constructs some dummy FunctionDecls with 'void' type. Depends on D21114 Reviewers: aprantl, dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21141 llvm-svn: 272198 --- clang/lib/CodeGen/CodeGenFunction.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 5c8f57dc005..d32ed7f8b7b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -762,15 +762,18 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, // Emit subprogram debug descriptor. if (CGDebugInfo *DI = getDebugInfo()) { + // Reconstruct the type from the argument list so that implicit parameters, + // such as 'this' and 'vtt', show up in the debug info. Preserve the calling + // convention. + CallingConv CC = CallingConv::CC_C; + if (auto *FD = dyn_cast_or_null(D)) + if (const auto *SrcFnTy = FD->getType()->getAs()) + CC = SrcFnTy->getCallConv(); SmallVector ArgTypes; - for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end(); - i != e; ++i) { - ArgTypes.push_back((*i)->getType()); - } - - QualType FnType = - getContext().getFunctionType(RetTy, ArgTypes, - FunctionProtoType::ExtProtoInfo()); + for (const VarDecl *VD : Args) + ArgTypes.push_back(VD->getType()); + QualType FnType = getContext().getFunctionType( + RetTy, ArgTypes, FunctionProtoType::ExtProtoInfo(CC)); DI->EmitFunctionStart(GD, Loc, StartLoc, FnType, CurFn, Builder); } -- cgit v1.2.3