summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/array-bounds.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve -Warray-bounds to handle multiple array extents rather than only ↵Aaron Ballman2018-04-241-0/+15
| | | | | | | | handling the top-most array extent. Patch by Bevin Hansson. llvm-svn: 330759
* [Sema] Detect more array index out of bounds when C++ overloaded operators ↵Daniel Marjamaki2017-02-281-1/+17
| | | | | | | | are used Differential Revision: https://reviews.llvm.org/D30192 llvm-svn: 296477
* Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it.Argyrios Kyrtzidis2012-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | This fixes the missing warning here: struct S { template <typename T> void meth() { char arr[3]; arr[4] = 0; // warning: array index 4 is past the end of the array } }; template <typename T> void func() { char arr[3]; arr[4] = 0; // no warning } llvm-svn: 170180
* Fix a couple bugs in the way we handle array indexes in array bounds ↵Eli Friedman2012-02-271-0/+6
| | | | | | checking. Specifically, make sure we don't ignore explicit casts in indexes, and make sure we use unsigned extension/comparisons on indexes. Fixes <rdar://problem/10916006>. llvm-svn: 151569
* Revert various template unreachability code I committed accidentally.David Blaikie2012-01-241-7/+3
| | | | | | r148774, r148775, r148776, r148777 llvm-svn: 148780
* Simple hack to do unreachable code analysis on template patterns.David Blaikie2012-01-241-3/+7
| | | | llvm-svn: 148774
* Suppress -Warray-bounds for classes (not just structs) where the last field isMatt Beaumont-Gay2011-11-291-4/+13
| | | | | | a 1-length character array. llvm-svn: 145445
* Merge branch 'yo-dawg-i-herd-u-like-arrays'Matt Beaumont-Gay2011-11-291-0/+4
| | | | llvm-svn: 145421
* Wordsmith the -Warray-bounds diagnostic text a bitMatt Beaumont-Gay2011-11-241-35/+34
| | | | llvm-svn: 145116
* Fix regression of -Warray-bounds involving varargs functions [PR 11007].Ted Kremenek2011-09-261-0/+9
| | | | llvm-svn: 140584
* Let -Warray-bounds handle casted array types without false positives.Nico Weber2011-09-171-0/+12
| | | | | | Fixes PR10771. llvm-svn: 139990
* Perform array bounds checking in more situations and properly handle specialKaelyn Uhrain2011-08-051-3/+18
| | | | | | | | | | | | | | | | case situations with the unary operators & and *. Also extend the array bounds checking to work with pointer arithmetic; the pointer arithemtic checking can be turned on using -Warray-bounds-pointer-arithmetic. The changes to where CheckArrayAccess gets called is based on some trial & error and a bunch of digging through source code and gdb backtraces in order to have the check performed under as many situations as possible (such as for variable initializers, arguments to function calls, and within conditional in addition to the simpler cases of the operands to binary and unary operator) while not being called--and triggering warnings--more than once for a given ArraySubscriptExpr. llvm-svn: 136997
* Flesh out the -Warray-bounds detection of C89 tail-padded one-elementChandler Carruth2011-08-051-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | arrays. This now suppresses the warning only in the case of a one-element array as the last field in a struct where the array size is a literal '1' rather than any macro expansion or template parameter. This doesn't distinguish between the language standard in use to allow code which dates from C89 era to compile without the warning even in C99 and C++ builds. We could add a separate warning (under a different flag) with fixit hints to switch to a flexible array, but its not clear that this would be desirable. Much of the code using this idiom is striving for maximum portability. Tests were also fleshed out a bit, and the diagnostic itself tweaked to be more pretty w.r.t. single elment arrays. This is more ugly than I would like due to APInt's not being supported by the diagnostic rendering engine. A pseudo-patch for this was proposed by Nicola Gigante, but I reworked it both for several correctness issues and for code style. Sorry this was so long in coming. llvm-svn: 136965
* disable array bounds overflow warning for cases where an array Chris Lattner2011-08-021-6/+17
| | | | | | | | | | | | | has a single element. This disables the warning in cases where there is a clear bug, but this is really rare (who uses arrays with one element?) and it also silences a large class of false positive issues with C89 code that is using tail padding in structs. A better version of this patch would detect when an array is in a tail position in a struct, but at least patch fixes the huge false positives that are hitting postgres and other code. llvm-svn: 136724
* Revert r136046 while fixing handling of e.g. &foo[index_one_past_size]Kaelyn Uhrain2011-07-261-7/+6
| | | | llvm-svn: 136113
* Expand array bounds checking to work in the presence of unary & and *,Kaelyn Uhrain2011-07-261-6/+7
| | | | | | | | | and to work with pointer arithmetic in addition to array indexing. The new pointer arithmetic porition of the array bounds checking can be turned on by -Warray-bounds-pointer-arithmetic (and is off by default). llvm-svn: 136046
* Teach CFGBuilder that the 'default' branch of a switch statement is dead if ↵Ted Kremenek2011-03-161-0/+13
| | | | | | all enum values in a switch conditioned are handled. llvm-svn: 127727
* Correctly handle nested switch statements in CFGBuilder when on switch ↵Ted Kremenek2011-03-041-0/+13
| | | | | | statement has a condition that evaluates to a constant. llvm-svn: 126977
* Teach CFGBuilder to prune trivially unreachable case statements.Ted Kremenek2011-03-011-0/+19
| | | | llvm-svn: 126797
* For C++, enhance -Warray-bounds to recursively analyze array subscript ↵Ted Kremenek2011-03-011-0/+8
| | | | | | accesses in ?: expressions. llvm-svn: 126766
* Fix bogus -Warray-bounds warning involving 'array[true]' reported in PR 9296.Ted Kremenek2011-02-231-0/+5
| | | | llvm-svn: 126341
* Add test case for PR 9284, a false positive for -Warray-bounds that is now ↵Ted Kremenek2011-02-231-4/+17
| | | | | | addressed using basic reachability analysis. llvm-svn: 126291
* Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the ↵Ted Kremenek2011-02-231-5/+16
| | | | | | | | | | related code is reachable. This suppresses some diagnostics that occur in unreachable code (e.g., -Warray-bound). We only pay the cost of doing the reachability analysis when we issue one of these diagnostics. llvm-svn: 126290
* Fix assertion failure on -Warray-bounds for 32-bit builds of Clang.Ted Kremenek2011-02-181-0/+6
| | | | llvm-svn: 125821
* Add -Warray-bounds test showing how the warning currently interoperates with ↵Ted Kremenek2011-02-171-0/+11
| | | | | | macros. llvm-svn: 125781
* Enhance the array bounds checking to work for several other constructs,Chandler Carruth2011-02-171-7/+62
| | | | | | | | | especially C++ code, and generally expand the test coverage. Logic adapted from a patch by Kaelyn Uhrain <rikka@google.com> and another Googler. llvm-svn: 125775
* Fix assertion failure in -Warray-bounds on template parameters used as arrays.Ted Kremenek2011-02-161-0/+21
llvm-svn: 125693
OpenPOWER on IntegriCloud