[PATCH] D28973: Supresses misc-move-constructor-init warning for const fields.
CJ DiMeglio via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 11:14:08 PST 2017
lethalantidote updated this revision to Diff 87484.
lethalantidote marked an inline comment as done.
lethalantidote added a comment.
- Addresses alexfh's comments.
https://reviews.llvm.org/D28973
Files:
clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
+++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
@@ -84,6 +84,16 @@
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;
Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -57,6 +57,9 @@
if (QT.isTriviallyCopyableType(*Result.Context))
return;
+ if (QT.isConstQualified())
+ return;
+
const auto *RD = QT->getAsCXXRecordDecl();
if (RD && RD->isTriviallyCopyable())
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28973.87484.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170207/6e71238b/attachment.bin>
More information about the cfe-commits
mailing list