[PATCH] Introducing initial UseAuto transform
Dmitri Gribenko
gribozavr at gmail.com
Tue Feb 12 12:56:37 PST 2013
================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:37-54
@@ +36,20 @@
+
+ while (true) {
+ const Expr *E2 = E->IgnoreParenImpCasts();
+ if (E2 != E) {
+ E = E2;
+ continue;
+ }
+
+ E2 = E->IgnoreConversionOperator();
+ if (E2 != E) {
+ // We hit a conversion operator. Since they may do non-trivial work,
+ // making use of auto would result in this operator no-longer being
+ // called.
+ return;
+ }
+
+ // Nothing changed. We're down as far as we can go.
+ break;
+ }
+
----------------
The loop.
================
Comment at: test/cpp11-migrate/UseAuto/iterator.cpp:67-70
@@ +66,6 @@
+
+ // declarator-id is not the same type as initializer expression. No transform
+ // should happen.
+ std::vector<int>::iterator I2 = myI;
+ // CHECK: std::vector<int>::iterator I2 = myI;
+
----------------
Edwin Vane wrote:
> Dmitri Gribenko wrote:
> > So this transformation was not being done even without this change?
> That's right. The point of that code originally was to get at the as-written source of the conversion operator. In this case, the source type of the conversion op was not the same as the dest so the change wasn't made. Now we abort on any conversion ops, even those whose source type is the same as the dest (if that's even possible) because of the side effect thing you mentioned.
I think we can drop [the loop] then. This will not break the test, and conversion operator that converts to itself will not be called implicitly.
http://llvm-reviews.chandlerc.com/D392
More information about the cfe-commits
mailing list