clang-tools  10.0.0svn
ProperlySeededRandomGeneratorCheck.h
Go to the documentation of this file.
1 //===--- ProperlySeededRandomGeneratorCheck.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_CERT_PROPERLY_SEEDED_RANDOM_GENERATOR_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_PROPERLY_SEEDED_RANDOM_GENERATOR_H
11 
12 #include "../ClangTidyCheck.h"
13 #include <string>
14 
15 namespace clang {
16 namespace tidy {
17 namespace cert {
18 
19 /// Random number generator must be seeded properly.
20 ///
21 /// A random number generator initialized with default value or a
22 /// constant expression is a security vulnerability.
23 ///
24 /// For the user-facing documentation see:
25 /// http://clang.llvm.org/extra/clang-tidy/checks/cert-properly-seeded-random-generator.html
27 public:
29  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
30  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32 
33 private:
34  template <class T>
35  void checkSeed(const ast_matchers::MatchFinder::MatchResult &Result,
36  const T *Func);
37 
38  std::string RawDisallowedSeedTypes;
39  SmallVector<StringRef, 5> DisallowedSeedTypes;
40 };
41 
42 } // namespace cert
43 } // namespace tidy
44 } // namespace clang
45 
46 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_PROPERLY_SEEDED_RANDOM_GENERATOR_H
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Base class for all clang-tidy checks.
ProperlySeededRandomGeneratorCheck(StringRef Name, ClangTidyContext *Context)
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.