[PATCH] New warning -Wpessimizing-move to catch when removing calls to std::move prevent optimization

Richard Smith richard at metafoo.co.uk
Tue Apr 28 17:23:51 PDT 2015


LGTM with a couple of minor changes.


================
Comment at: lib/Sema/SemaInit.cpp:5768-5769
@@ +5767,4 @@
+      InitExpr = MTE->GetTemporaryExpr()->IgnoreImpCasts();
+      while (const CXXConstructExpr *CCE =
+                 dyn_cast<CXXConstructExpr>(InitExpr)) {
+        if (CCE->getNumArgs() != 1)
----------------
If `CCE` is a `CXXTemporaryObjectExpr` (which derives from `CXXConstructExpr`), you shouldn't step through it here -- `CXXTemporaryObjectExpr` is always modeling explicit syntax.

================
Comment at: lib/Sema/SemaInit.cpp:5770
@@ +5769,3 @@
+                 dyn_cast<CXXConstructExpr>(InitExpr)) {
+        if (CCE->getNumArgs() != 1)
+          return;
----------------
It would be marginally better to check

    CCE->getNumArgs() == 0 ||
    (CCE->getNumArgs() > 1 && !isa<CXXDefaultArgExpr>(CCE->getArg(1)))

in case the constructor has a default argument.

http://reviews.llvm.org/D7633

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list