[cfe-commits] r123261 - in /cfe/trunk: 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

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 11 11:45:13 PST 2011


Author: akirtzidis
Date: Tue Jan 11 13:45:13 2011
New Revision: 123261

URL: http://llvm.org/viewvc/llvm-project?rev=123261&view=rev
Log:
[analyzer] Add 'isLoad' parameter in Checker::visitLocation() to conveniently distinguish between loads/stores.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/Checker.h
    cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/Checker.h?rev=123261&r1=123260&r2=123261&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/Checker.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/PathSensitive/Checker.h Tue Jan 11 13:45:13 2011
@@ -245,7 +245,7 @@
     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 @@
   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) {}

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp?rev=123261&r1=123260&r2=123261&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp Tue Jan 11 13:45:13 2011
@@ -27,7 +27,7 @@
 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 @@
   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)

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp?rev=123261&r1=123260&r2=123261&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp Tue Jan 11 13:45:13 2011
@@ -34,7 +34,7 @@
 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 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.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=123261&r1=123260&r2=123261&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Tue Jan 11 13:45:13 2011
@@ -29,7 +29,8 @@
 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::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()) {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=123261&r1=123260&r2=123261&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Jan 11 13:45:13 2011
@@ -82,7 +82,7 @@
   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 @@
 }
 
 // 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);





More information about the cfe-commits mailing list