summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-10 21:27:35 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-10 21:27:35 +0000
commit1e0e4001c83db629cfb0f38157379fa09bef6cb4 (patch)
tree1efd546bd0d1fa836b6a716858ffdb590432b1f5 /clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
parentca1e27be0deda2a163bb7817fcd80c29d415544f (diff)
downloadbcm5719-llvm-1e0e4001c83db629cfb0f38157379fa09bef6cb4.tar.gz
bcm5719-llvm-1e0e4001c83db629cfb0f38157379fa09bef6cb4.zip
[analyzer] For now, don't inline C++ standard library functions.
This is a (heavy-handed) solution to PR13724 -- until we know we can do a good job inlining the STL, it's best to be consistent and not generate more false positives than we did before. We can selectively whitelist certain parts of the 'std' namespace that are known to be safe. This is controlled by analyzer config option 'c++-stdlib-inlining', which can be set to "true" or "false". This commit also adds control for whether or not to inline any templated functions (member or non-member), under the config option 'c++-template-inlining'. This option is currently on by default. llvm-svn: 163548
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 9e45a115283..b410890f8ee 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -47,6 +47,36 @@ AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const {
return CXXMemberInliningMode >= K;
}
+bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) 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>(Config.lookup(Name))
+ .Case("true", true)
+ .Case("false", false)
+ .Default(DefaultVal);
+}
+
bool AnalyzerOptions::includeTemporaryDtorsInCFG() const {
- return !Config.lookup("cfg-temporary-dtors").empty();
+ if (!IncludeTemporaryDtorsInCFG.hasValue())
+ const_cast<llvm::Optional<bool> &>(IncludeTemporaryDtorsInCFG) =
+ getBooleanOption("cfg-temporary-dtors");
+
+ return *IncludeTemporaryDtorsInCFG;
+}
+
+bool AnalyzerOptions::mayInlineCXXStandardLibrary() const {
+ if (!InlineCXXStandardLibrary.hasValue())
+ const_cast<llvm::Optional<bool> &>(InlineCXXStandardLibrary) =
+ getBooleanOption("c++-stdlib-inlining");
+
+ return *InlineCXXStandardLibrary;
+}
+
+bool AnalyzerOptions::mayInlineTemplateFunctions() const {
+ if (!InlineTemplateFunctions.hasValue())
+ const_cast<llvm::Optional<bool> &>(InlineTemplateFunctions) =
+ getBooleanOption("c++-template-inlining", /*Default=*/true);
+
+ return *InlineTemplateFunctions;
}
OpenPOWER on IntegriCloud