File indexing completed on 2026-05-10 08:36:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNSAFEFUNCTIONSCHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNSAFEFUNCTIONSCHECK_H
0011
0012 #include "../ClangTidyCheck.h"
0013 #include "../utils/Matchers.h"
0014 #include <optional>
0015
0016 namespace clang::tidy::bugprone {
0017
0018
0019
0020
0021
0022
0023
0024 class UnsafeFunctionsCheck : public ClangTidyCheck {
0025 public:
0026 UnsafeFunctionsCheck(StringRef Name, ClangTidyContext *Context);
0027 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0028
0029 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0030 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0031
0032 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
0033 Preprocessor *ModuleExpanderPP) override;
0034 void onEndOfTranslationUnit() override;
0035
0036 struct CheckedFunction {
0037 std::string Name;
0038 matchers::MatchesAnyListedNameMatcher::NameMatcher Pattern;
0039 std::string Replacement;
0040 std::string Reason;
0041 };
0042
0043 private:
0044 const std::vector<CheckedFunction> CustomFunctions;
0045
0046
0047 const bool ReportDefaultFunctions;
0048
0049
0050 const bool ReportMoreUnsafeFunctions;
0051
0052 Preprocessor *PP = nullptr;
0053
0054
0055 std::optional<bool> IsAnnexKAvailable;
0056 };
0057
0058 }
0059
0060 #endif