diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-21 21:44:21 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-21 21:44:21 +0000 |
commit | c568e2f801a62e442cbbd823b71f70175715661f (patch) | |
tree | 003b85c5413608402681a8e392fd40466acb6558 /lib | |
parent | ee04959f88e26ed38dccf4aed2ff10cad1f703c9 (diff) |
[analyzer] Set the default IPA mode to 'basic-inlining', which excludes C++.
Under -analyzer-ipa=basic-inlining, only C functions, blocks, and C++ static
member functions are inlined -- essentially, the calls that behave like simple
C function calls. This is essentially the behavior in Xcode 4.4.
C++ support still has some rough edges, and we don't want users to be worried
about them if they download and run their own checker. (In particular, the
massive number of false positives for analyzing LLVM comes from inlining
defensively-written code in contexts where more aggressive assumptions are
implicitly made. This problem is not unique to C++, but it is exacerbated by
the higher proportion of code that lives in header files in C++.)
The eventual goal is to be comfortable enough with C++ support (and simple
Objective-C support) to advance to -analyzer-ipa=inlining as the default
behavior. See the IPA design notes for more details.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 2 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 24 |
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 09e95ce693..95f9c38828 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -147,7 +147,7 @@ static void AnalyzerOptsToArgs(const AnalyzerOptions &Opts, ToArgsList &Res) { getAnalysisPurgeModeName(Opts.AnalysisPurgeOpt)); if (!Opts.AnalyzeSpecificFunction.empty()) Res.push_back("-analyze-function", Opts.AnalyzeSpecificFunction); - if (Opts.IPAMode != Inlining) + if (Opts.IPAMode != BasicInlining) Res.push_back("-analyzer-ipa", getAnalysisIPAModeName(Opts.IPAMode)); if (Opts.InliningMode != NoRedundancy) Res.push_back("-analyzer-inlining-mode", diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 3b2e4ec824..62e93b132e 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -22,8 +22,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Support/SaveAndRestore.h" -#define CXX_INLINING_ENABLED 1 - using namespace clang; using namespace ento; @@ -305,6 +303,20 @@ template<> struct ProgramStateTrait<DynamicDispatchBifurcationMap> }} +static bool shouldInlineCXX(AnalysisManager &AMgr) { + switch (AMgr.IPAMode) { + case None: + case BasicInlining: + return false; + case Inlining: + case DynamicDispatch: + case DynamicDispatchBifurcate: + return true; + case NumIPAModes: + llvm_unreachable("not actually a valid option"); + } +} + bool ExprEngine::inlineCall(const CallEvent &Call, const Decl *D, NodeBuilder &Bldr, ExplodedNode *Pred, ProgramStateRef State) { @@ -320,11 +332,11 @@ bool ExprEngine::inlineCall(const CallEvent &Call, const Decl *D, break; case CE_CXXMember: case CE_CXXMemberOperator: - if (!CXX_INLINING_ENABLED) + if (!shouldInlineCXX(getAnalysisManager())) return false; break; case CE_CXXConstructor: { - if (!CXX_INLINING_ENABLED) + if (!shouldInlineCXX(getAnalysisManager())) return false; // Only inline constructors and destructors if we built the CFGs for them @@ -351,7 +363,7 @@ bool ExprEngine::inlineCall(const CallEvent &Call, const Decl *D, break; } case CE_CXXDestructor: { - if (!CXX_INLINING_ENABLED) + if (!shouldInlineCXX(getAnalysisManager())) return false; // Only inline constructors and destructors if we built the CFGs for them @@ -371,7 +383,7 @@ bool ExprEngine::inlineCall(const CallEvent &Call, const Decl *D, break; } case CE_CXXAllocator: - if (!CXX_INLINING_ENABLED) + if (!shouldInlineCXX(getAnalysisManager())) return false; // Do not inline allocators until we model deallocators. |