RegionMap[D].reset(SP);
}
-void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
- QualType FnType, llvm::Function *Fn) {
+llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
+ SourceLocation Loc,
+ QualType FnType,
+ bool IsDeclForCallSite) {
StringRef Name;
StringRef LinkageName;
const Decl *D = GD.getDecl();
if (!D)
- return;
+ return nullptr;
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
llvm::DIFile *Unit = getOrCreateFile(Loc);
- bool IsDeclForCallSite = Fn ? true : false;
llvm::DIScope *FDContext =
IsDeclForCallSite ? Unit : getDeclContextDescriptor(D);
llvm::DINodeArray TParamsArray;
FDContext, Name, LinkageName, Unit, LineNo,
getOrCreateFunctionType(D, FnType, Unit), ScopeLine, Flags, SPFlags,
TParamsArray.get(), getFunctionDeclaration(D));
-
- if (IsDeclForCallSite)
- Fn->setSubprogram(SP);
-
DBuilder.retainType(SP);
+ return SP;
}
void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
if (Func->getSubprogram())
return;
- if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
- EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
+ if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined()) {
+ llvm::DISubprogram *SP =
+ EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType,
+ /*IsDeclForCallSite=*/true);
+ assert(SP && "Could not find decl for callee?");
+ Func->setSubprogram(SP);
+ }
}
void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {
/// End an inlined function scope.
void EmitInlineFunctionEnd(CGBuilderTy &Builder);
- /// Emit debug info for a function declaration.
- /// \p Fn is set only when a declaration for a debug call site gets created.
- void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
- QualType FnType, llvm::Function *Fn = nullptr);
+ /// Emit debug info for a function declaration. Set \p IsDeclForCallSite if
+ /// a call site entry must reference the declaration.
+ llvm::DISubprogram *EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+ QualType FnType,
+ bool IsDeclForCallSite = false);
/// Emit debug info for an extern function being called.
/// This is needed for call site debug info.