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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103160 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Checker/PathSensitive/AnalysisManager.h b/include/clang/Checker/PathSensitive/AnalysisManager.h
index 0c59d7b..9194f45 100644
--- a/include/clang/Checker/PathSensitive/AnalysisManager.h
+++ b/include/clang/Checker/PathSensitive/AnalysisManager.h
@@ -52,19 +52,21 @@
   //   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 @@
 
   bool shouldEagerlyAssume() const { return EagerlyAssume; }
 
+  bool shouldInlineCall() const { return InlineCall; }
+
   CFG *getCFG(Decl const *D) {
     return AnaCtxMgr.getContext(D)->getCFG();
   }
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 8e8eacb..9ac6ad3 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -56,8 +56,6 @@
   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 @@
   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/include/clang/Frontend/AnalysisConsumer.h b/include/clang/Frontend/AnalysisConsumer.h
index 3341bb0..5dd8014 100644
--- a/include/clang/Frontend/AnalysisConsumer.h
+++ b/include/clang/Frontend/AnalysisConsumer.h
@@ -71,6 +71,8 @@
   unsigned VisualizeEGUbi : 1;
   unsigned EnableExperimentalChecks : 1;
   unsigned EnableExperimentalInternalChecks : 1;
+  unsigned InlineCall : 1;
+
 public:
   AnalyzerOptions() {
     AnalysisStoreOpt = BasicStoreModel;
diff --git a/lib/Checker/GRCXXExprEngine.cpp b/lib/Checker/GRCXXExprEngine.cpp
index 00ac995..18e112c 100644
--- a/lib/Checker/GRCXXExprEngine.cpp
+++ b/lib/Checker/GRCXXExprEngine.cpp
@@ -86,7 +86,7 @@
   const CXXConstructorDecl *CD = E->getConstructor();
   assert(CD);
 
-  if (!CD->isThisDeclarationADefinition())
+  if (!(CD->isThisDeclarationADefinition() && AMgr.shouldInlineCall()))
     // FIXME: invalidate the object.
     return;
 
@@ -147,7 +147,7 @@
   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/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp
index 87c3fca..df74ead 100644
--- a/lib/Frontend/AnalysisConsumer.cpp
+++ b/lib/Frontend/AnalysisConsumer.cpp
@@ -177,7 +177,7 @@
                                   Opts.MaxNodes,
                                   Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
                                   Opts.PurgeDead, Opts.EagerlyAssume,
-                                  Opts.TrimGraph));
+                                  Opts.TrimGraph, Opts.InlineCall));
   }
 
   virtual void HandleTranslationUnit(ASTContext &C);
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index e1275c1..92f33d0 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -797,6 +797,7 @@
     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/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp
index dd89159..47f1444 100644
--- a/test/Analysis/method-call.cpp
+++ b/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; }