[PATCH] D11305: [Sema] Emit correct warning when copy-elision is not possible.

Richard Smith richard at metafoo.co.uk
Fri Jul 17 13:07:52 PDT 2015


rsmith added inline comments.

================
Comment at: lib/Sema/SemaInit.cpp:5991-6001
@@ -5990,1 +5990,13 @@
 
+    // If we're returning a function parameter, copy elision
+    // is not possible.
+    if (const FunctionDecl *FD =
+        dyn_cast_or_null<FunctionDecl>(VD->getParentFunctionOrMethod())) {
+      for (const auto *Param : FD->params()) {
+        if (Param == VD) {
+          DiagID = diag::warn_redundant_move_on_return;
+          break;
+        }
+      }
+    }
+
----------------
Can you just check `isa<ParmVarDecl>(VD)`?


Repository:
  rL LLVM

http://reviews.llvm.org/D11305







More information about the cfe-commits mailing list