LimitedRandomnessCheck.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. //===--- LimitedRandomnessCheck.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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_LIMITED_RANDOMNESS_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_LIMITED_RANDOMNESS_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::cert {
  12. /// Pseudorandom number generators are not genuinely random. The result of the
  13. /// std::rand() function makes no guarantees as to the quality of the random
  14. /// sequence produced.
  15. /// This check warns for the usage of std::rand() function.
  16. ///
  17. /// For the user-facing documentation see:
  18. /// http://clang.llvm.org/extra/clang-tidy/checks/cert/msc50-cpp.html
  19. class LimitedRandomnessCheck : public ClangTidyCheck {
  20. public:
  21. LimitedRandomnessCheck(StringRef Name, ClangTidyContext *Context)
  22. : ClangTidyCheck(Name, Context) {}
  23. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  24. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  25. };
  26. } // namespace clang::tidy::cert
  27. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_LIMITED_RANDOMNESS_H