|
@@ -103,8 +103,7 @@ AnalyzerOptions::mayInlineCXXMemberFunction(
|
|
|
|
|
|
StringRef AnalyzerOptions::getCheckerStringOption(StringRef CheckerName,
|
|
|
StringRef OptionName,
|
|
|
- StringRef DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
+ bool SearchInParents) const {
|
|
|
assert(!CheckerName.empty() &&
|
|
|
"Empty checker name! Make sure the checker object (including it's "
|
|
|
"bases!) if fully initialized before calling this function!");
|
|
@@ -117,62 +116,66 @@ StringRef AnalyzerOptions::getCheckerStringOption(StringRef CheckerName,
|
|
|
return StringRef(I->getValue());
|
|
|
size_t Pos = CheckerName.rfind('.');
|
|
|
if (Pos == StringRef::npos)
|
|
|
- return DefaultVal;
|
|
|
+ break;
|
|
|
+
|
|
|
CheckerName = CheckerName.substr(0, Pos);
|
|
|
} while (!CheckerName.empty() && SearchInParents);
|
|
|
- return DefaultVal;
|
|
|
+
|
|
|
+ llvm_unreachable("Unknown checker option! Did you call getChecker*Option "
|
|
|
+ "with incorrect parameters? User input must've been "
|
|
|
+ "verified by CheckerRegistry.");
|
|
|
+
|
|
|
+ return "";
|
|
|
}
|
|
|
|
|
|
StringRef AnalyzerOptions::getCheckerStringOption(const ento::CheckerBase *C,
|
|
|
StringRef OptionName,
|
|
|
- StringRef DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
+ bool SearchInParents) const {
|
|
|
return getCheckerStringOption(
|
|
|
- C->getTagDescription(), OptionName, DefaultVal, SearchInParents);
|
|
|
+ C->getTagDescription(), OptionName, SearchInParents);
|
|
|
}
|
|
|
|
|
|
bool AnalyzerOptions::getCheckerBooleanOption(StringRef CheckerName,
|
|
|
StringRef OptionName,
|
|
|
- bool DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
- // FIXME: We should emit a warning here if the value is something other than
|
|
|
- // "true", "false", or the empty string (meaning the default value),
|
|
|
- // but the AnalyzerOptions doesn't have access to a diagnostic engine.
|
|
|
- return llvm::StringSwitch<bool>(
|
|
|
+ bool SearchInParents) const {
|
|
|
+ auto Ret = llvm::StringSwitch<llvm::Optional<bool>>(
|
|
|
getCheckerStringOption(CheckerName, OptionName,
|
|
|
- DefaultVal ? "true" : "false",
|
|
|
SearchInParents))
|
|
|
.Case("true", true)
|
|
|
.Case("false", false)
|
|
|
- .Default(DefaultVal);
|
|
|
+ .Default(None);
|
|
|
+
|
|
|
+ assert(Ret &&
|
|
|
+ "This option should be either 'true' or 'false', and should've been "
|
|
|
+ "validated by CheckerRegistry!");
|
|
|
+
|
|
|
+ return *Ret;
|
|
|
}
|
|
|
|
|
|
bool AnalyzerOptions::getCheckerBooleanOption(const ento::CheckerBase *C,
|
|
|
StringRef OptionName,
|
|
|
- bool DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
+ bool SearchInParents) const {
|
|
|
return getCheckerBooleanOption(
|
|
|
- C->getTagDescription(), OptionName, DefaultVal, SearchInParents);
|
|
|
+ C->getTagDescription(), OptionName, SearchInParents);
|
|
|
}
|
|
|
|
|
|
int AnalyzerOptions::getCheckerIntegerOption(StringRef CheckerName,
|
|
|
StringRef OptionName,
|
|
|
- int DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
- int Ret = DefaultVal;
|
|
|
+ bool SearchInParents) const {
|
|
|
+ int Ret = 0;
|
|
|
bool HasFailed = getCheckerStringOption(CheckerName, OptionName,
|
|
|
- std::to_string(DefaultVal),
|
|
|
SearchInParents)
|
|
|
.getAsInteger(0, Ret);
|
|
|
- assert(!HasFailed && "analyzer-config option should be numeric");
|
|
|
+ assert(!HasFailed &&
|
|
|
+ "This option should be numeric, and should've been validated by "
|
|
|
+ "CheckerRegistry!");
|
|
|
(void)HasFailed;
|
|
|
return Ret;
|
|
|
}
|
|
|
|
|
|
int AnalyzerOptions::getCheckerIntegerOption(const ento::CheckerBase *C,
|
|
|
StringRef OptionName,
|
|
|
- int DefaultVal,
|
|
|
- bool SearchInParents ) const {
|
|
|
+ bool SearchInParents) const {
|
|
|
return getCheckerIntegerOption(
|
|
|
- C->getTagDescription(), OptionName, DefaultVal, SearchInParents);
|
|
|
+ C->getTagDescription(), OptionName, SearchInParents);
|
|
|
}
|