[cfe-commits] r85597 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/GRExprEngine.cpp
Ted Kremenek
kremenek at apple.com
Fri Oct 30 10:47:33 PDT 2009
Author: kremenek
Date: Fri Oct 30 12:47:32 2009
New Revision: 85597
URL: http://llvm.org/viewvc/llvm-project?rev=85597&view=rev
Log:
Make checkers run in deterministic order.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Analysis/GRExprEngine.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=85597&r1=85596&r2=85597&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Fri Oct 30 12:47:32 2009
@@ -76,7 +76,11 @@
llvm::OwningPtr<GRSimpleAPICheck> BatchAuditor;
- llvm::DenseMap<void *, Checker*> Checkers;
+ typedef llvm::DenseMap<void *, unsigned> CheckerMap;
+ CheckerMap CheckerM;
+
+ typedef std::vector<std::pair<void *, Checker*> >CheckersOrdered;
+ CheckersOrdered Checkers;
/// BR - The BugReporter associated with this engine. It is important that
// this object be placed at the very end of member variables so that its
@@ -205,13 +209,18 @@
void RegisterInternalChecks();
template <typename CHECKER>
- void registerCheck(Checker *check) {
- Checkers[CHECKER::getTag()] = check;
+ void registerCheck(CHECKER *check) {
+ unsigned entry = Checkers.size();
+ void *tag = CHECKER::getTag();
+ Checkers.push_back(std::make_pair(tag, check));
+ CheckerM[tag] = entry;
}
+
+ Checker *lookupChecker(void *tag) const;
template <typename CHECKER>
- CHECKER *getChecker() {
- return static_cast<CHECKER*>(Checkers[CHECKER::getTag()]);
+ CHECKER *getChecker() const {
+ return static_cast<CHECKER*>(lookupChecker(CHECKER::getTag()));
}
bool isRetStackAddr(const ExplodedNode* N) const {
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=85597&r1=85596&r2=85597&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Oct 30 12:47:32 2009
@@ -118,13 +118,11 @@
ExplodedNodeSet Tmp;
ExplodedNodeSet *PrevSet = &Src;
- for (llvm::DenseMap<void*, Checker*>::iterator I = Checkers.begin(),
- E = Checkers.end(); I != E; ++I) {
-
- llvm::DenseMap<void*, Checker*>::iterator X = I;
-
- ExplodedNodeSet *CurrSet = (++X == E) ? &Dst
+ for (CheckersOrdered::iterator I=Checkers.begin(),E=Checkers.end(); I!=E; ++I)
+ {
+ ExplodedNodeSet *CurrSet = (I+1 == E) ? &Dst
: (PrevSet == &Tmp) ? &Src : &Tmp;
+
CurrSet->clear();
void *tag = I->first;
Checker *checker = I->second;
@@ -146,7 +144,7 @@
if (Checkers.empty())
return Pred;
- for (llvm::DenseMap<void*, Checker*>::iterator I = Checkers.begin(),
+ for (CheckersOrdered::iterator I = Checkers.begin(),
E = Checkers.end(); I != E; ++I) {
Pred = I->second->CheckLocation(S, Pred, state, V, *this);
if (!Pred)
@@ -184,8 +182,7 @@
GRExprEngine::~GRExprEngine() {
BR.FlushReports();
delete [] NSExceptionInstanceRaiseSelectors;
- for (llvm::DenseMap<void*, Checker*>::iterator I=Checkers.begin(),
- E=Checkers.end(); I!=E; ++I)
+ for (CheckersOrdered::iterator I=Checkers.begin(), E=Checkers.end(); I!=E;++I)
delete I->second;
}
@@ -2861,6 +2858,15 @@
}
//===----------------------------------------------------------------------===//
+// Checker registration/lookup.
+//===----------------------------------------------------------------------===//
+
+Checker *GRExprEngine::lookupChecker(void *tag) const {
+ CheckerMap::iterator I = CheckerM.find(tag);
+ return (I == CheckerM.end()) ? NULL : Checkers[I->second].second;
+}
+
+//===----------------------------------------------------------------------===//
// Visualization.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list