]> granicus.if.org Git - clang/commitdiff
Remove unneeded test in tryCaptureAsConstant.
authorAkira Hatanaka <ahatanaka@apple.com>
Mon, 2 May 2016 22:29:40 +0000 (22:29 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Mon, 2 May 2016 22:29:40 +0000 (22:29 +0000)
It isn't necessary to call hasDefaultArg because we can't rematerialize
a captured variable that is a function parameter, regardless of whether
or not it has a default argument. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268318 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBlocks.cpp

index 88786bc9fcf22e7cf4c6b0216cfaf4f2116e943a..d603d21bbe0bddb810ee0f780fd01e82ee9b7ffb 100644 (file)
@@ -262,10 +262,10 @@ static bool isSafeForCXXConstantCapture(QualType type) {
 static llvm::Constant *tryCaptureAsConstant(CodeGenModule &CGM,
                                             CodeGenFunction *CGF,
                                             const VarDecl *var) {
-  // Don't rematerialize default arguments of function parameters.
-  if (auto *PD = dyn_cast<ParmVarDecl>(var))
-    if (PD->hasDefaultArg())
-      return nullptr;
+  // Return if this is a function paramter. We shouldn't try to
+  // rematerialize default arguments of function parameters.
+  if (isa<ParmVarDecl>(var))
+    return nullptr;
 
   QualType type = var->getType();