[PATCH] Add warnings for undefined behaviors with pointers

Richard Smith richard at metafoo.co.uk
Thu Jun 5 17:01:07 PDT 2014

LGTM with some minor diagnostic tweaks.

Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2393
@@ +2392,3 @@
+  "'this' pointer cannot be null in well-defined C++ code; pointer may be "
+  "assumed always converted to a true value">, InGroup<UndefinedBoolConversion>;
+def warn_address_of_reference_bool_conversion : Warning<
"assumed to always convert to" would sound better to me.


  assumed to always convert to 'true'

rather than

  assumed to always convert to a true value

to avoid people wondering what "a true value" is (cf. "a true Scotsman").

Likewise I'd suggest putting the %select's below into single quotes.

Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2409
@@ +2408,3 @@
+  "reference cannot be bound to dereferenced null pointer in well-defined C++ "
+  "code; comparison maybe be assumed to always evaluate to "
+  "%select{true|false}0">,
Typo "maybe be" should be "may be"


More information about the cfe-commits mailing list