[PATCH] Fix UseAuto replacing declaration lists with new expressions

Ariel Bernal ariel.j.bernal at intel.com
Thu May 23 12:16:20 PDT 2013



================
Comment at: test/cpp11-migrate/UseAuto/new.cpp:68
@@ +67,3 @@
+    // CHECK: MyType *g = new MyType(), **h = new MyType*();
+  }
+  return 0;
----------------
Edwin Vane wrote:
> Can we have some tests using typedefs?
yes sure

================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:112
@@ +111,3 @@
+    // one declaration in the declaration list.
+    if (VarDecls > 0) {
+      // All delcarations should match the same non-decorated type.
----------------
Edwin Vane wrote:
> Just compare DI against D->decl_begin(). No need to count VarDecls otherwise.
No problem, done

================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:120
@@ +119,3 @@
+      SourceLocation SL = Q.getStarLoc();
+      while (SL != FirsDeclTypeLoc.getBeginLoc()) {
+        Replace.insert(tooling::Replacement(SM, SL, 1, ""));
----------------
Edwin Vane wrote:
> Is this test even necessary? When you've finished unwinding all the PointerTypes, I would expect cast<PointerTypeLoc>(Q.getNexttypeLoc()) to fail no? That, is you'll unwind typelocs until you get the underlying pointed-at type.
It seems that getNextTypeLoc() doesn't fail. And on the other hand getStarLoc() returns the location of declaration list type when there's no star. I decided to use this logic since when we finish to unwind all typelocs there won't be any star left, just the underlying type.


http://llvm-reviews.chandlerc.com/D839



More information about the cfe-commits mailing list