def analyzer_checker_option_help : Flag<["-"], "analyzer-checker-option-help">,
HelpText<"Display the list of checker and package options">;
+def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-option-help-developer">,
+ HelpText<"Display the list of checker and package options meant for "
+ "development purposes only">;
+
def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">,
HelpText<"Don't emit errors on invalid analyzer-config inputs">;
bits<2> Type = val.Type;
}
+/// Marks the entry hidden. Hidden entries won't be displayed in
+/// -analyzer-checker-option-help.
+class HiddenEnum<bit val> {
+ bit Val = val;
+}
+def DontHide : HiddenEnum<0>;
+def Hide : HiddenEnum<1>;
+
/// Describes an option for a checker or a package.
class CmdLineOption<CmdLineOptionTypeEnum type, string cmdFlag, string desc,
- string defaultVal> {
+ string defaultVal, HiddenEnum isHidden = DontHide> {
bits<2> Type = type.Type;
- string CmdFlag = cmdFlag;
- string Desc = desc;
- string DefaultVal = defaultVal;
+ string CmdFlag = cmdFlag;
+ string Desc = desc;
+ string DefaultVal = defaultVal;
+ bit Hidden = isHidden.Val;
}
/// Describes a list of package options.
"for each uninitalized field, as opposed to emitting one "
"warning per constructor call, and listing the uninitialized "
"fields that belongs to it in notes.",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"CheckPointeeInitialization",
"If set to false, the checker will not analyze "
"OSObject instances. By default, the checker only checks "
"retain-release rules for Objective-C NSObject instances "
"and CoreFoundation objects.",
- "true">,
+ "true",
+ Hide>,
CmdLineOption<Boolean,
"TrackNSCFStartParam",
"Check not only that the code follows retain-release rules "
"(Aggressive) or NonLocalized only if it is not backed by a "
"SymRegion (Non-Aggressive), basically leaving only string "
"literals as NonLocalized.",
- "false">
+ "false",
+ Hide>
]>,
Documentation<HasDocumentation>;
CmdLineOption<Boolean,
"PreStmtCastExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PostStmtCastExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PreStmtArraySubscriptExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PostStmtArraySubscriptExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PreStmtCXXNewExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PostStmtCXXNewExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PreStmtOffsetOfExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PostStmtOffsetOfExpr",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PreCall",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"PostCall",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"EndFunction",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"NewAllocator",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"Bind",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"LiveSymbols",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"RegionChanges",
"",
- "false">,
+ "false",
+ Hide>,
CmdLineOption<Boolean,
"*",
"Enables all callbacks.",
- "false">
+ "false",
+ Hide>
]>,
Documentation<NotDocumented>;
unsigned ShowCheckerHelpDeveloper : 1;
unsigned ShowEnabledCheckerList : 1;
unsigned ShowCheckerOptionList : 1;
+ unsigned ShowCheckerOptionDeveloperList : 1;
unsigned ShowConfigOptionsList : 1;
unsigned ShouldEmitErrorsOnInvalidConfigValue : 1;
unsigned AnalyzeAll : 1;
AnalyzerOptions()
: DisableAllChecks(false), ShowCheckerHelp(false),
ShowCheckerHelpAlpha(false), ShowCheckerHelpDeveloper(false),
- ShowEnabledCheckerList(false), ShowCheckerOptionList(false),
+ ShowEnabledCheckerList(false),
+ ShowCheckerOptionList(false), ShowCheckerOptionDeveloperList(false),
ShowConfigOptionsList(false), AnalyzeAll(false),
AnalyzerDisplayProgress(false), AnalyzeNestedBlocks(false),
eagerlyAssumeBinOpBifurcation(false), TrimGraph(false),
StringRef OptionName;
StringRef DefaultValStr;
StringRef Description;
+ bool IsHidden;
CmdLineOption(StringRef OptionType, StringRef OptionName,
- StringRef DefaultValStr, StringRef Description)
+ StringRef DefaultValStr, StringRef Description, bool IsHidden)
: OptionType(OptionType), OptionName(OptionName),
- DefaultValStr(DefaultValStr), Description(Description) {
+ DefaultValStr(DefaultValStr), Description(Description),
+ IsHidden(IsHidden) {
assert((OptionType == "bool" || OptionType == "string" ||
OptionType == "int") &&
/// non-compatibility mode.
void addCheckerOption(StringRef OptionType, StringRef CheckerFullName,
StringRef OptionName, StringRef DefaultValStr,
- StringRef Description);
+ StringRef Description, bool IsHidden = false);
/// Adds a package to the registry.
void addPackage(StringRef FullName);
/// non-compatibility mode.
void addPackageOption(StringRef OptionType, StringRef PackageFullName,
StringRef OptionName, StringRef DefaultValStr,
- StringRef Description);
+ StringRef Description, bool IsHidden = false);
// FIXME: This *really* should be added to the frontend flag descriptions.
/// Initializes a CheckerManager by calling the initialization functions for
Opts.ShowCheckerHelpDeveloper =
Args.hasArg(OPT_analyzer_checker_help_developer);
Opts.ShowCheckerOptionList = Args.hasArg(OPT_analyzer_checker_option_help);
+ Opts.ShowCheckerOptionDeveloperList =
+ Args.hasArg(OPT_analyzer_checker_option_help_developer);
Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help);
Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers);
Opts.ShouldEmitErrorsOnInvalidConfigValue =
}
// Honor -analyzer-checker-option-help.
- if (Clang->getAnalyzerOpts()->ShowCheckerOptionList) {
+ if (AnOpts.ShowCheckerOptionList || AnOpts.ShowCheckerOptionDeveloperList) {
ento::printCheckerConfigList(llvm::outs(),
Clang->getFrontendOpts().Plugins,
*Clang->getAnalyzerOpts(),
addDependency(FULLNAME, DEPENDENCY);
#define GET_CHECKER_OPTIONS
-#define CHECKER_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL) \
- addCheckerOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC);
+#define CHECKER_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, IS_HIDDEN) \
+ addCheckerOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, IS_HIDDEN);
#define GET_PACKAGE_OPTIONS
-#define PACKAGE_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL) \
- addPackageOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC);
+#define PACKAGE_OPTION(TYPE, FULLNAME, CMDFLAG, DESC, DEFAULT_VAL, IS_HIDDEN) \
+ addPackageOption(TYPE, FULLNAME, CMDFLAG, DEFAULT_VAL, DESC, IS_HIDDEN);
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
#undef CHECKER_DEPENDENCY
StringRef PackageFullName,
StringRef OptionName,
StringRef DefaultValStr,
- StringRef Description) {
+ StringRef Description, bool IsHidden) {
PackageOptions.emplace_back(
- PackageFullName,
- CmdLineOption{OptionType, OptionName, DefaultValStr, Description});
+ PackageFullName, CmdLineOption{OptionType, OptionName, DefaultValStr,
+ Description, IsHidden});
}
void CheckerRegistry::addChecker(InitializationFunction Rfn,
StringRef CheckerFullName,
StringRef OptionName,
StringRef DefaultValStr,
- StringRef Description) {
+ StringRef Description, bool IsHidden) {
CheckerOptions.emplace_back(
- CheckerFullName,
- CmdLineOption{OptionType, OptionName, DefaultValStr, Description});
+ CheckerFullName, CmdLineOption{OptionType, OptionName, DefaultValStr,
+ Description, IsHidden});
}
void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const {
}
for (const std::pair<StringRef, const CmdLineOption &> &Entry : OptionMap) {
+ if (!AnOpts.ShowCheckerOptionDeveloperList && Entry.second.IsHidden)
+ continue;
+
const CmdLineOption &Option = Entry.second;
std::string FullOption = (Entry.first + ":" + Option.OptionName).str();
// RUN: %clang_cc1 -analyzer-checker-option-help 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyzer-checker-option-help-developer \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN
+
// CHECK: OVERVIEW: Clang Static Analyzer Checker and Package Option List
//
// CHECK: USAGE: -analyzer-config <OPTION1=VALUE,OPTION2=VALUE,...>
// CHECK: the first statement in the group is representative
// CHECK: for all other statements in the group in
// CHECK: terms of complexity. (default: 50)
+
+// CHECK-NOT: optin.cplusplus.UninitializedObject:NotesAsWarnings
+// CHECK-HIDDEN: optin.cplusplus.UninitializedObject:NotesAsWarnings
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());
}
static void printChecker(llvm::raw_ostream &OS, const Record &R) {
- OS << "CHECKER(" << "\"";
- OS.write_escaped(getCheckerFullName(&R)) << "\", ";
- OS << R.getName() << ", ";
- OS << "\"";
- OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
- OS << "\"";
- OS.write_escaped(getCheckerDocs(R));
- OS << "\", ";
-
- if (!isHidden(&R))
- OS << "false";
- else
- OS << "true";
+ OS << "CHECKER(" << "\"";
+ OS.write_escaped(getCheckerFullName(&R)) << "\", ";
+ OS << R.getName() << ", ";
+ OS << "\"";
+ OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
+ OS << "\"";
+ OS.write_escaped(getCheckerDocs(R));
+ OS << "\", ";
+
+ if (!isHidden(&R))
+ OS << "false";
+ else
+ OS << "true";
+
+ OS << ")\n";
+}
+
+static void printOption(llvm::raw_ostream &OS, StringRef FullName,
+ const Record &R) {
+ OS << "\"";
+ OS.write_escaped(getCheckerOptionType(R)) << "\", \"";
+ OS.write_escaped(FullName) << "\", ";
+ OS << '\"' << getStringValue(R, "CmdFlag") << "\", ";
+ OS << '\"';
+ OS.write_escaped(getStringValue(R, "Desc")) << "\", ";
+ OS << '\"';
+ OS.write_escaped(getStringValue(R, "DefaultVal")) << "\", ";
- OS << ")\n";
+ if (!R.getValueAsBit("Hidden"))
+ OS << "false";
+ else
+ OS << "true";
}
namespace clang {
std::vector<Record *> PackageOptions = Package
->getValueAsListOfDefs("PackageOptions");
for (Record *PackageOpt : PackageOptions) {
- OS << "PACKAGE_OPTION(\"";
- OS.write_escaped(getCheckerOptionType(*PackageOpt)) << "\", \"";
- OS.write_escaped(getPackageFullName(Package)) << "\", ";
- OS << '\"' << getStringValue(*PackageOpt, "CmdFlag") << "\", ";
- OS << '\"';
- OS.write_escaped(getStringValue(*PackageOpt, "Desc")) << "\", ";
- OS << '\"';
- OS.write_escaped(getStringValue(*PackageOpt, "DefaultVal")) << "\"";
+ OS << "PACKAGE_OPTION(";
+ printOption(OS, getPackageFullName(Package), *PackageOpt);
OS << ")\n";
}
}
std::vector<Record *> CheckerOptions = Checker
->getValueAsListOfDefs("CheckerOptions");
for (Record *CheckerOpt : CheckerOptions) {
- OS << "CHECKER_OPTION(\"";
- OS << getCheckerOptionType(*CheckerOpt) << "\", \"";
- OS.write_escaped(getCheckerFullName(Checker)) << "\", ";
- OS << '\"' << getStringValue(*CheckerOpt, "CmdFlag") << "\", ";
- OS << '\"';
- OS.write_escaped(getStringValue(*CheckerOpt, "Desc")) << "\", ";
- OS << '\"';
- OS.write_escaped(getStringValue(*CheckerOpt, "DefaultVal")) << "\"";
- OS << ")";
- OS << '\n';
+ OS << "CHECKER_OPTION(";
+ printOption(OS, getCheckerFullName(Checker), *CheckerOpt);
+ OS << ")\n";
}
}
OS << "#endif // GET_CHECKER_OPTIONS\n"