From 622b6fb0a1d280c16e135c7e427b79cafffbde1f Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 1 Oct 2012 18:28:19 +0000 Subject: 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 --- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/StaticAnalyzer/Core/AnalyzerOptions.cpp') 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(Config.lookup(Name)) - .Case("true", true) - .Case("false", false) - .Default(DefaultVal); + StringRef V(Config.GetOrCreateValue(Name, toString(DefaultVal)).getValue()); + return llvm::StringSwitch(V) + .Case("true", true) + .Case("false", false) + .Default(DefaultVal); } -bool AnalyzerOptions::includeTemporaryDtorsInCFG() const { +bool AnalyzerOptions::includeTemporaryDtorsInCFG() { if (!IncludeTemporaryDtorsInCFG.hasValue()) const_cast &>(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 &>(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 &>(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 &>(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 &>(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); } -- cgit v1.2.3-18-g5258