Index: clang-tidy/ClangTidy.cpp =================================================================== --- clang-tidy/ClangTidy.cpp +++ clang-tidy/ClangTidy.cpp @@ -304,11 +304,12 @@ typedef std::vector> CheckersList; static CheckersList getCheckersControlList(ClangTidyContext &Context, - bool IncludeExperimental) { + bool IncludeExperimental, + bool IncludeDebug) { CheckersList List; const auto &RegisteredCheckers = - AnalyzerOptions::getRegisteredCheckers(IncludeExperimental); + AnalyzerOptions::getRegisteredCheckers(IncludeExperimental, IncludeDebug); bool AnalyzerChecksEnabled = false; for (StringRef CheckName : RegisteredCheckers) { std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str()); @@ -376,7 +377,8 @@ Context.getOptions().AnalyzeTemporaryDtors ? "true" : "false"; AnalyzerOptions->CheckersControlList = - getCheckersControlList(Context, *Context.getOptions().EnableAlphaChecks); + getCheckersControlList(Context, *Context.getOptions().EnableAlphaChecks, + *Context.getOptions().EnableDebugChecks); if (!AnalyzerOptions->CheckersControlList.empty()) { setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions); AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel; @@ -401,7 +403,8 @@ } for (const auto &AnalyzerCheck : - getCheckersControlList(Context, *Context.getOptions().EnableAlphaChecks)) + getCheckersControlList(Context, *Context.getOptions().EnableAlphaChecks, + *Context.getOptions().EnableDebugChecks)) CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first); std::sort(CheckNames.begin(), CheckNames.end()); Index: clang-tidy/ClangTidyOptions.h =================================================================== --- clang-tidy/ClangTidyOptions.h +++ clang-tidy/ClangTidyOptions.h @@ -80,6 +80,9 @@ /// \brief Turns on experimental alpha checkers from the static analyzer. llvm::Optional EnableAlphaChecks; + /// \brief Turns on debug checkers from the static analyzer. + llvm::Optional EnableDebugChecks; + /// \brief Format code around applied fixes with clang-format using this /// style. /// Index: clang-tidy/ClangTidyOptions.cpp =================================================================== --- clang-tidy/ClangTidyOptions.cpp +++ clang-tidy/ClangTidyOptions.cpp @@ -88,6 +88,7 @@ IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex); IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors); IO.mapOptional("EnableAlphaChecks", Options.EnableAlphaChecks); + IO.mapOptional("EnableDebugChecks", Options.EnableDebugChecks); IO.mapOptional("FormatStyle", Options.FormatStyle); IO.mapOptional("User", Options.User); IO.mapOptional("CheckOptions", NOpts->Options); @@ -110,6 +111,7 @@ Options.SystemHeaders = false; Options.AnalyzeTemporaryDtors = false; Options.EnableAlphaChecks = false; + Options.EnableDebugChecks = false; Options.FormatStyle = "none"; Options.User = llvm::None; for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(), @@ -151,6 +153,7 @@ overrideValue(Result.SystemHeaders, Other.SystemHeaders); overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors); overrideValue(Result.EnableAlphaChecks, Other.EnableAlphaChecks); + overrideValue(Result.EnableDebugChecks, Other.EnableDebugChecks); overrideValue(Result.FormatStyle, Other.FormatStyle); overrideValue(Result.User, Other.User); mergeVectors(Result.ExtraArgs, Other.ExtraArgs); Index: clang-tidy/tool/ClangTidyMain.cpp =================================================================== --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -198,6 +198,12 @@ static cl::opt EnableAlphaChecks("enable-alpha-checks", cl::init(false), cl::Hidden, cl::cat(ClangTidyCategory)); +/// This option Enables debug checkers from the static analyzer. +/// This option is set to false and not visible in help, because they are not +/// for general usage. +static cl::opt EnableDebugChecks("enable-debug-checks", cl::init(false), + cl::Hidden, cl::cat(ClangTidyCategory)); + static cl::opt ExportFixes("export-fixes", cl::desc(R"( YAML file to store suggested fixes in. The stored fixes can be applied to the input source @@ -308,6 +314,7 @@ DefaultOptions.SystemHeaders = SystemHeaders; DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors; DefaultOptions.EnableAlphaChecks = EnableAlphaChecks; + DefaultOptions.EnableDebugChecks = EnableDebugChecks; DefaultOptions.FormatStyle = FormatStyle; DefaultOptions.User = llvm::sys::Process::GetEnv("USER"); // USERNAME is used on Windows. Index: docs/clang-tidy/index.rst =================================================================== --- docs/clang-tidy/index.rst +++ docs/clang-tidy/index.rst @@ -117,6 +117,10 @@ clang-analyzer- checks. This option overrides the value read from a .clang-tidy file. + -enable-alpha-checks - This option is not visible in help. + It allows to enable clang analyzer Alpha checks. + -enable-debug-checks - This option is not visible in help. + It allows to enable clang analyzer Debug checks. -checks= - Comma-separated list of globs with optional '-' prefix. Globs are processed in order of Index: test/clang-tidy/enable-debug-checks.cpp =================================================================== --- /dev/null +++ test/clang-tidy/enable-debug-checks.cpp @@ -0,0 +1,6 @@ +// Check if '-enable-debug-checks' is visible for users +// RUN: clang-tidy -help | not grep 'enable-debug-checks' + +// Check if '-enable-debug-checks' enables debug checks. +// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-debug' +// RUN: clang-tidy -checks=* -list-checks -enable-debug-checks | grep 'clang-analyzer-debug'