forked from OSchip/llvm-project
Refactor clients of AnalyzerOptions::getBooleanOption() to have
an intermediate helper method to query and populate the Optional value. llvm-svn: 165043
This commit is contained in:
parent
24c20ec63a
commit
4924a0161b
|
@ -194,6 +194,10 @@ private:
|
|||
/// If an option value is not provided, returns the given \p DefaultVal.
|
||||
bool getBooleanOption(StringRef Name, bool DefaultVal);
|
||||
|
||||
/// Variant that accepts a Optional value to cache the result.
|
||||
bool getBooleanOption(llvm::Optional<bool> &V, StringRef Name,
|
||||
bool DefaultVal);
|
||||
|
||||
/// Interprets an option's string value as an integer value.
|
||||
int getOptionAsInteger(llvm::StringRef Name, int DefaultVal);
|
||||
|
||||
|
|
|
@ -64,44 +64,42 @@ bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) {
|
|||
.Default(DefaultVal);
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::getBooleanOption(llvm::Optional<bool> &V,
|
||||
StringRef Name,
|
||||
bool DefaultVal) {
|
||||
if (!V.hasValue())
|
||||
V = getBooleanOption(Name, DefaultVal);
|
||||
return V.getValue();
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
|
||||
if (!IncludeTemporaryDtorsInCFG.hasValue())
|
||||
const_cast<llvm::Optional<bool> &>(IncludeTemporaryDtorsInCFG) =
|
||||
getBooleanOption("cfg-temporary-dtors", /*Default=*/false);
|
||||
|
||||
return *IncludeTemporaryDtorsInCFG;
|
||||
return getBooleanOption(IncludeTemporaryDtorsInCFG,
|
||||
"cfg-temporary-dtors",
|
||||
/* Default = */ false);
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
|
||||
if (!InlineCXXStandardLibrary.hasValue())
|
||||
const_cast<llvm::Optional<bool> &>(InlineCXXStandardLibrary) =
|
||||
getBooleanOption("c++-stdlib-inlining", /*Default=*/true);
|
||||
|
||||
return *InlineCXXStandardLibrary;
|
||||
return getBooleanOption(InlineCXXStandardLibrary,
|
||||
"c++-stdlib-inlining",
|
||||
/*Default=*/true);
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::mayInlineTemplateFunctions() {
|
||||
if (!InlineTemplateFunctions.hasValue())
|
||||
const_cast<llvm::Optional<bool> &>(InlineTemplateFunctions) =
|
||||
getBooleanOption("c++-template-inlining", /*Default=*/true);
|
||||
|
||||
return *InlineTemplateFunctions;
|
||||
return getBooleanOption(InlineTemplateFunctions,
|
||||
"c++-template-inlining",
|
||||
/*Default=*/true);
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::mayInlineObjCMethod() {
|
||||
if (!ObjCInliningMode.hasValue())
|
||||
const_cast<llvm::Optional<bool> &>(ObjCInliningMode) =
|
||||
getBooleanOption("objc-inlining", /*Default=*/true);
|
||||
|
||||
return *ObjCInliningMode;
|
||||
return getBooleanOption(ObjCInliningMode,
|
||||
"objc-inlining",
|
||||
/* Default = */ true);
|
||||
}
|
||||
|
||||
bool AnalyzerOptions::shouldPruneNullReturnPaths() {
|
||||
if (!PruneNullReturnPaths.hasValue())
|
||||
const_cast<llvm::Optional<bool> &>(PruneNullReturnPaths) =
|
||||
getBooleanOption("suppress-null-return-paths", /*Default=*/true);
|
||||
|
||||
return *PruneNullReturnPaths;
|
||||
return getBooleanOption(PruneNullReturnPaths,
|
||||
"suppress-null-return-paths",
|
||||
/* Default = */ true);
|
||||
}
|
||||
|
||||
int AnalyzerOptions::getOptionAsInteger(StringRef Name, int DefaultVal) {
|
||||
|
|
Loading…
Reference in New Issue