diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-10-01 18:28:19 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-10-01 18:28:19 +0000 |
commit | 622b6fb0a1d280c16e135c7e427b79cafffbde1f (patch) | |
tree | ed546fdae1b950bb96b131078813e1ca63e05f3b /lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | |
parent | 43e8ef0b90dffcf9bda4fc2d3e6b21feb1e15bfb (diff) |
Have AnalyzerOptions::getBooleanOption() stick the matching config
string in the config table so that it can be dumped as part of the
config dumper. Add a test to show that these options are sticking
and can be cross-checked using FileCheck.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp index 1ffd105766..7e6013bba8 100644 --- a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -48,17 +48,20 @@ AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const { return CXXMemberInliningMode >= K; } -bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) const { +static StringRef toString(bool b) { return b ? "true" : "false"; } + +bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) { // 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>(Config.lookup(Name)) - .Case("true", true) - .Case("false", false) - .Default(DefaultVal); + StringRef V(Config.GetOrCreateValue(Name, toString(DefaultVal)).getValue()); + return llvm::StringSwitch<bool>(V) + .Case("true", true) + .Case("false", false) + .Default(DefaultVal); } -bool AnalyzerOptions::includeTemporaryDtorsInCFG() const { +bool AnalyzerOptions::includeTemporaryDtorsInCFG() { if (!IncludeTemporaryDtorsInCFG.hasValue()) const_cast<llvm::Optional<bool> &>(IncludeTemporaryDtorsInCFG) = getBooleanOption("cfg-temporary-dtors", /*Default=*/false); @@ -66,7 +69,7 @@ bool AnalyzerOptions::includeTemporaryDtorsInCFG() const { return *IncludeTemporaryDtorsInCFG; } -bool AnalyzerOptions::mayInlineCXXStandardLibrary() const { +bool AnalyzerOptions::mayInlineCXXStandardLibrary() { if (!InlineCXXStandardLibrary.hasValue()) const_cast<llvm::Optional<bool> &>(InlineCXXStandardLibrary) = getBooleanOption("c++-stdlib-inlining", /*Default=*/true); @@ -74,7 +77,7 @@ bool AnalyzerOptions::mayInlineCXXStandardLibrary() const { return *InlineCXXStandardLibrary; } -bool AnalyzerOptions::mayInlineTemplateFunctions() const { +bool AnalyzerOptions::mayInlineTemplateFunctions() { if (!InlineTemplateFunctions.hasValue()) const_cast<llvm::Optional<bool> &>(InlineTemplateFunctions) = getBooleanOption("c++-template-inlining", /*Default=*/true); @@ -82,7 +85,7 @@ bool AnalyzerOptions::mayInlineTemplateFunctions() const { return *InlineTemplateFunctions; } -bool AnalyzerOptions::mayInlineObjCMethod() const { +bool AnalyzerOptions::mayInlineObjCMethod() { if (!ObjCInliningMode.hasValue()) const_cast<llvm::Optional<bool> &>(ObjCInliningMode) = getBooleanOption("objc-inlining", /*Default=*/true); @@ -90,7 +93,7 @@ bool AnalyzerOptions::mayInlineObjCMethod() const { return *ObjCInliningMode; } -bool AnalyzerOptions::shouldPruneNullReturnPaths() const { +bool AnalyzerOptions::shouldPruneNullReturnPaths() { if (!PruneNullReturnPaths.hasValue()) const_cast<llvm::Optional<bool> &>(PruneNullReturnPaths) = getBooleanOption("suppress-null-return-paths", /*Default=*/true); @@ -120,6 +123,6 @@ unsigned AnalyzerOptions::getAlwaysInlineSize() const { return AlwaysInlineSize.getValue(); } -bool AnalyzerOptions::shouldSynthesizeBodies() const { +bool AnalyzerOptions::shouldSynthesizeBodies() { return getBooleanOption("faux-bodies", true); } |