Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: tools/clang/pass_to_move/tests/test-original.cc

Issue 1534793004: Update the Pass→std::move() tool to handle nested calls to Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/pass_to_move/tests/test-expected.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/pass_to_move/tests/test-original.cc
diff --git a/tools/clang/pass_to_move/tests/test-original.cc b/tools/clang/pass_to_move/tests/test-original.cc
index 06ea9e0833c493c33ac5c2801b5f3f272aee7f62..1e2a96d0b0d2669d4ff367c23ad9f78e5d011d5f 100644
--- a/tools/clang/pass_to_move/tests/test-original.cc
+++ b/tools/clang/pass_to_move/tests/test-original.cc
@@ -24,19 +24,39 @@ struct E {
A* a;
};
-void F() {
+struct F {
+ explicit F(A&&);
+ F&& Pass();
+};
+
+void Test() {
+ // Pass that returns rvalue reference should use std::move.
A a1;
A a2 = a1.Pass();
+ // Pass that doesn't return a rvalue reference should not be rewritten.
B b1;
B b2 = b1.Pass();
+ // std::move() needs to wrap the entire expression when passing a member.
C c;
A a3 = c.a.Pass();
+ // Don't rewrite things that return rvalue references that aren't named Pass.
D d1;
D d2 = d1.NotPass();
+ // Pass via a pointer type should dereference the pointer first.
E e;
A a4 = e.a->Pass();
+
+ // Nested Pass() is handled correctly.
+ A a5;
+ F f = F(a5.Pass()).Pass();
+
+ // Chained Pass is handled (mostly) correctly. The replacement applier dedupes
+ // the insertion of std::move, so the result is not completely correct...
+ // ... but hopefully there's very little code following this broken pattern.
+ A a6;
+ A a7 = a6.Pass().Pass();
}
« no previous file with comments | « tools/clang/pass_to_move/tests/test-expected.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698