[PATCH] Introducing initial UseAuto transform

Sean Silva silvas at purdue.edu
Mon Feb 11 11:43:07 PST 2013



================
Comment at: test/cpp11-migrate/UseAuto/iterator.cpp:1
@@ +1,2 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: cpp11-migrate -use-auto %t.cpp -- --std=c++11
----------------
What is the purpose of this grep?

================
Comment at: cpp11-migrate/UseAuto/UseAuto.h:27
@@ +26,3 @@
+/// In addition to being used as the type specifier for variable declarations
+/// auto can be used in these ways (c++11 §7.1.6.4.2):
+/// * With functions with trailing return type
----------------
avoid non-ascii characters

================
Comment at: cpp11-migrate/UseAuto/UseAuto.h:36
@@ +35,3 @@
+///   * This transform applies auto only to the variable declaration not to the
+///   new expression as described in (c++11 §5.3.4.2)
+/// * A for-range-declaration
----------------
same here

================
Comment at: cpp11-migrate/UseAuto/UseAuto.cpp:43-46
@@ +42,6 @@
+
+  if (int result = UseAutoTool.run(newFrontendActionFactory(&Finder))) {
+    llvm::errs() << "Error encountered during translation.\n";
+    return result;
+  }
+
----------------
<http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly>

================
Comment at: cpp11-migrate/UseAuto/UseAutoActions.cpp:31-38
@@ +30,10 @@
+
+  const Expr *Initializer = D->getInit();
+  const CXXConstructExpr *Construct =
+      dyn_cast<const CXXConstructExpr>(Initializer);
+
+  assert(Construct && "Expecteded a CXXConstructExpr for initializer");
+
+  // Drill down to the as-written initializer.
+  const Expr *E = *Construct->arg_begin();
+
----------------
cast<> already asserts on a mismatch. These lines could be collapsed to just

`*cast<CXXConstructExpr>(D->getInit())->arg_begin()`


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



More information about the cfe-commits mailing list