[cfe-commits] r125640 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaExpr.cpp test/Analysis/out-of-bounds.c test/Sema/array-bounds.c

Ted Kremenek kremenek at apple.com
Tue Feb 15 20:07:00 PST 2011


On Feb 15, 2011, at 7:16 PM, Chandler Carruth wrote:

> On Tue, Feb 15, 2011 at 5:57 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Tue Feb 15 19:57:07 2011
> New Revision: 125640
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=125640&view=rev
> Log:
> Add trivial buffer overflow checking in Sema.
> 
> Totally psyched about this, but  a little sad too. =] We just implemented this, and were polishing before sending it for review. Also, this is tracked in PR9098.

No need to be sad.  We should just put whatever is the best implementation into Clang.  If that includes scrapping what I spent an hour working on, then that's fine.  :)

> 
> Also:
> 
> +def warn_array_index_out_of_bounds : Warning<
> +  "array index %select{precedes first|excedes last}0 array element">,
> 
> Spelling of 'excedes'? ;]

Ha!

> 
> Also, maybe phrase this as "is negative" and "past the end"?

I don't think we need 'is negative' if we print out the value.  That's obvious.  Rather, I think we should focus on the implication (like, "past the end" as you suggest).

> When we implemented it we included the actual index given (or computed), and attached a note for cases where we have a declaration of the array with a fixed size.

I've incorporated these suggestions in r125649.  We now:

- print out the index
- print out the number of elements in the array (if we exceed the array size)
- have a note referencing the declaration of the array




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110215/562f2186/attachment.html>


More information about the cfe-commits mailing list