Debug info bug fix, function start wasn't getting generated correctly

for Obj-C methods.

llvm-svn: 57769
This commit is contained in:
Daniel Dunbar 2008-10-18 18:22:23 +00:00
parent 2dadd3bbc6
commit 354d278518
5 changed files with 24 additions and 24 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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

View File

@ -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());

View File

@ -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