Matthias Gehre | 37f10a0 | 2015-12-13 22:08:26 +0000 | [diff] [blame] | 1 | //===--- ProBoundsConstantArrayIndexCheck.h - clang-tidy---------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H |
| 12 | |
| 13 | #include "../ClangTidy.h" |
| 14 | #include "../utils/IncludeInserter.h" |
| 15 | |
| 16 | namespace clang { |
| 17 | namespace tidy { |
Etienne Bergeron | 456177b | 2016-05-02 18:00:29 +0000 | [diff] [blame] | 18 | namespace cppcoreguidelines { |
Matthias Gehre | 37f10a0 | 2015-12-13 22:08:26 +0000 | [diff] [blame] | 19 | |
| 20 | /// This checks that all array subscriptions on static arrays and std::arrays |
| 21 | /// have a constant index and are within bounds |
| 22 | /// |
| 23 | /// For the user-facing documentation see: |
| 24 | /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html |
| 25 | class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck { |
| 26 | const std::string GslHeader; |
Etienne Bergeron | 2a4c00f | 2016-05-03 02:54:05 +0000 | [diff] [blame] | 27 | const utils::IncludeSorter::IncludeStyle IncludeStyle; |
| 28 | std::unique_ptr<utils::IncludeInserter> Inserter; |
Matthias Gehre | 37f10a0 | 2015-12-13 22:08:26 +0000 | [diff] [blame] | 29 | |
| 30 | public: |
| 31 | ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context); |
| 32 | void registerPPCallbacks(CompilerInstance &Compiler) override; |
| 33 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 34 | void storeOptions(ClangTidyOptions::OptionMap &Opts) override; |
| 35 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 36 | }; |
| 37 | |
Etienne Bergeron | 456177b | 2016-05-02 18:00:29 +0000 | [diff] [blame] | 38 | } // namespace cppcoreguidelines |
Matthias Gehre | 37f10a0 | 2015-12-13 22:08:26 +0000 | [diff] [blame] | 39 | } // namespace tidy |
| 40 | } // namespace clang |
| 41 | |
| 42 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H |