2015-12-14 06:08:26 +08:00
|
|
|
//===--- ProBoundsConstantArrayIndexCheck.h - clang-tidy---------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-12-14 06:08:26 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
|
|
|
|
|
2020-06-29 23:05:51 +08:00
|
|
|
#include "../ClangTidyCheck.h"
|
2015-12-14 06:08:26 +08:00
|
|
|
#include "../utils/IncludeInserter.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
2016-05-03 02:00:29 +08:00
|
|
|
namespace cppcoreguidelines {
|
2015-12-14 06:08:26 +08:00
|
|
|
|
|
|
|
/// This checks that all array subscriptions on static arrays and std::arrays
|
|
|
|
/// have a constant index and are within bounds
|
|
|
|
///
|
|
|
|
/// For the user-facing documentation see:
|
|
|
|
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html
|
|
|
|
class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
|
|
|
|
const std::string GslHeader;
|
2020-07-27 19:48:53 +08:00
|
|
|
utils::IncludeInserter Inserter;
|
2015-12-14 06:08:26 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context);
|
[clang-tidy] Change checks to use new isLanguageVersionSupported restriction
Summary: Modifies all checks that are language version dependent to use `isLanguageVersionSupported`
Reviewers: jdoerfert, lebedev.ri, aaron.ballman, gribozavr2, Eugene.Zelenko
Reviewed By: gribozavr2
Subscribers: wuzish, nemanjai, xazax.hun, hiraditya, kbarton, steven_wu, dexonsmith, arphaman, lebedev.ri, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75340
2020-03-04 00:39:32 +08:00
|
|
|
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
|
|
|
return LangOpts.CPlusPlus;
|
|
|
|
}
|
2019-03-23 02:58:12 +08:00
|
|
|
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
|
|
|
|
Preprocessor *ModuleExpanderPP) override;
|
2015-12-14 06:08:26 +08:00
|
|
|
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
|
|
|
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
|
|
|
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
|
|
|
};
|
|
|
|
|
2016-05-03 02:00:29 +08:00
|
|
|
} // namespace cppcoreguidelines
|
2015-12-14 06:08:26 +08:00
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
|