llvm-project/clang-tools-extra/clang-tidy/cppcoreguidelines
Matthias Gehre 37f10a0c25 [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index
Summary:
This is http://reviews.llvm.org/D13746 but instead of including <array>,
a stub is provided.
This check flags all array subscriptions on static arrays and
std::arrays that either have a non-compile-time-constant index or are
out of bounds.

Dynamic accesses into arrays are difficult for both tools and humans to
validate as safe. array_view is a bounds-checked, safe type for
accessing arrays of data. at() is another alternative that ensures
single accesses are bounds-checked. If iterators are needed to access an
array, use the iterators from an array_view constructed over the array.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15030

llvm-svn: 255470
2015-12-13 22:08:26 +00:00
..
CMakeLists.txt [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index 2015-12-13 22:08:26 +00:00
CppCoreGuidelinesTidyModule.cpp [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index 2015-12-13 22:08:26 +00:00
Makefile
ProBoundsArrayToPointerDecayCheck.cpp Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not consider const" 2015-11-17 23:35:39 +00:00
ProBoundsArrayToPointerDecayCheck.h Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not consider const" 2015-11-17 23:35:39 +00:00
ProBoundsConstantArrayIndexCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index 2015-12-13 22:08:26 +00:00
ProBoundsConstantArrayIndexCheck.h [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index 2015-12-13 22:08:26 +00:00
ProBoundsPointerArithmeticCheck.cpp [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated pointer arithmetic 2015-11-26 22:32:11 +00:00
ProBoundsPointerArithmeticCheck.h [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic 2015-10-12 21:53:19 +00:00
ProTypeConstCastCheck.cpp Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeConstCastCheck.h Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeCstyleCastCheck.cpp [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast 2015-11-08 21:10:39 +00:00
ProTypeCstyleCastCheck.h [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast 2015-11-08 21:10:39 +00:00
ProTypeReinterpretCastCheck.cpp Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeReinterpretCastCheck.h Fixing links and reformatting code; NFC. 2015-10-07 20:33:36 +00:00
ProTypeStaticCastDowncastCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast 2015-10-12 20:46:53 +00:00
ProTypeStaticCastDowncastCheck.h [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast 2015-10-12 20:46:53 +00:00
ProTypeUnionAccessCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00
ProTypeUnionAccessCheck.h [clang-tidy] add check cppcoreguidelines-pro-type-union-access 2015-10-16 18:46:30 +00:00
ProTypeVarargCheck.cpp [clang-tidy] add check cppcoreguidelines-pro-type-vararg 2015-10-21 20:09:02 +00:00
ProTypeVarargCheck.h [clang-tidy] add check cppcoreguidelines-pro-type-vararg 2015-10-21 20:09:02 +00:00