[PATCH] Re-adding the isSpelledAsLValue check in Consumed analysis
Richard Smith
richard at metafoo.co.uk
Mon Feb 24 14:04:10 PST 2014
This doesn't seem like the right approach. The special case here is `std::move`, not universal references that end up being lvalues.
================
Comment at: test/SemaCXX/warn-consumed-analysis.cpp:149
@@ +148,3 @@
+
+ var1 = move(var0);
+
----------------
The reason this consumes `var0` *isn't* because `var0` was passed to a `T&&` (which was actually an lvalue reference), it's that inside `move`, the object was cast to an rvalue reference and moved from.
Consider:
void f(ConsumableClass &does_not_consume);
template<typename ...T> void call_f(T &&...t) {
f(std::forward<T>(t)...);
}
void g() {
ConsumableClass x;
call_f(x); // does *not* consume x
consume(x); // ok
}
http://llvm-reviews.chandlerc.com/D2872
More information about the cfe-commits
mailing list