]> granicus.if.org Git - clang/commitdiff
[analyzer] add LocationContext::inTopFrame() helper.
authorAnna Zaks <ganna@apple.com>
Sat, 3 Nov 2012 02:54:16 +0000 (02:54 +0000)
committerAnna Zaks <ganna@apple.com>
Sat, 3 Nov 2012 02:54:16 +0000 (02:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167351 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/AnalysisContext.h
include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
lib/Analysis/AnalysisDeclContext.cpp
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

index a2090eca724b60b2c95984503fd314961a6aa15d..52466786b341918518054b191e888d19f97770a3 100644 (file)
@@ -237,6 +237,9 @@ public:
 
   const StackFrameContext *getCurrentStackFrame() const;
 
+  /// Return true if the current LocationContext has no caller context.
+  virtual bool inTopFrame() const;
+
   virtual void Profile(llvm::FoldingSetNodeID &ID) = 0;
 
 public:
@@ -271,6 +274,9 @@ public:
 
   const CFGBlock *getCallSiteBlock() const { return Block; }
 
+  /// Return true if the current LocationContext has no caller context.
+  virtual bool inTopFrame() const { return getParent() == 0;  }
+
   unsigned getIndex() const { return Index; }
 
   void Profile(llvm::FoldingSetNodeID &ID);
index 15a7586aeececb709d8597120335e2f27ceb8969..9d5ef8ae41cf7a06a1fe5a5af4295d58fceae003 100644 (file)
@@ -100,6 +100,9 @@ public:
     return Pred->getStackFrame();
   }
 
+  /// Return true if the current LocationContext has no caller context.
+  bool inTopFrame() const { return getLocationContext()->inTopFrame();  }
+
   /// Returns true if the predecessor is within an inlined function/method.
   bool isWithinInlined() {
     return (getStackFrame()->getParent() != 0);
index e17090f79991a90c7067c8791b99f0135515e9cf..e7df0a813b37f0dd41098258e6ef9e8eeac0a01b 100644 (file)
@@ -355,6 +355,10 @@ const StackFrameContext *LocationContext::getCurrentStackFrame() const {
   return NULL;
 }
 
+bool LocationContext::inTopFrame() const {
+  return getCurrentStackFrame()->inTopFrame();
+}
+
 bool LocationContext::isParentOf(const LocationContext *LC) const {
   do {
     const LocationContext *Parent = LC->getParent();
index cc5cf635310e134e01ea40ebe2870254f10ce2e5..304051c1394cc20544551d519d9a321a8f255481 100644 (file)
@@ -3190,12 +3190,6 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
 // Handle return statements.
 //===----------------------------------------------------------------------===//
 
-// Return true if the current LocationContext has no caller context.
-static bool inTopFrame(CheckerContext &C) {
-  const LocationContext *LC = C.getLocationContext();
-  return LC->getParent() == 0;  
-}
-
 void RetainCountChecker::checkPreStmt(const ReturnStmt *S,
                                       CheckerContext &C) const {
 
@@ -3204,7 +3198,7 @@ void RetainCountChecker::checkPreStmt(const ReturnStmt *S,
   // better checking even for inlined calls, and see if they match
   // with their expected semantics (e.g., the method should return a retained
   // object, etc.).
-  if (!inTopFrame(C))
+  if (!C.inTopFrame())
     return;
 
   const Expr *RetE = S->getRetValue();