[cfe-commits] r103161 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRExprEngine.h lib/Checker/GRExprEngine.cpp test/Analysis/inline.c test/Analysis/inline2.c test/Analysis/inline3.c test/Analysis/inline4.c

Zhongxing Xu xuzhongxing at gmail.com
Wed May 5 20:38:28 PDT 2010


Author: zhongxingxu
Date: Wed May  5 22:38:27 2010
New Revision: 103161

URL: http://llvm.org/viewvc/llvm-project?rev=103161&view=rev
Log:
Turn -analyzer-inline-call on for C functions. This also fixed a bug that
after inlining post-call checking shouldn't be done.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
    cfe/trunk/lib/Checker/GRExprEngine.cpp
    cfe/trunk/test/Analysis/inline.c
    cfe/trunk/test/Analysis/inline2.c
    cfe/trunk/test/Analysis/inline3.c
    cfe/trunk/test/Analysis/inline4.c

Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Wed May  5 22:38:27 2010
@@ -456,6 +456,8 @@
   void EvalLocation(ExplodedNodeSet &Dst, Stmt *S, ExplodedNode* Pred,
                     const GRState* St, SVal location,
                     const void *tag, bool isLoad);
+
+  bool InlineCall(ExplodedNodeSet &Dst, const CallExpr *CE, ExplodedNode *Pred);
 };
 
 } // end clang namespace

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed May  5 22:38:27 2010
@@ -1810,6 +1810,28 @@
   }
 }
 
+bool GRExprEngine::InlineCall(ExplodedNodeSet &Dst, const CallExpr *CE, 
+                              ExplodedNode *Pred) {
+  const GRState *state = GetState(Pred);
+  const Expr *Callee = CE->getCallee();
+  SVal L = state->getSVal(Callee);
+  
+  const FunctionDecl *FD = L.getAsFunctionDecl();
+  if (!FD)
+    return false;
+
+  if (!FD->getBody(FD))
+    return false;
+
+  // Now we have the definition of the callee, create a CallEnter node.
+  CallEnter Loc(CE, FD, Pred->getLocationContext());
+
+  ExplodedNode *N = Builder->generateNode(Loc, state, Pred);
+  if (N)
+    Dst.Add(N);
+  return true;
+}
+
 void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
                              CallExpr::arg_iterator AI,
                              CallExpr::arg_iterator AE,
@@ -1889,6 +1911,10 @@
     // If the callee is processed by a checker, skip the rest logic.
     if (CheckerEvalCall(CE, DstChecker, *DI))
       DstTmp3.insert(DstChecker);
+    else if (AMgr.shouldInlineCall() && InlineCall(Dst, CE, *DI)) {
+      // Callee is inlined. We shouldn't do post call checking.
+      return;
+    }
     else {
       for (ExplodedNodeSet::iterator DI_Checker = DstChecker.begin(),
            DE_Checker = DstChecker.end();

Modified: cfe/trunk/test/Analysis/inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inline.c?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inline.c (original)
+++ cfe/trunk/test/Analysis/inline.c Wed May  5 22:38:27 2010
@@ -1,5 +1,5 @@
-// RUN: false
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
+
 int f1() {
   int y = 1;
   y++;

Modified: cfe/trunk/test/Analysis/inline2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inline2.c?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inline2.c (original)
+++ cfe/trunk/test/Analysis/inline2.c Wed May  5 22:38:27 2010
@@ -1,5 +1,4 @@
-// RUN: false
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
 
 // Test parameter 'a' is registered to LiveVariables analysis data although it
 // is not referenced in the function body. 

Modified: cfe/trunk/test/Analysis/inline3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inline3.c?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inline3.c (original)
+++ cfe/trunk/test/Analysis/inline3.c Wed May  5 22:38:27 2010
@@ -1,5 +1,4 @@
-// RUN: false
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
 
 // Test when entering f1(), we set the right AnalysisContext to Environment.
 // Otherwise, block-level expr '1 && a' would not be block-level.

Modified: cfe/trunk/test/Analysis/inline4.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inline4.c?rev=103161&r1=103160&r2=103161&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/inline4.c (original)
+++ cfe/trunk/test/Analysis/inline4.c Wed May  5 22:38:27 2010
@@ -1,5 +1,5 @@
-// RUN: false
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
+
 int g(int a) {    
   return a;
 }





More information about the cfe-commits mailing list