aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp10
-rw-r--r--lib/CodeGen/CGDebugInfo.h6
-rw-r--r--lib/CodeGen/CGObjC.cpp10
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp19
-rw-r--r--lib/CodeGen/CodeGenFunction.h3
5 files changed, 24 insertions, 24 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index f326be2769..e1889603ee 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -598,7 +598,8 @@ CGDebugInfo::getOrCreateType(QualType type, llvm::CompileUnitDesc *Unit)
/// EmitFunctionStart - Constructs the debug code for entering a function -
/// "llvm.dbg.func.start.".
-void CGDebugInfo::EmitFunctionStart(const FunctionDecl *FnDecl,
+void CGDebugInfo::EmitFunctionStart(const char *Name,
+ QualType ReturnType,
llvm::Function *Fn,
llvm::IRBuilder<> &Builder)
{
@@ -611,8 +612,8 @@ void CGDebugInfo::EmitFunctionStart(const FunctionDecl *FnDecl,
}
// Get name information.
- Subprogram->setName(FnDecl->getName());
- Subprogram->setFullName(FnDecl->getName());
+ Subprogram->setName(Name);
+ Subprogram->setFullName(Name);
// Gather location information.
llvm::CompileUnitDesc *Unit = getOrCreateCompileUnit(CurLoc);
@@ -620,8 +621,7 @@ void CGDebugInfo::EmitFunctionStart(const FunctionDecl *FnDecl,
uint64_t Loc = SM.getLogicalLineNumber(CurLoc);
// Get Function Type.
- QualType type = FnDecl->getResultType();
- llvm::TypeDesc *SPTy = getOrCreateType(type, Unit);
+ llvm::TypeDesc *SPTy = getOrCreateType(ReturnType, Unit);
Subprogram->setAnchor(SubprogramAnchor);
Subprogram->setContext(Unit);
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index 22a45ce8b5..9352505a96 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -110,9 +110,9 @@ public:
void EmitStopPoint(llvm::Function *Fn, BuilderType &Builder);
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
- /// start of a new function
- void EmitFunctionStart(const FunctionDecl *FnDecl, llvm::Function *Fn,
- BuilderType &Builder);
+ /// start of a new function.
+ void EmitFunctionStart(const char *Name, QualType ReturnType,
+ llvm::Function *Fn, BuilderType &Builder);
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
/// of a new block.
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 0c45c55554..c0260ad06b 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -119,7 +119,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD) {
Args.push_back(std::make_pair(IPD, IPD->getType()));
}
- StartFunction(OMD, OMD->getResultType(), Fn, Args);
+ StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocEnd());
}
/// Generate an Objective-C method. An Objective-C method is a C function with
@@ -127,13 +127,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD) {
void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
StartObjCMethod(OMD);
EmitStmt(OMD->getBody());
-
- const CompoundStmt *S = dyn_cast<CompoundStmt>(OMD->getBody());
- if (S) {
- FinishFunction(S->getRBracLoc());
- } else {
- FinishFunction();
- }
+ FinishFunction(cast<CompoundStmt>(OMD->getBody())->getRBracLoc());
}
// FIXME: I wasn't sure about the synthesis approach. If we end up
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 12e468c127..2ee08eae17 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -98,7 +98,8 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
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 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
// 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 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
FProto->getArgType(i)));
}
- StartFunction(FD, FD->getResultType(), Fn, Args);
+ StartFunction(FD, FD->getResultType(), Fn, Args,
+ cast<CompoundStmt>(FD->getBody())->getLBracLoc());
EmitStmt(FD->getBody());
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index c0a5a44b69..d57efa94f5 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -184,7 +184,8 @@ public:
llvm::Function *Fn);
void StartFunction(const Decl *D, QualType RetTy,
llvm::Function *Fn,
- const FunctionArgList &Args);
+ const FunctionArgList &Args,
+ SourceLocation StartLoc);
void FinishFunction(SourceLocation EndLoc=SourceLocation());
/// EmitFunctionProlog - Emit the target specific LLVM code to load