[PATCH] Extend loop variable naming checks

Dmitri Gribenko gribozavr at gmail.com
Wed Mar 6 12:42:25 PST 2013



================
Comment at: cpp11-migrate/LoopConvert/VariableNaming.cpp:66
@@ -64,2 +65,3 @@
 /// converter in a loop nested within SourceStmt.
 bool VariableNamer::declarationExists(const StringRef Symbol) {
+  assert(Context != 0 && "Expected an ASTContext");
----------------
Please drop the 'const' in StringRef.

================
Comment at: test/cpp11-migrate/LoopConvert/naming-alias.cpp:15-16
@@ +14,4 @@
+void aliasing() {
+  // The extra blank braces are left as a placeholder for after the variable
+  // declaration is deleted.
+  for (int i = 0; i < N; ++i) {
----------------
Use CHECK-NOT.  Current CHECK will match a partial line even when the variable decl is not deleted.

================
Comment at: test/cpp11-migrate/LoopConvert/naming-alias.cpp:8-9
@@ +7,4 @@
+const int N = 10;
+int nums[N];
+int sum = 0;
+
----------------
Are `nums` and `sum` used?

Also, could you add a comment explaining what is aliasing with what.  I don't really understand it now.

================
Comment at: test/cpp11-migrate/LoopConvert/naming-conflict.cpp:23
@@ +22,3 @@
+  // CHECK: int num = 0;
+  // CHECK-NEXT: for (auto & [[VAR:[a-z_]+]] : nums)
+  // CHECK-NEXT: printf("Fibonacci number is %d\n", [[VAR]]);
----------------
Why did you use a regex here instead of hardcoding the name, like in tests below?



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



More information about the cfe-commits mailing list