clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
cert
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::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
24
class
ProperlySeededRandomGeneratorCheck
:
public
ClangTidyCheck
{
25
public
:
26
ProperlySeededRandomGeneratorCheck
(StringRef
Name
,
ClangTidyContext
*Context);
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
31
private
:
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
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::cert::ProperlySeededRandomGeneratorCheck
Random number generator must be seeded properly.
Definition:
ProperlySeededRandomGeneratorCheck.h:24
clang::tidy::cert::ProperlySeededRandomGeneratorCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
ProperlySeededRandomGeneratorCheck.cpp:31
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:78
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:26
clang::tidy::cert
Definition:
CERTTidyModule.cpp:233
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:126
Generated on Thu Nov 21 2024 14:00:58 for clang-tools by
1.9.6