[cfe-commits] [PATCH] C++11 nullptr-convert standalone tool
Richard Smith
richard at metafoo.co.uk
Mon Nov 26 14:04:07 PST 2012
================
Comment at: nullptr-convert/Matchers.cpp:34-39
@@ +33,8 @@
+/// would match the declarations for p1, p2 and p3 but not p4.
+AST_MATCHER(VarDecl, hasNullInitializer) {
+ const Expr *Initializer = Node.getAnyInitializer();
+ return (Initializer != NULL && Initializer->isNullPointerConstant(
+ Node.getASTContext(), Expr::NPC_ValueDependentIsNull)
+ != Expr::NPCK_NotNull);
+}
+
----------------
Instead of just looking for a few special cases, you could find *all* null pointer constants by looking for casts with CK_NullToPointer or CK_NullToMemberPointer.
http://llvm-reviews.chandlerc.com/D136
More information about the cfe-commits
mailing list