[PATCH] Add warnings for undefined behaviors with pointers
Richard Smith
richard at metafoo.co.uk
Tue Jun 3 13:06:07 PDT 2014
Some suggestions on diagnostic wording.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2392-2393
@@ +2391,4 @@
+def warn_this_bool_conversion : Warning<
+ "this pointer can only be false in undefined contexts, which may be "
+ "removed during optimization">,
+ InGroup<UndefinedBoolConversion>, DefaultIgnore;
----------------
"undefined contexts" is rather unclear here. Maybe something like:
"'this' pointer cannot be null in well-defined C++ code; comparison may be removed"
(I don't like "during optimization" either, since it suggests we guarantee to leave this alone at `-O0`)
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2396-2398
@@ +2395,5 @@
+def warn_address_of_reference_bool_conversion : Warning<
+ "pointer to reference can only be false in undefined contexts, which may be "
+ "removed during optimization">,
+ InGroup<UndefinedBoolConversion>, DefaultIgnore;
+
----------------
Likewise:
"reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be removed"
http://reviews.llvm.org/D3999
More information about the cfe-commits
mailing list