Szelethus created this revision. Szelethus added reviewers: NoQ, dcoughlin, baloghadamsoftware, Charusso, xazax.hun, rnkovacs. Szelethus added a project: clang. Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, jfb, mikhail.ramalho, a.sidorin, JDevlieghere, szepet, whisperity.
During my work on analyzer dependencies, I created a great amount of new checkers that emitted no diagnostics at all, and were purely modeling some function or another. However, the user shouldn't really disable/enable these by hand, so I think it would be great to hide them by default, along with other, older modeling-only checkers and debug checkers. I intentionally chose not to hide alpha checkers, because they have a scary enough name, in my opinion, to cause no surprise when they emit false positives or cause crashes. CodeChecker also works by individually enabling and disabling each and every checker, and the dependency patches would create a great amount of unnecessary work on that side. But this is yet another reason, not the main motivation behind this patch :) The patch introduces the `Hidden` bit into the TableGen files (you may remember it before I removed it in D53995 <https://reviews.llvm.org/D53995>), and checkers that are either marked as hidden, or are in a package that is marked hidden won't be displayed under `-analyzer-checker-help`. `-analyzer-checker-help-hidden`, a new flag meant for developers only, displays the full list. Some dumps I made while coding (not a part of this patch): CHECKER HIDDEN: debug.AnalysisOrder CHECKER HIDDEN: debug.Stats CHECKER NOT HIDDEN: alpha.security.ArrayBound CHECKER NOT HIDDEN: alpha.security.ArrayBoundV2 CHECKER NOT HIDDEN: osx.cocoa.AutoreleaseWrite CHECKER NOT HIDDEN: alpha.unix.BlockInCriticalSection CHECKER NOT HIDDEN: alpha.core.BoolAssignment CHECKER HIDDEN: core.builtin.BuiltinFunctions CHECKER NOT HIDDEN: osx.coreFoundation.CFError CHECKER HIDDEN: debug.DumpCFG CHECKER HIDDEN: debug.ViewCFG CHECKER NOT HIDDEN: osx.coreFoundation.CFNumber CHECKER NOT HIDDEN: osx.coreFoundation.CFRetainRelease CHECKER NOT HIDDEN: alpha.unix.cstring.BufferOverlap CHECKER HIDDEN: unix.cstring.CStringModeling CHECKER NOT HIDDEN: alpha.unix.cstring.NotNullTerminated CHECKER NOT HIDDEN: unix.cstring.NullArg CHECKER NOT HIDDEN: alpha.unix.cstring.OutOfBounds CHECKER NOT HIDDEN: unix.cstring.BadSizeArg CHECKER HIDDEN: cplusplus.SelfAssignment CHECKER NOT HIDDEN: core.CallAndMessage CHECKER NOT HIDDEN: alpha.core.CallAndMessageUnInitRefArg CHECKER HIDDEN: debug.DumpCalls CHECKER HIDDEN: debug.DumpCallGraph CHECKER HIDDEN: debug.ViewCallGraph CHECKER NOT HIDDEN: alpha.core.CastSize CHECKER NOT HIDDEN: alpha.core.CastToStruct CHECKER NOT HIDDEN: alpha.unix.Chroot CHECKER NOT HIDDEN: osx.cocoa.ClassRelease CHECKER NOT HIDDEN: alpha.clone.CloneChecker CHECKER HIDDEN: debug.ConfigDumper CHECKER NOT HIDDEN: alpha.core.Conversion CHECKER NOT HIDDEN: valist.CopyToSelf CHECKER NOT HIDDEN: deadcode.DeadStores CHECKER NOT HIDDEN: alpha.cplusplus.DeleteWithNonVirtualDtor CHECKER NOT HIDDEN: security.insecureAPI.DeprecatedOrUnsafeBufferHandling CHECKER NOT HIDDEN: core.NullDereference CHECKER NOT HIDDEN: alpha.osx.cocoa.DirectIvarAssignment CHECKER NOT HIDDEN: alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions CHECKER NOT HIDDEN: core.DivideZero CHECKER HIDDEN: debug.DumpDominators CHECKER HIDDEN: unix.DynamicMemoryModeling CHECKER NOT HIDDEN: alpha.core.DynamicTypeChecker CHECKER NOT HIDDEN: core.DynamicTypePropagation CHECKER NOT HIDDEN: optin.osx.cocoa.localizability.EmptyLocalizationContextChecker CHECKER NOT HIDDEN: alpha.cplusplus.EnumCastOutOfRange CHECKER HIDDEN: debug.ViewExplodedGraph CHECKER HIDDEN: debug.ExprInspection CHECKER NOT HIDDEN: alpha.core.FixedAddr CHECKER NOT HIDDEN: security.FloatLoopCounter CHECKER NOT HIDDEN: optin.performance.GCDAntipattern CHECKER HIDDEN: apiModeling.google.GTest CHECKER NOT HIDDEN: alpha.security.taint.TaintPropagation CHECKER NOT HIDDEN: alpha.core.IdenticalExpr CHECKER NOT HIDDEN: cplusplus.InnerPointer CHECKER NOT HIDDEN: alpha.osx.cocoa.InstanceVariableInvalidation CHECKER NOT HIDDEN: alpha.cplusplus.InvalidatedIterator CHECKER HIDDEN: alpha.cplusplus.IteratorModeling CHECKER NOT HIDDEN: alpha.cplusplus.IteratorRange CHECKER HIDDEN: alpha.osx.cocoa.IvarInvalidationModeling CHECKER NOT HIDDEN: alpha.llvm.Conventions CHECKER HIDDEN: debug.DumpLiveStmts CHECKER HIDDEN: debug.DumpLiveVars CHECKER NOT HIDDEN: osx.MIG CHECKER NOT HIDDEN: optin.mpi.MPI-Checker CHECKER NOT HIDDEN: osx.SecKeychainAPI CHECKER NOT HIDDEN: osx.API CHECKER NOT HIDDEN: unix.Malloc CHECKER NOT HIDDEN: alpha.security.MallocOverflow CHECKER NOT HIDDEN: unix.MallocSizeof CHECKER NOT HIDDEN: unix.MismatchedDeallocator CHECKER NOT HIDDEN: alpha.cplusplus.MismatchedIterator CHECKER NOT HIDDEN: alpha.osx.cocoa.MissingInvalidationMethod CHECKER NOT HIDDEN: alpha.security.MmapWriteExec CHECKER NOT HIDDEN: cplusplus.Move CHECKER NOT HIDDEN: osx.cocoa.NSAutoreleasePool CHECKER NOT HIDDEN: osx.cocoa.NSError CHECKER HIDDEN: osx.NSOrCFErrorDerefChecker CHECKER NOT HIDDEN: cplusplus.NewDelete CHECKER NOT HIDDEN: cplusplus.NewDeleteLeaks CHECKER NOT HIDDEN: osx.cocoa.NilArg CHECKER HIDDEN: core.builtin.NoReturnFunctions CHECKER NOT HIDDEN: optin.osx.cocoa.localizability.NonLocalizedStringChecker CHECKER NOT HIDDEN: core.NonNullParamChecker CHECKER HIDDEN: core.NonnilStringConstants CHECKER NOT HIDDEN: nullability.NullPassedToNonnull CHECKER NOT HIDDEN: nullability.NullReturnedFromNonnull CHECKER HIDDEN: nullability.NullabilityBase CHECKER NOT HIDDEN: nullability.NullableDereferenced CHECKER NOT HIDDEN: nullability.NullablePassedToNonnull CHECKER NOT HIDDEN: nullability.NullableReturnedFromNonnull CHECKER NOT HIDDEN: osx.NumberObjectConversion CHECKER NOT HIDDEN: optin.osx.OSObjectCStyleCast CHECKER NOT HIDDEN: osx.OSObjectRetainCount CHECKER NOT HIDDEN: osx.cocoa.AtSync CHECKER NOT HIDDEN: osx.coreFoundation.containers.PointerSizedValues CHECKER NOT HIDDEN: osx.coreFoundation.containers.OutOfBounds CHECKER NOT HIDDEN: osx.cocoa.Dealloc CHECKER NOT HIDDEN: osx.cocoa.ObjCGenerics CHECKER NOT HIDDEN: osx.cocoa.Loops CHECKER NOT HIDDEN: osx.cocoa.IncompatibleMethodTypes CHECKER NOT HIDDEN: osx.cocoa.NonNilReturnValue CHECKER NOT HIDDEN: osx.ObjCProperty CHECKER NOT HIDDEN: osx.cocoa.SelfInit CHECKER NOT HIDDEN: osx.cocoa.MissingSuperCall CHECKER NOT HIDDEN: osx.cocoa.SuperDealloc CHECKER NOT HIDDEN: osx.cocoa.UnusedIvars CHECKER NOT HIDDEN: optin.performance.Padding CHECKER NOT HIDDEN: alpha.osx.cocoa.localizability.PluralMisuseChecker CHECKER NOT HIDDEN: alpha.core.PointerArithm CHECKER NOT HIDDEN: alpha.nondeterminism.PointerSorting CHECKER NOT HIDDEN: alpha.core.PointerSub CHECKER NOT HIDDEN: alpha.unix.PthreadLock CHECKER HIDDEN: debug.ReportStmts CHECKER HIDDEN: osx.cocoa.RetainCountBase CHECKER NOT HIDDEN: osx.cocoa.RetainCount CHECKER NOT HIDDEN: alpha.security.ReturnPtrRange CHECKER NOT HIDDEN: core.uninitialized.UndefReturn CHECKER NOT HIDDEN: osx.cocoa.RunLoopAutoreleaseLeak CHECKER NOT HIDDEN: security.insecureAPI.SecuritySyntaxChecker CHECKER NOT HIDDEN: alpha.unix.SimpleStream CHECKER NOT HIDDEN: alpha.core.SizeofPtr CHECKER NOT HIDDEN: alpha.core.StackAddressAsyncEscape CHECKER HIDDEN: core.StackAddrEscapeBase CHECKER NOT HIDDEN: core.StackAddressEscape CHECKER HIDDEN: apiModeling.StdCLibraryFunctions CHECKER NOT HIDDEN: alpha.unix.Stream CHECKER HIDDEN: debug.TaintTest CHECKER NOT HIDDEN: alpha.core.TestAfterDivZero CHECKER HIDDEN: debug.DumpTraversal CHECKER HIDDEN: apiModeling.TrustNonnull CHECKER NOT HIDDEN: security.insecureAPI.UncheckedReturn CHECKER NOT HIDDEN: core.uninitialized.Branch CHECKER NOT HIDDEN: core.uninitialized.CapturedBlockVariable CHECKER NOT HIDDEN: core.UndefinedBinaryOperatorResult CHECKER NOT HIDDEN: core.uninitialized.ArraySubscript CHECKER NOT HIDDEN: core.uninitialized.Assign CHECKER NOT HIDDEN: valist.Uninitialized CHECKER NOT HIDDEN: alpha.cplusplus.UninitializedObject CHECKER NOT HIDDEN: unix.API CHECKER NOT HIDDEN: optin.portability.UnixAPI CHECKER NOT HIDDEN: alpha.deadcode.UnreachableCode CHECKER NOT HIDDEN: valist.Unterminated CHECKER NOT HIDDEN: core.VLASize CHECKER HIDDEN: valist.ValistBase CHECKER NOT HIDDEN: osx.cocoa.VariadicMethodTypes CHECKER NOT HIDDEN: unix.Vfork CHECKER NOT HIDDEN: optin.cplusplus.VirtualCall CHECKER NOT HIDDEN: security.insecureAPI.bcmp CHECKER NOT HIDDEN: security.insecureAPI.bcopy CHECKER NOT HIDDEN: security.insecureAPI.bzero CHECKER NOT HIDDEN: security.insecureAPI.getpw CHECKER NOT HIDDEN: security.insecureAPI.gets CHECKER NOT HIDDEN: security.insecureAPI.mkstemp CHECKER NOT HIDDEN: security.insecureAPI.mktemp CHECKER NOT HIDDEN: security.insecureAPI.rand CHECKER NOT HIDDEN: security.insecureAPI.strcpy CHECKER NOT HIDDEN: security.insecureAPI.vfork Repository: rC Clang https://reviews.llvm.org/D60925 Files: include/clang/Driver/CC1Options.td include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h include/clang/StaticAnalyzer/Checkers/CheckerBase.td include/clang/StaticAnalyzer/Checkers/Checkers.td include/clang/StaticAnalyzer/Core/AnalyzerOptions.h include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h lib/Frontend/CompilerInvocation.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/SarifDiagnostics.cpp lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp test/Analysis/show-checker-list.c utils/TableGen/ClangSACheckersEmitter.cpp
Index: utils/TableGen/ClangSACheckersEmitter.cpp =================================================================== --- utils/TableGen/ClangSACheckersEmitter.cpp +++ utils/TableGen/ClangSACheckersEmitter.cpp @@ -110,6 +110,16 @@ return ""; } +static bool isHidden(const Record *R) { + if (R->getValueAsBit("Hidden")) + return true; + // Not declared as hidden, check the parent package if it is hidden. + if (DefInit *DI = dyn_cast<DefInit>(R->getValueInit("ParentPackage"))) + return isHidden(DI->getDef()); + + return false; +} + static void printChecker(llvm::raw_ostream &OS, const Record &R) { OS << "CHECKER(" << "\""; OS.write_escaped(getCheckerFullName(&R)) << "\", "; @@ -118,7 +128,14 @@ OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; OS << "\""; OS.write_escaped(getCheckerDocs(R)); - OS << "\""; + OS << "\", "; + + if (!isHidden(&R)) + OS << "false"; + else + OS << "true"; + + OS << ")\n"; } namespace clang { @@ -206,7 +223,6 @@ "\n"; for (const Record *checker : checkers) { printChecker(OS, *checker); - OS << ")\n"; } OS << "\n" "#endif // GET_CHECKERS\n" Index: test/Analysis/show-checker-list.c =================================================================== --- /dev/null +++ test/Analysis/show-checker-list.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -analyzer-checker-help \ +// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK + +// RUN: %clang_cc1 -analyzer-checker-help-hidden \ +// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN + +// CHECK: core.DivideZero +// CHECK-HIDDEN: core.DivideZero + +// CHECK-NOT: unix.DynamicMemoryModeling +// CHECK-HIDDEN: unix.DynamicMemoryModeling Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -115,9 +115,9 @@ // Register builtin checkers. #define GET_CHECKERS -#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ +#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ addChecker(register##CLASS, shouldRegister##CLASS, FULLNAME, HELPTEXT, \ - DOC_URI); + DOC_URI, IS_HIDDEN); #define GET_PACKAGES #define PACKAGE(FULLNAME) addPackage(FULLNAME); @@ -350,8 +350,9 @@ void CheckerRegistry::addChecker(InitializationFunction Rfn, ShouldRegisterFunction Sfn, StringRef Name, - StringRef Desc, StringRef DocsUri) { - Checkers.emplace_back(Rfn, Sfn, Name, Desc, DocsUri); + StringRef Desc, StringRef DocsUri, + bool IsHidden) { + Checkers.emplace_back(Rfn, Sfn, Name, Desc, DocsUri, IsHidden); // Record the presence of the checker in its packages. StringRef PackageName, LeafName; @@ -421,6 +422,9 @@ const size_t InitialPad = 2; for (const auto &Checker : Checkers) { + if (!AnOpts.ShowCheckerHelpHidden && Checker.IsHidden) + continue; + Out.indent(InitialPad) << Checker.FullName; int Pad = OptionFieldWidth - Checker.FullName.size(); Index: lib/StaticAnalyzer/Core/SarifDiagnostics.cpp =================================================================== --- lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -256,7 +256,7 @@ static StringRef getRuleDescription(StringRef CheckName) { return llvm::StringSwitch<StringRef>(CheckName) #define GET_CHECKERS -#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ +#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ .Case(FULLNAME, HELPTEXT) #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER @@ -267,7 +267,7 @@ static StringRef getRuleHelpURIStr(StringRef CheckName) { return llvm::StringSwitch<StringRef>(CheckName) #define GET_CHECKERS -#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ +#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ .Case(FULLNAME, DOC_URI) #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp =================================================================== --- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -33,7 +33,7 @@ AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) { static const StringRef StaticAnalyzerChecks[] = { #define GET_CHECKERS -#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ +#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ FULLNAME, #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef CHECKER Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -234,28 +234,30 @@ } #if CLANG_ENABLE_STATIC_ANALYZER - // Honor -analyzer-checker-help. - // This should happen AFTER plugins have been loaded! - if (Clang->getAnalyzerOpts()->ShowCheckerHelp) { + // These should happen AFTER plugins have been loaded! + + AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts(); + // Honor -analyzer-checker-help and -analyzer-checker-help-hidden. + if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpHidden) { ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins, - *Clang->getAnalyzerOpts(), + AnOpts, Clang->getDiagnostics(), Clang->getLangOpts()); return true; } // Honor -analyzer-list-enabled-checkers. - if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) { + if (AnOpts.ShowEnabledCheckerList) { ento::printEnabledCheckerList(llvm::outs(), Clang->getFrontendOpts().Plugins, - *Clang->getAnalyzerOpts(), + AnOpts, Clang->getDiagnostics(), Clang->getLangOpts()); } // Honor -analyzer-config-help. - if (Clang->getAnalyzerOpts()->ShowConfigOptionsList) { + if (AnOpts.ShowConfigOptionsList) { ento::printAnalyzerConfigList(llvm::outs()); return true; } Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -285,6 +285,7 @@ } Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help); + Opts.ShowCheckerHelpHidden = Args.hasArg(OPT_analyzer_checker_help_hidden); Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help); Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers); Opts.ShouldEmitErrorsOnInvalidConfigValue = Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h =================================================================== --- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h +++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h @@ -137,6 +137,7 @@ StringRef Desc; StringRef DocumentationUri; CmdLineOptionList CmdLineOptions; + bool IsHidden = false; StateFromCmdLine State = StateFromCmdLine::State_Unspecified; ConstCheckerInfoList Dependencies; @@ -150,9 +151,10 @@ } CheckerInfo(InitializationFunction Fn, ShouldRegisterFunction sfn, - StringRef Name, StringRef Desc, StringRef DocsUri) + StringRef Name, StringRef Desc, StringRef DocsUri, + bool IsHidden) : Initialize(Fn), ShouldRegister(sfn), FullName(Name), Desc(Desc), - DocumentationUri(DocsUri) {} + DocumentationUri(DocsUri), IsHidden(IsHidden) {} // Used for lower_bound. explicit CheckerInfo(StringRef FullName) : FullName(FullName) {} @@ -190,16 +192,19 @@ /// Adds a checker to the registry. Use this non-templated overload when your /// checker requires custom initialization. void addChecker(InitializationFunction Fn, ShouldRegisterFunction sfn, - StringRef FullName, StringRef Desc, StringRef DocsUri); + StringRef FullName, StringRef Desc, StringRef DocsUri, + bool IsHidden); /// Adds a checker to the registry. Use this templated overload when your /// checker does not require any custom initialization. template <class T> - void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri) { + void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri, + bool IsHidden = false) { // Avoid MSVC's Compiler Error C2276: // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx addChecker(&CheckerRegistry::initializeManager<T>, - &CheckerRegistry::returnTrue<T>, FullName, Desc, DocsUri); + &CheckerRegistry::returnTrue<T>, FullName, Desc, DocsUri, + IsHidden); } /// Makes the checker with the full name \p fullName depends on the checker Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -197,6 +197,7 @@ unsigned DisableAllChecks : 1; unsigned ShowCheckerHelp : 1; + unsigned ShowCheckerHelpHidden : 1; unsigned ShowEnabledCheckerList : 1; unsigned ShowConfigOptionsList : 1; unsigned ShouldEmitErrorsOnInvalidConfigValue : 1; Index: include/clang/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- include/clang/StaticAnalyzer/Checkers/Checkers.td +++ include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -20,7 +20,7 @@ def Alpha : Package<"alpha">; def Core : Package<"core">; -def CoreBuiltin : Package<"builtin">, ParentPackage<Core>; +def CoreBuiltin : Package<"builtin">, ParentPackage<Core>, Hidden; def CoreUninitialized : Package<"uninitialized">, ParentPackage<Core>; def CoreAlpha : Package<"core">, ParentPackage<Alpha>; @@ -97,10 +97,10 @@ // The APIModeling package is for checkers that model APIs and don't perform // any diagnostics. These checkers are always turned on; this package is // intended for API modeling that is not controlled by the target triple. -def APIModeling : Package<"apiModeling">; -def GoogleAPIModeling : Package<"google">, ParentPackage<APIModeling>; +def APIModeling : Package<"apiModeling">, Hidden; +def GoogleAPIModeling : Package<"google">, ParentPackage<APIModeling>, Hidden; -def Debug : Package<"debug">; +def Debug : Package<"debug">, Hidden; def CloneDetectionAlpha : Package<"clone">, ParentPackage<Alpha>; @@ -141,7 +141,8 @@ def StackAddrEscapeBase : Checker<"StackAddrEscapeBase">, HelpText<"Generate information about stack address escapes.">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def StackAddrEscapeChecker : Checker<"StackAddressEscape">, HelpText<"Check that addresses to stack memory do not escape the function">, @@ -154,7 +155,8 @@ def NonnullGlobalConstantsChecker: Checker<"NonnilStringConstants">, HelpText<"Assume that const string-like globals are non-null">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; } // end "core" @@ -231,7 +233,8 @@ def NullabilityBase : Checker<"NullabilityBase">, HelpText<"Stores information during the analysis about nullability.">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def NullPassedToNonnullChecker : Checker<"NullPassedToNonnull">, HelpText<"Warns when a null pointer is passed to a pointer which has a " @@ -336,7 +339,8 @@ HelpText<"The base of several CString related checkers. On it's own it emits " "no reports, but adds valuable information to the analysis when " "enabled.">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def CStringNullArg : Checker<"NullArg">, HelpText<"Check for null pointers being passed as arguments to C string " @@ -390,7 +394,8 @@ "false"> ]>, Dependencies<[CStringModeling]>, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def MallocChecker: Checker<"Malloc">, HelpText<"Check for memory leaks, double free, and use-after-free problems. " @@ -462,7 +467,8 @@ def CXXSelfAssignmentChecker : Checker<"SelfAssignment">, HelpText<"Checks C++ copy and move assignment operators for self assignment">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def MoveChecker: Checker<"Move">, HelpText<"Find use-after-move bugs in C++">, @@ -518,7 +524,8 @@ def IteratorModeling : Checker<"IteratorModeling">, HelpText<"Models iterators of C++ containers">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def InvalidatedIteratorChecker : Checker<"InvalidatedIterator">, HelpText<"Check for use of invalidated iterators">, @@ -584,7 +591,8 @@ def ValistBase : Checker<"ValistBase">, HelpText<"Gathers information about va_lists.">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def UninitializedChecker : Checker<"Uninitialized">, HelpText<"Check for usages of uninitialized (or already released) va_lists.">, @@ -783,7 +791,8 @@ def RetainCountBase : Checker<"RetainCountBase">, HelpText<"Common base of various retain count related checkers">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; } // end "osx.cocoa" @@ -791,7 +800,8 @@ def NSOrCFErrorDerefChecker : Checker<"NSOrCFErrorDerefChecker">, HelpText<"Implementation checker for NSErrorChecker and CFErrorChecker">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def NumberObjectConversionChecker : Checker<"NumberObjectConversion">, HelpText<"Check for erroneous conversions of objects representing numbers " @@ -958,7 +968,8 @@ HelpText<"Gathers information for annotation driven invalidation checking " "for classes that contains a method annotated with " "'objc_instance_variable_invalidator'">, - Documentation<NotDocumented>; + Documentation<NotDocumented>, + Hidden; def InstanceVariableInvalidation : Checker<"InstanceVariableInvalidation">, HelpText<"Check that the invalidatable instance variables are invalidated in " Index: include/clang/StaticAnalyzer/Checkers/CheckerBase.td =================================================================== --- include/clang/StaticAnalyzer/Checkers/CheckerBase.td +++ include/clang/StaticAnalyzer/Checkers/CheckerBase.td @@ -49,6 +49,7 @@ // This field is optional. list<CmdLineOption> PackageOptions; Package ParentPackage; + bit Hidden = 0; } /// Describes a 'super' package that holds another package inside it. This is @@ -91,6 +92,7 @@ list<Checker> Dependencies; bits<2> Documentation; Package ParentPackage; + bit Hidden = 0; } /// Describes a list of checker options. @@ -108,3 +110,7 @@ class Dependencies<list<Checker> Deps = []> { list<Checker> Dependencies = Deps; } + +/// Marks a checker or a package hidden. Hidden entries won't be displayed in +/// -analyzer-checker-help, which is desirable for alpha or modeling checkers. +class Hidden { bit Hidden = 1; } Index: include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h =================================================================== --- include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h +++ include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h @@ -26,7 +26,7 @@ class CheckerRegistry; #define GET_CHECKERS -#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI) \ +#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ void register##CLASS(CheckerManager &mgr); \ bool shouldRegister##CLASS(const LangOptions &LO); #include "clang/StaticAnalyzer/Checkers/Checkers.inc" Index: include/clang/Driver/CC1Options.td =================================================================== --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -107,7 +107,7 @@ ValuesCode<[{ const char *Values = #define GET_CHECKERS - #define CHECKER(FULLNAME, CLASS, HT, DOC_URI) FULLNAME "," + #define CHECKER(FULLNAME, CLASS, HT, DOC_URI, IS_HIDDEN) FULLNAME "," #include "clang/StaticAnalyzer/Checkers/Checkers.inc" #undef GET_CHECKERS #define GET_PACKAGES @@ -130,6 +130,10 @@ def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">, HelpText<"Display the list of analyzer checkers that are available">; +def analyzer_checker_help_hidden : Flag<["-"], "analyzer-checker-help-hidden">, + HelpText<"Display the list of analyzer checkers that are available, " + "including modeling checkers">; + def analyzer_config_help : Flag<["-"], "analyzer-config-help">, HelpText<"Display the list of -analyzer-config options">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits