llvm-project/clang-tools-extra/clang-tidy
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
..
cert Add a license clarification for use of links and titles of CERT secure coding guidelines. 2015-12-10 13:53:36 +00:00
cppcoreguidelines [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index 2015-12-13 22:08:26 +00:00
google [clang-tidy] google-explicit-constructor: improve the warning message 2015-11-28 02:25:02 +00:00
llvm [clang-tidy] Fix llvm-include-order check on Windows. 2015-09-04 15:46:51 +00:00
misc [clang-tidy] Fix a typo in my latest commit. 2015-11-25 16:38:22 +00:00
modernize Replace a dyn_cast with isa where the result was only being used as a boolean. NFC. 2015-11-18 07:08:11 +00:00
readability [clang-tidy] Fix PR25812. 2015-12-12 11:31:25 +00:00
tool Fix problem with Clang-tidy parallel configure build. 2015-11-25 19:16:34 +00:00
utils [clang-tidy] Sort includes case-sensitively. 2015-12-10 12:24:19 +00:00
CMakeLists.txt Add a new module for the C++ Core Guidelines, and the first checker for those guidelines: cppcoreguidelines-pro-type-reinterpret-cast. 2015-10-06 13:31:00 +00:00
ClangTidy.cpp [clang-tidy] Test commit (playing with git-svn) 2015-11-16 13:06:15 +00:00
ClangTidy.h Reapplying r246209, which exposed language options to the checkers. This time disable UseNullptrCheck when not compiling in C++ mode, but still allow in C++11 mode since it's likely the user wishes to modernize their code. 2015-08-28 13:20:46 +00:00
ClangTidyDiagnosticConsumer.cpp [clang-tidy] Test commit (playing with git-svn) 2015-11-16 13:06:15 +00:00
ClangTidyDiagnosticConsumer.h Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files. 2015-11-09 16:28:11 +00:00
ClangTidyModule.cpp [clang-tidy] Default options in modules. 2014-10-16 11:27:57 +00:00
ClangTidyModule.h Revert "Apply modernize-use-default to clang-tools-extra." 2015-10-20 21:45:52 +00:00
ClangTidyModuleRegistry.h [clang-tidy] Fixed header guards using clang-tidy llvm-header-guard check. NFC. 2015-03-09 16:52:33 +00:00
ClangTidyOptions.cpp Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files. 2015-11-09 16:28:11 +00:00
ClangTidyOptions.h Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files. 2015-11-09 16:28:11 +00:00
Makefile Add a new module for the C++ Core Guidelines, and the first checker for those guidelines: cppcoreguidelines-pro-type-reinterpret-cast. 2015-10-06 13:31:00 +00:00
add_new_check.py clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests 2015-10-26 21:48:08 +00:00
rename_check.py [clang-tidy] Python script for easy check rename 2015-10-11 07:58:34 +00:00