]> granicus.if.org Git - clang/commitdiff
Turn -analyzer-inline-call on for C functions. This also fixed a bug that
authorZhongxing Xu <xuzhongxing@gmail.com>
Thu, 6 May 2010 03:38:27 +0000 (03:38 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Thu, 6 May 2010 03:38:27 +0000 (03:38 +0000)
after inlining post-call checking shouldn't be done.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103161 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f04ca75084b7f190384d4a204cc33074afd9b3ba..ac407f6933c860e0f8ebd45d57d5d0cba7853b77 100644 (file)
@@ -456,6 +456,8 @@ private:
   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
index 67090b86694fb88ff75a870bd565615867c3f3b9..b7b48d70de75ca8ead1f0cdba862e8534336caf0 100644 (file)
@@ -1810,6 +1810,28 @@ void GRExprEngine::EvalLocation(ExplodedNodeSet &Dst, Stmt *S,
   }
 }
 
+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 @@ void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
     // 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();
index acaf74ded996acb93bcd4bb7506c0d813d800b92..50c1a54d1016c3f95380c94257616869ad8b64b8 100644 (file)
@@ -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++;
index ec965a69c64470eb760ed3f204dcda3f774da584..efdb75cc6535d6e2a524372292f33cd8532c8bdf 100644 (file)
@@ -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. 
index 8f45858bb949ed8e3935a07d2025dd95606a65b0..884b3ed9dc25dd2d2a218240d71ae6ce1146a1d1 100644 (file)
@@ -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.
index b2b3c346e374034cb0883f8093e70955586adbbe..5a1d193beb29a9fcaba5fd649d3ac0aa20f54b49 100644 (file)
@@ -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;
 }