[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 14 11:16:00 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from the `const` nits. You should wait for @Quuxplusone before committing in case there are any additional comments.



================
Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:383
   SourceLocation MoveLoc = MovingCall->getExprLoc();
+  const bool MoveArgIsConst = MoveArg->getType().isConstQualified();
 
----------------
aaron.ballman wrote:
> Drop the top-level `const` and make it an integer type so that you don't need to use the `?:` below. The implicit conversion will do the right thing in terms of the integer value.
Top-level `const` is still here on the declaration.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:393
+        if (MoveArg->getDecl() == Capture.getCapturedVar()) {
+          const int IsExplicitCapture = Capture.isExplicit();
+          Check->diag(IsExplicitCapture ? Capture.getLocation()
----------------
Top-level `const` is still here as well.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74692/new/

https://reviews.llvm.org/D74692





More information about the cfe-commits mailing list