[PATCH] Extend loop variable naming checks

Jack Yang jack.yang at intel.com
Thu Mar 7 12:32:13 PST 2013



================
Comment at: test/cpp11-migrate/LoopConvert/naming-alias.cpp:19-20
@@ +18,4 @@
+  // element, and thus we consider the name "t" aliased to the loop.
+  // The extra blank braces are left as a placeholder for after the variable
+  // declaration is deleted.
+  for (int i = 0; i < N; ++i) {
----------------
Dmitri Gribenko wrote:
> These braces are not needed with CHECK-NOT in place.
When loop convert deletes the declaration, it doesn't remove the whole line.  In this case, it replaces the line "Val &t = Arr[i]; { }" with "{ }", and so if the braces aren't present, it would replace the declaration with an empty line. That is, loop convert doesn't delete the line even if it's empty.

As far as I know, there's no way for llvm's filecheck to skip the empty line. The intent of the braces serves as a placeholder so that that line is matched to move on to checking the next line.

Could replacing it with something like the following be a solution?

  for (int i = 0; i < N; ++i) {
    Val &t = Arr[i]; int y = t.x;
  }
  // CHECK: for (auto & t : Arr)
  // CHECK-NOT: Val &{{[a-z_]+}} =
  // CHECK-NEXT: int y = t.x;


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



More information about the cfe-commits mailing list