summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-05-06 02:59:29 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-05-06 02:59:29 +0000
commit9174b2c2f9251db08fea0c4e48372b9a599f57af (patch)
tree13c7afba2093214a1b5b820c3f4b6fb5bc0c5de9 /clang
parent9feb1bb11727cb79a71015fd950473269bcdafd6 (diff)
downloadbcm5719-llvm-9174b2c2f9251db08fea0c4e48372b9a599f57af.tar.gz
bcm5719-llvm-9174b2c2f9251db08fea0c4e48372b9a599f57af.zip
Make -analyzer-inline-call not a separate analysis. Instead it's a boolean
flag now, and can be used with other analyses. Only turned it on for C++ methods for now. llvm-svn: 103160
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Checker/PathSensitive/AnalysisManager.h8
-rw-r--r--clang/include/clang/Driver/CC1Options.td4
-rw-r--r--clang/include/clang/Frontend/AnalysisConsumer.h2
-rw-r--r--clang/lib/Checker/GRCXXExprEngine.cpp4
-rw-r--r--clang/lib/Frontend/AnalysisConsumer.cpp2
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp1
-rw-r--r--clang/test/Analysis/method-call.cpp2
7 files changed, 15 insertions, 8 deletions
diff --git a/clang/include/clang/Checker/PathSensitive/AnalysisManager.h b/clang/include/clang/Checker/PathSensitive/AnalysisManager.h
index 0c59d7b572a..9194f458990 100644
--- a/clang/include/clang/Checker/PathSensitive/AnalysisManager.h
+++ b/clang/include/clang/Checker/PathSensitive/AnalysisManager.h
@@ -52,19 +52,21 @@ class AnalysisManager : public BugReporterData {
// bifurcates paths.
bool EagerlyAssume;
bool TrimGraph;
+ bool InlineCall;
public:
AnalysisManager(ASTContext &ctx, Diagnostic &diags,
const LangOptions &lang, PathDiagnosticClient *pd,
StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr, unsigned maxnodes,
- bool vizdot, bool vizubi, bool purge, bool eager, bool trim)
+ bool vizdot, bool vizubi, bool purge, bool eager, bool trim,
+ bool inlinecall)
: Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
AScope(ScopeDecl), MaxNodes(maxnodes),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
- EagerlyAssume(eager), TrimGraph(trim) {}
+ EagerlyAssume(eager), TrimGraph(trim), InlineCall(inlinecall) {}
~AnalysisManager() { FlushDiagnostics(); }
@@ -122,6 +124,8 @@ public:
bool shouldEagerlyAssume() const { return EagerlyAssume; }
+ bool shouldInlineCall() const { return InlineCall; }
+
CFG *getCFG(Decl const *D) {
return AnaCtxMgr.getContext(D)->getCFG();
}
diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td
index 8e8eacb9c31..9ac6ad39ebf 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -56,8 +56,6 @@ def analysis_ObjCMemChecker : Flag<"-analyzer-check-objc-mem">,
HelpText<"Run the [Core] Foundation reference count checker">;
def analysis_WarnSizeofPointer : Flag<"-warn-sizeof-pointer">,
HelpText<"Warn about unintended use of sizeof() on pointer expressions">;
-def analysis_InlineCall : Flag<"-inline-call">,
- HelpText<"Experimental transfer function inlining callees when its definition is available.">;
def analyzer_store : Separate<"-analyzer-store">,
HelpText<"Source Code Analysis - Abstract Memory Store Models">;
@@ -97,6 +95,8 @@ def analyzer_viz_egraph_graphviz : Flag<"-analyzer-viz-egraph-graphviz">,
HelpText<"Display exploded graph using GraphViz">;
def analyzer_viz_egraph_ubigraph : Flag<"-analyzer-viz-egraph-ubigraph">,
HelpText<"Display exploded graph using Ubigraph">;
+def analyzer_inline_call : Flag<"-analyzer-inline-call">,
+ HelpText<"Experimental transfer function inlining callees when its definition is available.">;
def analyzer_max_nodes : Separate<"-analyzer-max-nodes">,
HelpText<"The maximum number of nodes the analyzer can generate">;
diff --git a/clang/include/clang/Frontend/AnalysisConsumer.h b/clang/include/clang/Frontend/AnalysisConsumer.h
index 3341bb01f0f..5dd80142eed 100644
--- a/clang/include/clang/Frontend/AnalysisConsumer.h
+++ b/clang/include/clang/Frontend/AnalysisConsumer.h
@@ -71,6 +71,8 @@ public:
unsigned VisualizeEGUbi : 1;
unsigned EnableExperimentalChecks : 1;
unsigned EnableExperimentalInternalChecks : 1;
+ unsigned InlineCall : 1;
+
public:
AnalyzerOptions() {
AnalysisStoreOpt = BasicStoreModel;
diff --git a/clang/lib/Checker/GRCXXExprEngine.cpp b/clang/lib/Checker/GRCXXExprEngine.cpp
index 00ac9955928..18e112cc8d3 100644
--- a/clang/lib/Checker/GRCXXExprEngine.cpp
+++ b/clang/lib/Checker/GRCXXExprEngine.cpp
@@ -86,7 +86,7 @@ void GRExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E, SVal Dest,
const CXXConstructorDecl *CD = E->getConstructor();
assert(CD);
- if (!CD->isThisDeclarationADefinition())
+ if (!(CD->isThisDeclarationADefinition() && AMgr.shouldInlineCall()))
// FIXME: invalidate the object.
return;
@@ -147,7 +147,7 @@ void GRExprEngine::VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE,
const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl());
assert(MD && "not a CXXMethodDecl?");
- if (!MD->isThisDeclarationADefinition())
+ if (!(MD->isThisDeclarationADefinition() && AMgr.shouldInlineCall()))
// FIXME: conservative method call evaluation.
return;
diff --git a/clang/lib/Frontend/AnalysisConsumer.cpp b/clang/lib/Frontend/AnalysisConsumer.cpp
index 87c3fca2496..df74eadaa0a 100644
--- a/clang/lib/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/Frontend/AnalysisConsumer.cpp
@@ -177,7 +177,7 @@ public:
Opts.MaxNodes,
Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
Opts.PurgeDead, Opts.EagerlyAssume,
- Opts.TrimGraph));
+ Opts.TrimGraph, Opts.InlineCall));
}
virtual void HandleTranslationUnit(ASTContext &C);
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index e1275c16fe9..92f33d01be0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -797,6 +797,7 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Args.hasArg(OPT_analyzer_experimental_internal_checks);
Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
Opts.MaxNodes = getLastArgIntValue(Args, OPT_analyzer_max_nodes,150000,Diags);
+ Opts.InlineCall = Args.hasArg(OPT_analyzer_inline_call);
}
static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
diff --git a/clang/test/Analysis/method-call.cpp b/clang/test/Analysis/method-call.cpp
index dd891596c5d..47f14447d6b 100644
--- a/clang/test/Analysis/method-call.cpp
+++ b/clang/test/Analysis/method-call.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
struct A {
int x;
A(int a) { x = a; }
OpenPOWER on IntegriCloud