]> granicus.if.org Git - clang/commitdiff
[analyzer] Add 'isLoad' parameter in Checker::visitLocation() to conveniently disting...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 11 Jan 2011 19:45:13 +0000 (19:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 11 Jan 2011 19:45:13 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123261 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/PathSensitive/Checker.h
lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
lib/StaticAnalyzer/Checkers/MallocChecker.cpp

index 797a377c5606e6ab746cd29f286dc82100ce57b3..82205dcd136980fa168f2aeed5dfc859ba1e0bb1 100644 (file)
@@ -245,7 +245,7 @@ private:
     CheckerContext C(Dst, Builder, Eng, Pred, tag,
                      isLoad ? ProgramPoint::PreLoadKind :
                      ProgramPoint::PreStoreKind, 0, S, state);
-    visitLocation(C, S, location);
+    visitLocation(C, S, location, isLoad);
   }
 
   void GR_evalDeadSymbols(ExplodedNodeSet &Dst, StmtNodeBuilder &Builder,
@@ -260,7 +260,8 @@ public:
   virtual ~Checker();
   virtual void _PreVisit(CheckerContext &C, const Stmt *S) {}
   virtual void _PostVisit(CheckerContext &C, const Stmt *S) {}
-  virtual void visitLocation(CheckerContext &C, const Stmt *S, SVal location) {}
+  virtual void visitLocation(CheckerContext &C, const Stmt *S, SVal location,
+                             bool isLoad) {}
   virtual void PreVisitBind(CheckerContext &C, const Stmt *StoreE,
                             SVal location, SVal val) {}
   virtual void evalDeadSymbols(CheckerContext &C, SymbolReaper &SymReaper) {}
index 13e628bcb1a56d32565a52e6c9bbc282eaedf4b8..d52427bf9d61d8f54c9a2e3de5e8c729e15bf9d0 100644 (file)
@@ -27,7 +27,7 @@ class ArrayBoundChecker :
 public:
   ArrayBoundChecker() : BT(0) {}
   static void *getTag() { static int x = 0; return &x; }
-  void visitLocation(CheckerContext &C, const Stmt *S, SVal l);
+  void visitLocation(CheckerContext &C, const Stmt *S, SVal l, bool isLoad);
 };
 }
 
@@ -35,7 +35,8 @@ void ento::RegisterArrayBoundChecker(ExprEngine &Eng) {
   Eng.registerCheck(new ArrayBoundChecker());
 }
 
-void ArrayBoundChecker::visitLocation(CheckerContext &C, const Stmt *S, SVal l){
+void ArrayBoundChecker::visitLocation(CheckerContext &C, const Stmt *S, SVal l,
+                                      bool isLoad) {
   // Check for out of bound array element access.
   const MemRegion *R = l.getAsRegion();
   if (!R)
index b55fadebf87402743963cc83c5c12c75caab31bc..f6d3e15d9680fa3df2ca723e6bf3e3cf422d242a 100644 (file)
@@ -34,7 +34,7 @@ class ArrayBoundCheckerV2 :
 public:
   ArrayBoundCheckerV2() : BT(0) {}
   static void *getTag() { static int x = 0; return &x; }
-  void visitLocation(CheckerContext &C, const Stmt *S, SVal l);      
+  void visitLocation(CheckerContext &C, const Stmt *S, SVal l, bool isLoad);
 };
 
 // FIXME: Eventually replace RegionRawOffset with this class.
@@ -68,7 +68,7 @@ void ento::RegisterArrayBoundCheckerV2(ExprEngine &Eng) {
 
 void ArrayBoundCheckerV2::visitLocation(CheckerContext &checkerContext,
                                         const Stmt *S,
-                                        SVal location) {
+                                        SVal location, bool isLoad) {
 
   // NOTE: Instead of using GRState::assumeInBound(), we are prototyping
   // some new logic here that reasons directly about memory region extents.
index 7dc8ec84dfe41edda79cd375dfff0379d9b153cf..3f6f9433298088f6a6cb6f40cdcabbb6b1806944 100644 (file)
@@ -29,7 +29,8 @@ class DereferenceChecker : public Checker {
 public:
   DereferenceChecker() : BT_null(0), BT_undef(0) {}
   static void *getTag() { static int tag = 0; return &tag; }
-  void visitLocation(CheckerContext &C, const Stmt *S, SVal location);
+  void visitLocation(CheckerContext &C, const Stmt *S, SVal location,
+                     bool isLoad);
 
   std::pair<ExplodedNode * const*, ExplodedNode * const*>
   getImplicitNodes() const {
@@ -85,7 +86,7 @@ void DereferenceChecker::AddDerefSource(llvm::raw_ostream &os,
 }
 
 void DereferenceChecker::visitLocation(CheckerContext &C, const Stmt *S,
-                                       SVal l) {
+                                       SVal l, bool isLoad) {
   // Check for dereference of an undefined value.
   if (l.isUndef()) {
     if (ExplodedNode *N = C.generateSink()) {
index 9375947abba38ae9708dd3e0dbf86836f1bf6ac7..36968ecd1f3c8de222cae7aefa6014a97f7eebcd 100644 (file)
@@ -82,7 +82,7 @@ public:
   void PreVisitReturnStmt(CheckerContext &C, const ReturnStmt *S);
   const GRState *evalAssume(const GRState *state, SVal Cond, bool Assumption,
                             bool *respondsToCallback);
-  void visitLocation(CheckerContext &C, const Stmt *S, SVal l);
+  void visitLocation(CheckerContext &C, const Stmt *S, SVal l, bool isLoad);
   virtual void PreVisitBind(CheckerContext &C, const Stmt *StoreE,
                             SVal location, SVal val);
 
@@ -653,7 +653,8 @@ const GRState *MallocChecker::evalAssume(const GRState *state, SVal Cond,
 }
 
 // Check if the location is a freed symbolic region.
-void MallocChecker::visitLocation(CheckerContext &C, const Stmt *S, SVal l) {
+void MallocChecker::visitLocation(CheckerContext &C, const Stmt *S, SVal l,
+                                  bool isLoad) {
   SymbolRef Sym = l.getLocSymbolInBase();
   if (Sym) {
     const RefState *RS = C.getState()->get<RegionState>(Sym);