summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-07-11 19:11:46 +0000
committerVedant Kumar <vsk@apple.com>2019-07-11 19:11:46 +0000
commitbdf8198d4cbdc487237f1eefbba7555cbce8251c (patch)
tree114b49567f9dc5f5de97db72ce66910a857a26bb /clang/lib/CodeGen/CGDebugInfo.cpp
parent08cb342afae142880218578a6539e0001ce30ef7 (diff)
downloadbcm5719-llvm-bdf8198d4cbdc487237f1eefbba7555cbce8251c.tar.gz
bcm5719-llvm-bdf8198d4cbdc487237f1eefbba7555cbce8251c.zip
[CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC
Replace a `llvm::Function *` parameter with a bool, which seems harder to set to the wrong value by accident. Differential Revision: https://reviews.llvm.org/D64540 llvm-svn: 365809
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f6ee7ee26d4..50c344fd348 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3621,18 +3621,19 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
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;
@@ -3665,11 +3666,8 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
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,
@@ -3691,8 +3689,13 @@ 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) {
OpenPOWER on IntegriCloud