[PATCH] Fix UseNullptr fails to replace explicit cast to nullptr assigned to const pointers
Edwin Vane
edwin.vane at intel.com
Thu Apr 4 14:16:57 PDT 2013
================
Comment at: cpp11-migrate/UseNullptr/NullptrMatchers.cpp:67
@@ -65,3 +66,3 @@
)
).bind(CastSequence);
}
----------------
I think perhaps a simpler way to state this is:
castExpr(
anyOf(
ImplicitCastToNull(),
explicitCastExpr(
hasDescendant(ImplicitCastToNull),
)
),
unless(hasParent(explicitCastExpr()))
)
I'm just concerned about special-casing certain kinds of cast sequences. With the one above I hope it captures the idea of what we're looking for better: an implicit cast to null and the longest continuous sequence of explicit casts around it.
Notice I suggest hasParent instead of hasAncestor. May want to test this.
================
Comment at: test/cpp11-migrate/UseNullptr/basic.cpp:271
@@ +270,3 @@
+void const_ambiguous_function(const int *p) {}
+void const_ambiguous_function(const float *p) {}
+
----------------
Can you move these ambiguity tests above test_const_pointers() so they're grouped with the other ambiguous tests?
================
Comment at: test/cpp11-migrate/UseNullptr/basic.cpp:255
@@ +254,3 @@
+
+// Test assignments to const pointers
+void test_const_pointers() {
----------------
I think a better description for these tests would be:
Tests where the implicit cast to null is surrounded by another implicit cast (non-const to const in these cases) with possible explicit casts in-between.
http://llvm-reviews.chandlerc.com/D627
More information about the cfe-commits
mailing list