summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-09-10 22:37:19 +0000
committerAnna Zaks <ganna@apple.com>2012-09-10 22:37:19 +0000
commit14ce52492f4002c743e27dca48d02e7e9bfcf61c (patch)
treefd58a8a4e5ba34482f59bf39d4f7521f4910b701 /clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
parent41ff85d7541960a7b5bec74c15835d48881a9a3a (diff)
downloadbcm5719-llvm-14ce52492f4002c743e27dca48d02e7e9bfcf61c.tar.gz
bcm5719-llvm-14ce52492f4002c743e27dca48d02e7e9bfcf61c.zip
[analyzer] Add ipa-always-inline-size option (with 3 as the default).
The option allows to always inline very small functions, whose size (in number of basic blocks) is set using -analyzer-config ipa-always-inline-size option. llvm-svn: 163558
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 29e27834763..5cbbb8d4628 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
+using namespace llvm;
bool
AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const {
@@ -80,3 +81,26 @@ bool AnalyzerOptions::mayInlineTemplateFunctions() const {
return *InlineTemplateFunctions;
}
+
+int AnalyzerOptions::getOptionAsInteger(StringRef Name, int DefaultVal) const {
+ std::string OptStr = Config.lookup(Name);
+ if (OptStr.empty())
+ return DefaultVal;
+
+ int Res = DefaultVal;
+ assert(StringRef(OptStr).getAsInteger(10, Res) == false &&
+ "analyzer-config option should be numeric.");
+
+ return Res;
+}
+
+unsigned AnalyzerOptions::getAlwaysInlineSize() const {
+ if (!AlwaysInlineSize.hasValue()) {
+ unsigned DefaultSize = 3;
+ Optional<unsigned> &MutableOption =
+ const_cast<Optional<unsigned> &>(AlwaysInlineSize);
+ MutableOption = getOptionAsInteger("ipa-always-inline-size", DefaultSize);
+ }
+
+ return AlwaysInlineSize.getValue();
+}
OpenPOWER on IntegriCloud