]> granicus.if.org Git - clang/commitdiff
Revert "[CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC"
authorVedant Kumar <vsk@apple.com>
Thu, 11 Jul 2019 19:28:07 +0000 (19:28 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 11 Jul 2019 19:28:07 +0000 (19:28 +0000)
This reverts commit 1af41074445229fea66b99710a850e5f42ecfa95.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365814 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h

index 50c344fd348a1cb3a5b1240f22632a781956ab9c..f6ee7ee26d4bf2705bb13c623c6bc4c401f8d4ea 100644 (file)
@@ -3621,19 +3621,18 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
     RegionMap[D].reset(SP);
 }
 
-llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
-                                                  SourceLocation Loc,
-                                                  QualType FnType,
-                                                  bool IsDeclForCallSite) {
+void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
+                                   QualType FnType, llvm::Function *Fn) {
   StringRef Name;
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
   if (!D)
-    return nullptr;
+    return;
 
   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;
@@ -3666,8 +3665,11 @@ llvm::DISubprogram *CGDebugInfo::EmitFunctionDecl(GlobalDecl GD,
       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,
@@ -3689,13 +3691,8 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
   if (Func->getSubprogram())
     return;
 
-  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);
-  }
+  if (!CalleeDecl->isStatic() && !CalleeDecl->isInlined())
+    EmitFunctionDecl(CalleeDecl, CalleeDecl->getLocation(), CalleeType, Func);
 }
 
 void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) {
index ca713fc016990185a1d91af3d1008bb54a00927c..7edbea86633a39122a5d3382438218a724c5d82f 100644 (file)
@@ -408,11 +408,10 @@ public:
   /// End an inlined function scope.
   void EmitInlineFunctionEnd(CGBuilderTy &Builder);
 
-  /// 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 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 an extern function being called.
   /// This is needed for call site debug info.