Debug info bug fix, function start wasn't getting generated correctly
for Obj-C methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57769 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 12e468c..2ee08ea 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -98,7 +98,8 @@
 
 void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, 
                                     llvm::Function *Fn,
-                                    const FunctionArgList &Args) {
+                                    const FunctionArgList &Args,
+                                    SourceLocation StartLoc) {
   CurFuncDecl = D;
   FnRetTy = RetTy;
   CurFn = Fn;
@@ -122,11 +123,14 @@
   
   // Emit subprogram debug descriptor.
   // FIXME: The cast here is a huge hack.
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
-    if (CGDebugInfo *DI = CGM.getDebugInfo()) {
-      if (CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody()))
-        DI->setLocation(body->getLBracLoc());
-      DI->EmitFunctionStart(FD, CurFn, Builder);
+  if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+    DI->setLocation(StartLoc);
+    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+      DI->EmitFunctionStart(FD->getName(), RetTy, CurFn, Builder);
+    } else {
+      // Just use LLVM function name.
+      DI->EmitFunctionStart(Fn->getName().c_str(), 
+                            RetTy, CurFn, Builder);
     }
   }
 
@@ -145,7 +149,8 @@
                                     FProto->getArgType(i)));
   }
 
-  StartFunction(FD, FD->getResultType(), Fn, Args);
+  StartFunction(FD, FD->getResultType(), Fn, Args,
+                cast<CompoundStmt>(FD->getBody())->getLBracLoc());
 
   EmitStmt(FD->getBody());