[cfe-commits] r81501 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Frontend/Analyses.def lib/Analysis/CallInliner.cpp lib/Frontend/AnalysisConsumer.cpp

Zhongxing Xu xuzhongxing at gmail.com
Thu Sep 10 21:13:45 PDT 2009


Author: zhongxingxu
Date: Thu Sep 10 23:13:42 2009
New Revision: 81501

URL: http://llvm.org/viewvc/llvm-project?rev=81501&view=rev
Log:
Start to add a new transfer function that inlines callee. To be continued.

Added:
    cfe/trunk/lib/Analysis/CallInliner.cpp
Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
    cfe/trunk/include/clang/Frontend/Analyses.def
    cfe/trunk/lib/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=81501&r1=81500&r2=81501&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Thu Sep 10 23:13:42 2009
@@ -81,6 +81,8 @@
   }
 };
 
+GRTransferFuncs *CreateCallInliner(ASTContext &ctx);
+
 } // end clang namespace
 
 #endif

Modified: cfe/trunk/include/clang/Frontend/Analyses.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Analyses.def?rev=81501&r1=81500&r2=81501&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/Analyses.def (original)
+++ cfe/trunk/include/clang/Frontend/Analyses.def Thu Sep 10 23:13:42 2009
@@ -48,6 +48,10 @@
 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

Added: cfe/trunk/lib/Analysis/CallInliner.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallInliner.cpp?rev=81501&view=auto

==============================================================================
--- cfe/trunk/lib/Analysis/CallInliner.cpp (added)
+++ cfe/trunk/lib/Analysis/CallInliner.cpp Thu Sep 10 23:13:42 2009
@@ -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);
+}

Modified: cfe/trunk/lib/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/AnalysisConsumer.cpp?rev=81501&r1=81500&r2=81501&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/AnalysisConsumer.cpp Thu Sep 10 23:13:42 2009
@@ -412,6 +412,28 @@
   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.
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list