diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 6 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 12 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 4 |
4 files changed, 17 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 3b912ce3d65..abcd547be99 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -144,7 +144,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { DMEntry = llvm::ConstantExpr::getBitCast(GV, LPtrTy); // Emit global variable debug descriptor for static vars. - CGDebugInfo *DI = CGM.getDebugInfo(); + CGDebugInfo *DI = getDebugInfo(); if(DI) { DI->setLocation(D.getLocation()); DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D); @@ -224,7 +224,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { DMEntry = DeclPtr; // Emit debug info for local var declaration. - if (CGDebugInfo *DI = CGM.getDebugInfo()) { + if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(D.getLocation()); DI->EmitDeclareOfAutoVariable(&D, DeclPtr, Builder); } @@ -299,7 +299,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) { DMEntry = DeclPtr; // Emit debug info for param declaration. - if (CGDebugInfo *DI = CGM.getDebugInfo()) { + if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(D.getLocation()); DI->EmitDeclareOfArgVariable(&D, DeclPtr, Builder); } diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index d23547fb36a..1d28708c46d 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -28,7 +28,7 @@ using namespace CodeGen; //===----------------------------------------------------------------------===// void CodeGenFunction::EmitStopPoint(const Stmt *S) { - if (CGDebugInfo *DI = CGM.getDebugInfo()) { + if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(S->getLocStart()); DI->EmitStopPoint(CurFn, Builder); } @@ -124,7 +124,7 @@ bool CodeGenFunction::EmitSimpleStmt(const Stmt *S) { RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast, llvm::Value *AggLoc, bool isAggVol) { - CGDebugInfo *DI = CGM.getDebugInfo(); + CGDebugInfo *DI = getDebugInfo(); if (DI) { EnsureInsertPoint(); DI->setLocation(S.getLBracLoc()); diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 322f8bf565a..a699317f63d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -23,8 +23,8 @@ using namespace clang; using namespace CodeGen; CodeGenFunction::CodeGenFunction(CodeGenModule &cgm) - : CGM(cgm), Target(CGM.getContext().Target), SwitchInsn(NULL), - CaseRangeBlock(NULL) { + : CGM(cgm), Target(CGM.getContext().Target), DebugInfo(0), SwitchInsn(0), + CaseRangeBlock(0) { LLVMIntTy = ConvertType(getContext().IntTy); LLVMPointerWidth = Target.getPointerWidth(0); } @@ -128,7 +128,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { EmitReturnBlock(); // Emit debug descriptor for function end. - if (CGDebugInfo *DI = CGM.getDebugInfo()) { + if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(EndLoc); DI->EmitRegionEnd(CurFn, Builder); } @@ -168,7 +168,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, // Emit subprogram debug descriptor. // FIXME: The cast here is a huge hack. - if (CGDebugInfo *DI = CGM.getDebugInfo()) { + if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(StartLoc); if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { DI->EmitFunctionStart(CGM.getMangledName(FD)->getName(), @@ -197,6 +197,10 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy, void CodeGenFunction::GenerateCode(const FunctionDecl *FD, llvm::Function *Fn) { + // Check if we should generate debug info for this function. + if (CGM.getDebugInfo() && !FD->getAttr<NodebugAttr>()) + DebugInfo = CGM.getDebugInfo(); + FunctionArgList Args; if (FD->getNumParams()) { const FunctionTypeProto* FProto = FD->getType()->getAsFunctionTypeProto(); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index ce4a424c338..5888055aeda 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -55,6 +55,7 @@ namespace clang { namespace CodeGen { class CodeGenModule; class CodeGenTypes; + class CGDebugInfo; class CGFunctionInfo; class CGRecordLayout; @@ -151,6 +152,8 @@ public: void EmitBranchThroughCleanup(llvm::BasicBlock *Dest); private: + CGDebugInfo* DebugInfo; + /// LabelIDs - Track arbitrary ids assigned to labels for use in implementing /// the GCC address-of-label extension and indirect goto. IDs are assigned to /// labels inside getIDForAddrOfLabel(). @@ -228,6 +231,7 @@ public: CodeGenFunction(CodeGenModule &cgm); ASTContext &getContext() const; + CGDebugInfo *getDebugInfo() { return DebugInfo; } void GenerateObjCMethod(const ObjCMethodDecl *OMD); |