clang-tools  14.0.0git
ReplaceRandomShuffleCheck.h
Go to the documentation of this file.
1 //===--- ReplaceRandomShuffleCheck.h - clang-tidy----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_RANDOM_SHUFFLE_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_RANDOM_SHUFFLE_H
11 
12 #include "../ClangTidyCheck.h"
13 #include "../utils/IncludeInserter.h"
14 
15 namespace clang {
16 namespace tidy {
17 namespace modernize {
18 
19 /// std::random_shuffle will be removed as of C++17. This check will find and
20 /// replace all occurrences of std::random_shuffle with std::shuffle.
21 ///
22 /// For the user-facing documentation see:
23 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-random-shuffle.html
25 public:
26  ReplaceRandomShuffleCheck(StringRef Name, ClangTidyContext *Context);
27  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
28  Preprocessor *ModuleExpanderPP) override;
29  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30  return LangOpts.CPlusPlus11;
31  }
32  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
33  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35 
36 private:
37  utils::IncludeInserter IncludeInserter;
38 };
39 
40 } // namespace modernize
41 } // namespace tidy
42 } // namespace clang
43 
44 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_RANDOM_SHUFFLE_H
clang::tidy::modernize::ReplaceRandomShuffleCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: ReplaceRandomShuffleCheck.cpp:30
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::utils::IncludeInserter
Produces fixes to insert specified includes to source files, if not yet present.
Definition: IncludeInserter.h:55
clang::tidy::modernize::ReplaceRandomShuffleCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition: ReplaceRandomShuffleCheck.h:29
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
clang::tidy::modernize::ReplaceRandomShuffleCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: ReplaceRandomShuffleCheck.cpp:56
clang::tidy::modernize::ReplaceRandomShuffleCheck::registerPPCallbacks
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
Definition: ReplaceRandomShuffleCheck.cpp:46
clang::tidy::modernize::ReplaceRandomShuffleCheck::ReplaceRandomShuffleCheck
ReplaceRandomShuffleCheck(StringRef Name, ClangTidyContext *Context)
Definition: ReplaceRandomShuffleCheck.cpp:23
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:72
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::bugprone::PP
static Preprocessor * PP
Definition: BadSignalToKillThreadCheck.cpp:29
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::modernize::ReplaceRandomShuffleCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: ReplaceRandomShuffleCheck.cpp:51
clang::tidy::modernize::ReplaceRandomShuffleCheck
std::random_shuffle will be removed as of C++17.
Definition: ReplaceRandomShuffleCheck.h:24