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 {
18 
19 /// This checks that all array subscriptions on static arrays and std::arrays
20 /// have a constant index and are within bounds
21 ///
22 /// For the user-facing documentation see:
23 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html
24 class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
25   const std::string GslHeader;
26   const IncludeSorter::IncludeStyle IncludeStyle;
27   std::unique_ptr<IncludeInserter> Inserter;
28 
29 public:
30   ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context);
31   void registerPPCallbacks(CompilerInstance &Compiler) override;
32   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35 };
36 
37 } // namespace tidy
38 } // namespace clang
39 
40 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
41