[clang-tools-extra] r294459 - [clang-tidy] Supresses misc-move-constructor-init warning for const fields.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 8 06:56:17 PST 2017
Author: alexfh
Date: Wed Feb 8 08:56:16 2017
New Revision: 294459
URL: http://llvm.org/viewvc/llvm-project?rev=294459&view=rev
Log:
[clang-tidy] Supresses misc-move-constructor-init warning for const fields.
Patch by CJ DiMeglio!
Differential revision: https://reviews.llvm.org/D28973
Modified:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=294459&r1=294458&r2=294459&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Wed Feb 8 08:56:16 2017
@@ -57,6 +57,9 @@ void MoveConstructorInitCheck::check(con
if (QT.isTriviallyCopyableType(*Result.Context))
return;
+ if (QT.isConstQualified())
+ return;
+
const auto *RD = QT->getAsCXXRecordDecl();
if (RD && RD->isTriviallyCopyable())
return;
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp?rev=294459&r1=294458&r2=294459&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp Wed Feb 8 08:56:16 2017
@@ -84,6 +84,16 @@ struct N {
N(N &&RHS) : Mem(move(RHS.Mem)) {}
};
+struct O {
+ O(O&& other) : b(other.b) {} // ok
+ const B b;
+};
+
+struct P {
+ P(O&& other) : b(other.b) {} // ok
+ B b;
+};
+
struct Movable {
Movable(Movable &&) = default;
Movable(const Movable &) = default;
More information about the cfe-commits
mailing list