diff options
author | Anna Zaks <ganna@apple.com> | 2013-01-24 23:15:34 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-01-24 23:15:34 +0000 |
commit | 36d988f02356a0cbbee86b67830cd3bba2b0241c (patch) | |
tree | ce29d059350e09f4c282e1fa4c9b702ab9700d53 /clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | |
parent | 6bab4ef4e83ffd7f42e00b5ead2bcfead78b51b4 (diff) | |
download | bcm5719-llvm-36d988f02356a0cbbee86b67830cd3bba2b0241c.tar.gz bcm5719-llvm-36d988f02356a0cbbee86b67830cd3bba2b0241c.zip |
[analyzer] Add "-analyzer-config mode=[deep|shallow] ".
The idea is to introduce a higher level "user mode" option for
different use scenarios. For example, if one wants to run the analyzer
for a small project each time the code is built, they would use
the "shallow" mode.
The user mode option will influence the default settings for the
lower-level analyzer options. For now, this just influences the ipa
modes, but we plan to find more optimal settings for them.
llvm-svn: 173386
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp index 107b739c170..c5a69aea5ca 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -20,12 +20,34 @@ using namespace clang; using namespace llvm; +AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() { + if (UserMode == UMK_NotSet) { + StringRef ModeStr(Config.GetOrCreateValue("mode", "deep").getValue()); + UserMode = llvm::StringSwitch<UserModeKind>(ModeStr) + .Case("shallow", UMK_Shallow) + .Case("deep", UMK_Deep) + .Default(UMK_NotSet); + assert(UserMode != UMK_NotSet && "User mode is not set or invalid."); + } + return UserMode; +} + IPAKind AnalyzerOptions::getIPAMode() { if (IPAMode == IPAK_NotSet) { + // Use the User Mode to set the default IPA value. + // Note, we have to add the string to the Config map for the ConfigDumper + // checker to function properly. + const char *DefaultIPA = 0; + UserModeKind HighLevelMode = getUserMode(); + if (HighLevelMode == UMK_Shallow) + DefaultIPA = "basic-inlining"; + else if (HighLevelMode == UMK_Deep) + DefaultIPA = "dynamic-bifurcate"; + assert(DefaultIPA); + // Lookup the ipa configuration option, use the default from User Mode. - StringRef ModeStr(Config.GetOrCreateValue("ipa", - "dynamic-bifurcate").getValue()); + StringRef ModeStr(Config.GetOrCreateValue("ipa", DefaultIPA).getValue()); IPAKind IPAConfig = llvm::StringSwitch<IPAKind>(ModeStr) .Case("none", IPAK_None) .Case("basic-inlining", IPAK_BasicInlining) |