]> granicus.if.org Git - clang/commitdiff
Start to add a new transfer function that inlines callee. To be continued.
authorZhongxing Xu <xuzhongxing@gmail.com>
Fri, 11 Sep 2009 04:13:42 +0000 (04:13 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Fri, 11 Sep 2009 04:13:42 +0000 (04:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81501 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRTransferFuncs.h
include/clang/Frontend/Analyses.def
lib/Analysis/CallInliner.cpp [new file with mode: 0644]
lib/Frontend/AnalysisConsumer.cpp

index a3bb8bad842649a4f63d32c6d73b7cf046cad747..5f7b2cb0e327e5f6346316799a9875750458f666 100644 (file)
@@ -81,6 +81,8 @@ public:
   }
 };
 
+GRTransferFuncs *CreateCallInliner(ASTContext &ctx);
+
 } // end clang namespace
 
 #endif
index 173ed135fcf2ebb6327453e6765294ab7bff503b..d5e408020a987053f41e9f979639c9461f491270 100644 (file)
@@ -48,6 +48,10 @@ ANALYSIS(WarnObjCUnusedIvars, "warn-objc-unused-ivars",
 ANALYSIS(CheckerCFRef, "checker-cfref",
          "Run the [Core] Foundation reference count checker", Code)
 
+ANALYSIS(InlineCall, "inline-call",
+         "Experimental transfer function inling callees when its definition"
+         " is available.", TranslationUnit)
+
 #ifndef ANALYSIS_STORE
 #define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)
 #endif
diff --git a/lib/Analysis/CallInliner.cpp b/lib/Analysis/CallInliner.cpp
new file mode 100644 (file)
index 0000000..344d14d
--- /dev/null
@@ -0,0 +1,41 @@
+//===--- CallInliner.cpp - Transfer function that inlines callee ----------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file implements the callee inlining transfer function.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+
+using namespace clang;
+
+namespace {
+  
+class VISIBILITY_HIDDEN CallInliner : public GRTransferFuncs {
+  ASTContext &Ctx;
+public:
+  CallInliner(ASTContext &ctx) : Ctx(ctx) {}
+
+  void EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
+                GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L,
+                ExplodedNode* Pred);
+  
+};
+
+}
+
+void CallInliner::EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
+                           GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L,
+                           ExplodedNode* Pred) {
+  assert(0 && "TO BE IMPLEMENTED");
+}
+  
+GRTransferFuncs *clang::CreateCallInliner(ASTContext &ctx) {
+  return new CallInliner(ctx);
+}
index 67328da66131bd854ed8184a10ee5aa1a0f7d552..034ff93f412601bec4df493c89cf5d2eaa95e35f 100644 (file)
@@ -412,6 +412,28 @@ static void ActionWarnObjCMethSigs(AnalysisManager& mgr, Decl *D) {
   CheckObjCInstMethSignature(cast<ObjCImplementationDecl>(D), BR);
 }
 
+static void ActionInlineCall(AnalysisManager &mgr, Decl *D) {
+  if (!D)
+    return;
+
+  llvm::OwningPtr<GRTransferFuncs> TF(CreateCallInliner(mgr.getASTContext()));
+
+  // Construct the analysis engine.
+  GRExprEngine Eng(mgr);
+
+  Eng.setTransferFunctions(TF.get());
+  
+  Eng.RegisterInternalChecks();
+  RegisterAppleChecks(Eng, *D);
+
+  // Execute the worklist algorithm.
+  Eng.ExecuteWorkList(mgr.getStackFrame(D));
+  
+  // Visualize the exploded graph.
+  if (mgr.shouldVisualizeGraphviz())
+    Eng.ViewGraph(mgr.shouldTrimGraph());
+}
+
 //===----------------------------------------------------------------------===//
 // AnalysisConsumer creation.
 //===----------------------------------------------------------------------===//