aboutsummaryrefslogtreecommitdiff
path: root/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
commit7229d0011766c174beffe6a846d78f448f845b39 (patch)
treec6c004f9d5ac847f1fda118d9b38301aef304d16 /lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
parent654f1d508cbc9553f4931b340dfa19b453f72ebd (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/AnalyzerOptions.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 29e2783476..5cbbb8d462 100644
--- a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/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();
+}