clang-tools 17.0.0git
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
15namespace clang::tidy::cert {
16
17/// Random number generator must be seeded properly.
18///
19/// A random number generator initialized with default value or a
20/// constant expression is a security vulnerability.
21///
22/// For the user-facing documentation see:
23/// http://clang.llvm.org/extra/clang-tidy/checks/cert/msc51-cpp.html
25public:
27 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
28 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30
31private:
32 template <class T>
33 void checkSeed(const ast_matchers::MatchFinder::MatchResult &Result,
34 const T *Func);
35
36 std::string RawDisallowedSeedTypes;
37 SmallVector<StringRef, 5> DisallowedSeedTypes;
38};
39
40} // namespace clang::tidy::cert
41
42#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_PROPERLY_SEEDED_RANDOM_GENERATOR_H
Token Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
llvm::StringMap< ClangTidyValue > OptionMap