[PATCH] Fix UseNullptr fails to replace explicit cast to nullptr assigned to const pointers
Ariel Bernal
ariel.j.bernal at intel.com
Fri Apr 5 12:32:23 PDT 2013
================
Comment at: cpp11-migrate/UseNullptr/NullptrMatchers.cpp:67
@@ -65,3 +66,3 @@
)
).bind(CastSequence);
}
----------------
Edwin Vane wrote:
> 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.
I think this is perfect, the only modification I would made is to replace hasParent with hasAncestor since the chain of explicit casts could be broken.
================
Comment at: test/cpp11-migrate/UseNullptr/basic.cpp:255
@@ +254,3 @@
+
+// Test assignments to const pointers
+void test_const_pointers() {
----------------
Edwin Vane wrote:
> 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.
done
================
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) {}
+
----------------
Edwin Vane wrote:
> Can you move these ambiguity tests above test_const_pointers() so they're grouped with the other ambiguous tests?
done
http://llvm-reviews.chandlerc.com/D627
More information about the cfe-commits
mailing list