r365809 - [CGDebugInfo] Simplify EmitFunctionDecl parameters, NFC

Vedant Kumar via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 12:11:46 PDT 2019


Author: vedantk
Date: Thu Jul 11 12:11:46 2019
New Revision: 365809

URL: http://llvm.org/viewvc/llvm-project?rev=365809&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=365809&r1=365808&r2=365809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jul 11 12:11:46 2019
@@ -3621,18 +3621,19 @@ void CGDebugInfo::EmitFunctionStart(Glob
     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(Globa
       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::EmitFuncDeclForCallSit
   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) {

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=365809&r1=365808&r2=365809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jul 11 12:11:46 2019
@@ -408,10 +408,11 @@ public:
   /// 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.




More information about the cfe-commits mailing list