]> granicus.if.org Git - clang/commitdiff
DebugInfo can be enabled or disabled at function level (e.g. using an attribute)...
authorDevang Patel <dpatel@apple.com>
Mon, 7 Mar 2011 18:45:56 +0000 (18:45 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 7 Mar 2011 18:45:56 +0000 (18:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127165 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjC.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h

index 9587de223aa759e33d1484f1131e7fa2b1a2b05b..c11c264d342748b484ef766fb884b3a42b4cf69d 100644 (file)
@@ -873,7 +873,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,
                                        const DeclMapTy &ldm) {
   const BlockDecl *blockDecl = blockInfo.getBlockDecl();
 
-  DebugInfo = CGM.getDebugInfo();
+  DebugInfo = getDebugInfo();
   BlockInfo = &blockInfo;
 
   // Arrange for local static and local extern declarations to appear
index add163da1d2e8970f35d00cec4c01d13bd02345a..e23d6107c0be99b00c73beeca7ba205f7c5bbf95 100644 (file)
@@ -1937,7 +1937,7 @@ LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) {
 
 RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, 
                                      ReturnValueSlot ReturnValue) {
-  if (CGDebugInfo *DI = CGM.getDebugInfo()) {
+  if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(E->getLocStart());
     DI->UpdateLineDirectiveRegion(Builder);
     DI->EmitStopPoint(Builder);
index 911a0ea418d0badd708a24f3f5efc773d419a54e..c442f10b866fbb8cd605a949c9d14b157ad7ad74 100644 (file)
@@ -2568,11 +2568,11 @@ Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) {
          "Invalid scalar expression to emit");
 
   if (isa<CXXDefaultArgExpr>(E))
-    CGM.disableDebugInfo();
+    disableDebugInfo();
   Value *V = ScalarExprEmitter(*this, IgnoreResultAssign)
     .Visit(const_cast<Expr*>(E));
   if (isa<CXXDefaultArgExpr>(E))
-    CGM.enableDebugInfo();
+    enableDebugInfo();
   return V;
 }
 
index d3616c3bfc21fa31c2985949660c4b487572fbf4..e37b19f25343199c8777163359fb84132ead24be 100644 (file)
@@ -121,8 +121,8 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
                                       const ObjCContainerDecl *CD) {
   FunctionArgList Args;
   // Check if we should generate debug info for this method.
-  if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
-    DebugInfo = CGM.getDebugInfo();
+  if (CGM.getModuleDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
+    DebugInfo = CGM.getModuleDebugInfo();
 
   llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
 
index 958eca75402c54fbdad017605dccbedd85ae40ea..50e03cd0c7ad22eabba3b887f4a0f7c7ed580ce0 100644 (file)
@@ -33,7 +33,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
     Target(CGM.getContext().Target), Builder(cgm.getModule().getContext()),
     BlockInfo(0), BlockPointer(0),
     NormalCleanupDest(0), EHCleanupDest(0), NextCleanupDestIndex(1),
-    ExceptionSlot(0), DebugInfo(0), IndirectBranch(0),
+    ExceptionSlot(0), DebugInfo(0), DisableDebugInfo(false), IndirectBranch(0),
     SwitchInsn(0), CaseRangeBlock(0),
     DidCallStackSave(false), UnreachableBlock(0),
     CXXThisDecl(0), CXXThisValue(0), CXXVTTDecl(0), CXXVTTValue(0),
@@ -336,8 +336,8 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn) {
   const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
   
   // Check if we should generate debug info for this function.
-  if (CGM.getDebugInfo() && !FD->hasAttr<NoDebugAttr>())
-    DebugInfo = CGM.getDebugInfo();
+  if (CGM.getModuleDebugInfo() && !FD->hasAttr<NoDebugAttr>())
+    DebugInfo = CGM.getModuleDebugInfo();
 
   FunctionArgList Args;
   QualType ResTy = FD->getResultType();
index ef006d9b2045f2d18374caa188fdf5ff0fb3f317..648afc1734a0422321603faf44eb397c59d89f97 100644 (file)
@@ -944,6 +944,7 @@ public:
                                       const VarDecl *V);
 private:
   CGDebugInfo *DebugInfo;
+  bool DisableDebugInfo;
 
   /// IndirectBranch - The first time an indirect goto is seen we create a block
   /// with an indirect branch.  Every time we see the address of a label taken,
@@ -1030,7 +1031,14 @@ public:
 
   CodeGenTypes &getTypes() const { return CGM.getTypes(); }
   ASTContext &getContext() const;
-  CGDebugInfo *getDebugInfo() { return DebugInfo; }
+  CGDebugInfo *getDebugInfo() { 
+    if (DisableDebugInfo) 
+      return NULL;
+    return DebugInfo; 
+  }
+  void disableDebugInfo() { DisableDebugInfo = true; }
+  void enableDebugInfo() { DisableDebugInfo = false; }
+
 
   const LangOptions &getLangOptions() const { return CGM.getLangOptions(); }
 
index 439cc7d3577676e6447b8a1345a70abd3d7d8b27..9da4574057d35a0dee7252c80030ca828f75954c 100644 (file)
@@ -64,7 +64,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
     ABI(createCXXABI(*this)), 
     Types(C, M, TD, getTargetCodeGenInfo().getABIInfo(), ABI),
     TBAA(0),
-    VTables(*this), Runtime(0), DisableDebugInfo(false),
+    VTables(*this), Runtime(0),
     CFConstantStringClassRef(0), ConstantStringClassRef(0),
     VMContext(M.getContext()),
     NSConcreteGlobalBlockDecl(0), NSConcreteStackBlockDecl(0),
@@ -1281,7 +1281,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
     EmitCXXGlobalVarDeclInitFunc(D, GV);
 
   // Emit global variable debug information.
-  if (CGDebugInfo *DI = getDebugInfo()) {
+  if (CGDebugInfo *DI = getModuleDebugInfo()) {
     DI->setLocation(D->getLocation());
     DI->EmitGlobalVariable(GV, D);
   }
index 550a4dcc8b55f0f2b79d836f28b7c38409531d85..a9855fba510432cb2f7e995cc0f6a9ecd589bd72 100644 (file)
@@ -152,7 +152,6 @@ class CodeGenModule : public CodeGenTypeCache {
 
   CGObjCRuntime* Runtime;
   CGDebugInfo* DebugInfo;
-  bool DisableDebugInfo;
 
   // WeakRefReferences - A set of references that have only been seen via
   // a weakref so far. This is used to remove the weak of the reference if we ever
@@ -282,13 +281,7 @@ public:
     StaticLocalDeclMap[D] = GV;
   }
 
-  CGDebugInfo *getDebugInfo() { 
-    if (DisableDebugInfo) 
-      return NULL;
-    return DebugInfo; 
-  }
-  void disableDebugInfo() { DisableDebugInfo = true; }
-  void enableDebugInfo() { DisableDebugInfo = false; }
+  CGDebugInfo *getModuleDebugInfo() { return DebugInfo; }
 
   ASTContext &getContext() const { return Context; }
   const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }