[PATCH] Added comprehensive macro arg usage logic to Use-Nullptr Transform

Dmitri Gribenko gribozavr at gmail.com
Fri May 3 05:56:57 PDT 2013



================
Comment at: cpp11-migrate/UseNullptr/NullptrActions.cpp:203
@@ +202,3 @@
+  ASTContext::ParentVector::const_iterator I = Parents.begin();
+  while (1) {
+    SourceLocation Loc;
----------------
Looks like this should be a do-while loop (reduces code duplication).

================
Comment at: cpp11-migrate/UseNullptr/NullptrActions.cpp:210
@@ +209,3 @@
+    else
+      assert(false && "Expected to find Decl or Stmt containing ancestor");
+
----------------
llvm_unreachable

================
Comment at: cpp11-migrate/UseNullptr/NullptrActions.cpp:316
@@ +315,3 @@
+  else
+    assert(false && "Unhandled ContainingAncestor node type");
+
----------------
llvm_unreachable

================
Comment at: test/cpp11-migrate/UseNullptr/macros.cpp:197-202
@@ -107,1 +196,8 @@
+  // both uses are pointers are allowed.
+  GTEST_EQ(0, i);
+  // CHECK: GTEST_EQ(0, i);
+  GTEST_EQ(0, Ptr);
+  // CHECK: GTEST_EQ(nullptr, Ptr);
+  GTEST_EQ(NULL, Ptr);
+  // CHECK: GTEST_EQ(nullptr, Ptr);
 }
----------------
This test is nice because it is reduced from real-world code, but I think you can trigger the same issue with a simpler macro, something like:


  #define FOO(x) do { int *z = x; if (x == 4) break; } while (false)
  FOO(0); // Can not be replaced with FOO(nullptr);



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



More information about the cfe-commits mailing list