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

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 06:55:02 PST 2020


Quuxplusone added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:329
       // CHECK-NOTES: [[@LINE-3]]:7: note: move occurred here
+      // CHECK-NOTES: [[@LINE-6]]:7: note: std::move of the const expression {{.*}}
     };
----------------
It continues to seem silly to me that you give an extra note here saying that line 325 doesn't do anything, when of course line 336 doesn't do anything either (and you don't give any extra note there).

This clang-tidy warning isn't supposed to be about what //physically happens// in the machine code during any particular compilation run; it's supposed to be about helping the user avoid //semantic// bugs by cleaning up their codebase's //logical// behavior. The rule is "don't use things after moving from them," period.

Analogously, if there were a clang-tidy warning to say "always indent four spaces after an `if`," and you proposed to add a note to some cases that said "...but here a three-space indent is OK, because C++ is whitespace-insensitive" — I'd also find //that// note to be mildly objectionable. We want to train people to do the right thing, not to do the right thing "except in this case because hey, it doesn't matter to the machine."


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

https://reviews.llvm.org/D74692





More information about the cfe-commits mailing list