[clang-tidy] Supresses misc-move-constructor-init warning for const fields.

Patch by CJ DiMeglio!

Differential revision: https://reviews.llvm.org/D28973

llvm-svn: 294459
This commit is contained in:
Alexander Kornienko 2017-02-08 14:56:16 +00:00
parent 2933875cc2
commit bb64200e16
2 changed files with 13 additions and 0 deletions

View File

@ -57,6 +57,9 @@ void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
if (QT.isTriviallyCopyableType(*Result.Context))
return;
if (QT.isConstQualified())
return;
const auto *RD = QT->getAsCXXRecordDecl();
if (RD && RD->isTriviallyCopyable())
return;

View File

@ -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;