[cfe-commits] PATCH: refactor and clean up pointer arithmetic warnings

Chandler Carruth chandlerc at google.com
Thu Jun 23 00:46:16 PDT 2011


This patch refactors the pointer arithmetic checking into a single place in
SemaExpr.cpp. It provides two interfaces, one for checking a single pointer
operand, one for checking both operands of a binary operator. The second
interface goes to some lengths to DTRT for a mixture of good and bad
operands on the LHS or RHS.

It also cleans up several aspects of the accompanying diagnostics to be more
clearly worded, and provide more information when diagnosing (for example)
both the LHS and RHS of a binary operator. It also makes the types shown be
consistently shown as the pointee types instead of pointer types.

There is still a fair amount of cleanup I'd like to do here, potentially
either simplifying some code, hooking up more clients to the code, and/or
lifting more common checking into these routines. This should also help pave
the way for a more principled place to perform warnings such as the
NULL-pointer arithmetic warnings.

One thing I would be particularly interested in feedback on is the text of
the warnings themselves. Any suggestions for further polish or wordsmithing
would be great there. =]

Patch is attached, and also available here:
http://codereview.appspot.com/4631063/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110623/983825b7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_ptr_arith.patch
Type: text/x-patch
Size: 23715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110623/983825b7/attachment.bin>


More information about the cfe-commits mailing list