]> granicus.if.org Git - clang/commitdiff
DebugInfo: Refactor default arg handling into a common place (instead of handling...
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 9 Feb 2015 19:13:51 +0000 (19:13 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 9 Feb 2015 19:13:51 +0000 (19:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228591 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprComplex.cpp
lib/CodeGen/CGExprScalar.cpp

index 3c296ae468163b79455ed4fdff27ac124f5257ff..95fad1a11430b668dd83d286bffd33e876a468a4 100644 (file)
@@ -2734,8 +2734,22 @@ struct DestroyUnpassedArg : EHScopeStack::Cleanup {
 
 }
 
+struct DisableDebugLocationUpdates {
+  CodeGenFunction &CGF;
+  bool disabledDebugInfo;
+  DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) {
+    if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo()))
+      CGF.disableDebugInfo();
+  }
+  ~DisableDebugLocationUpdates() {
+    if (disabledDebugInfo)
+      CGF.enableDebugInfo();
+  }
+};
+
 void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
                                   QualType type) {
+  DisableDebugLocationUpdates Dis(*this, E);
   if (const ObjCIndirectCopyRestoreExpr *CRE
         = dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) {
     assert(getLangOpts().ObjCAutoRefCount);
index 7d05d48e85ddbcf1680db21c6dec7b3d07a895be..80b16dd5ba3c15570900e4f21067856f6e472a23 100644 (file)
@@ -1387,12 +1387,7 @@ void CodeGenFunction::EmitAggExpr(const Expr *E, AggValueSlot Slot) {
   // Optimize the slot if possible.
   CheckAggExprForMemSetUse(Slot, E, *this);
  
-  bool hasDebugInfo = getDebugInfo();
-  if (isa<CXXDefaultArgExpr>(E))
-    disableDebugInfo();
   AggExprEmitter(*this, Slot).Visit(const_cast<Expr*>(E));
-  if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
-    enableDebugInfo();
 }
 
 LValue CodeGenFunction::EmitAggExprToLValue(const Expr *E) {
index b4c652c3d8b96b6aca5d7b56a2856cdb228d76e3..3a39b337b3e6abfc7650c3d7ef767ce524d67196 100644 (file)
@@ -1033,14 +1033,8 @@ ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E, bool IgnoreReal,
   assert(E && getComplexType(E->getType()) &&
          "Invalid complex expression to emit");
 
-  bool hasDebugInfo = getDebugInfo();
-  if (isa<CXXDefaultArgExpr>(E))
-    disableDebugInfo();
-  auto R = ComplexExprEmitter(*this, IgnoreReal, IgnoreImag)
-                .Visit(const_cast<Expr *>(E));
-  if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
-    enableDebugInfo();
-  return R;
+  return ComplexExprEmitter(*this, IgnoreReal, IgnoreImag)
+      .Visit(const_cast<Expr *>(E));
 }
 
 void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest,
index 951895f5f04ee2b778dea4eaf22dbf8e6a23bd17..3e7cd4011de85571b14201cb7c832debb1c4c0bf 100644 (file)
@@ -3393,14 +3393,8 @@ Value *CodeGenFunction::EmitScalarExpr(const Expr *E, bool IgnoreResultAssign) {
   assert(E && hasScalarEvaluationKind(E->getType()) &&
          "Invalid scalar expression to emit");
 
-  bool hasDebugInfo = getDebugInfo();
-  if (isa<CXXDefaultArgExpr>(E))
-    disableDebugInfo();
-  Value *V = ScalarExprEmitter(*this, IgnoreResultAssign)
-    .Visit(const_cast<Expr*>(E));
-  if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
-    enableDebugInfo();
-  return V;
+  return ScalarExprEmitter(*this, IgnoreResultAssign)
+      .Visit(const_cast<Expr *>(E));
 }
 
 /// EmitScalarConversion - Emit a conversion from the specified type to the