From 705fd953ef3374e7799d834765fcc0966a60177a Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 26 Nov 2009 02:32:19 +0000 Subject: [PATCH] Added batch versions of GRState::scanReachableSymbols() so that clients can scan a collection of SVals or MemRegions all at once. llvm-svn: 89926 --- .../clang/Analysis/PathSensitive/GRState.h | 27 +++++++++++++++++++ clang/lib/Analysis/GRState.cpp | 21 +++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/clang/include/clang/Analysis/PathSensitive/GRState.h b/clang/include/clang/Analysis/PathSensitive/GRState.h index ef0c36c44d9f..898f6edad0f2 100644 --- a/clang/include/clang/Analysis/PathSensitive/GRState.h +++ b/clang/include/clang/Analysis/PathSensitive/GRState.h @@ -264,8 +264,21 @@ public: const llvm::APSInt *getSymVal(SymbolRef sym); bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const; + + bool scanReachableSymbols(const SVal *I, const SVal *E, + SymbolVisitor &visitor) const; + + bool scanReachableSymbols(const MemRegion * const *I, + const MemRegion * const *E, + SymbolVisitor &visitor) const; template CB scanReachableSymbols(SVal val) const; + template CB scanReachableSymbols(const SVal *beg, + const SVal *end) const; + + template CB + scanReachableSymbols(const MemRegion * const *beg, + const MemRegion * const *end) const; //==---------------------------------------------------------------------==// // Accessing the Generic Data Map (GDM). @@ -726,7 +739,21 @@ CB GRState::scanReachableSymbols(SVal val) const { scanReachableSymbols(val, cb); return cb; } + +template +CB GRState::scanReachableSymbols(const SVal *beg, const SVal *end) const { + CB cb(this); + scanReachableSymbols(beg, end, cb); + return cb; +} +template +CB GRState::scanReachableSymbols(const MemRegion * const *beg, + const MemRegion * const *end) const { + CB cb(this); + scanReachableSymbols(beg, end, cb); + return cb; +} } // end clang namespace #endif diff --git a/clang/lib/Analysis/GRState.cpp b/clang/lib/Analysis/GRState.cpp index 23ee0b2258bd..5284d65e9ade 100644 --- a/clang/lib/Analysis/GRState.cpp +++ b/clang/lib/Analysis/GRState.cpp @@ -308,6 +308,27 @@ bool GRState::scanReachableSymbols(SVal val, SymbolVisitor& visitor) const { return S.scan(val); } +bool GRState::scanReachableSymbols(const SVal *I, const SVal *E, + SymbolVisitor &visitor) const { + ScanReachableSymbols S(this, visitor); + for ( ; I != E; ++I) { + if (S.scan(*I)) + return true; + } + return false; +} + +bool GRState::scanReachableSymbols(const MemRegion * const *I, + const MemRegion * const *E, + SymbolVisitor &visitor) const { + ScanReachableSymbols S(this, visitor); + for ( ; I != E; ++I) { + if (S.scan(*I)) + return true; + } + return false; +} + //===----------------------------------------------------------------------===// // Queries. //===----------------------------------------------------------------------===//