clang-tools 8.0.0

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