diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-08-16 00:49:49 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-08-16 00:49:49 +0000 |
commit | 1c72ef092f3d931639cf44b4f4f9d0eedc1baa8f (patch) | |
tree | 6e8f87c61a1d28ccf6050fb3f12121b8588d9791 /lib/Analysis/GRExprEngine.cpp | |
parent | dd463b8db0b07d2fdb99ffc7a7eb28eeb449c5d4 (diff) |
GRState:
- Remove ConstNotEq from GRState/GRStateManager (!= tracking uses GDM instead).
- GRStateManager now can book-keep "contexts" (e.g., factory objects) for uses
with data elements stored into the GDM.
- Refactor pretty-printing of states to use GRState::Printer objects
exclusively. This removed a huge amount of pretty-printing logic from
GRExprEngine.
CFRefCount
- Simplified some API calls based on refinements to the GDM api.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54835 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 122 |
1 files changed, 5 insertions, 117 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index f4ffcb12e0..896f473df8 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -177,7 +177,8 @@ void GRExprEngine::EmitWarnings(BugReporterData& BRData) { void GRExprEngine::setTransferFunctions(GRTransferFuncs* tf) { StateMgr.TF = tf; - getTF().RegisterChecks(*this); + tf->RegisterChecks(*this); + tf->RegisterPrinters(getStateManager().Printers); } void GRExprEngine::AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C) { @@ -2266,109 +2267,12 @@ void GRExprEngine::EvalBinOp(GRStateSet& OStates, const GRState* St, #ifndef NDEBUG static GRExprEngine* GraphPrintCheckerState; static SourceManager* GraphPrintSourceManager; -static GRState::Printer **GraphStatePrinterBeg, **GraphStatePrinterEnd; namespace llvm { template<> struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> : public DefaultDOTGraphTraits { - static void PrintVarBindings(std::ostream& Out, GRState* St) { - - Out << "Variables:\\l"; - - bool isFirst = true; - - for (GRState::vb_iterator I=St->vb_begin(), E=St->vb_end(); I!=E;++I) { - - if (isFirst) - isFirst = false; - else - Out << "\\l"; - - Out << ' ' << I.getKey()->getName() << " : "; - I.getData().print(Out); - } - - } - - - static void PrintSubExprBindings(std::ostream& Out, GRState* St){ - - bool isFirst = true; - - for (GRState::seb_iterator I=St->seb_begin(), E=St->seb_end();I!=E;++I) { - - if (isFirst) { - Out << "\\l\\lSub-Expressions:\\l"; - isFirst = false; - } - else - Out << "\\l"; - - Out << " (" << (void*) I.getKey() << ") "; - I.getKey()->printPretty(Out); - Out << " : "; - I.getData().print(Out); - } - } - - static void PrintBlkExprBindings(std::ostream& Out, GRState* St){ - - bool isFirst = true; - - for (GRState::beb_iterator I=St->beb_begin(), E=St->beb_end(); I!=E;++I){ - if (isFirst) { - Out << "\\l\\lBlock-level Expressions:\\l"; - isFirst = false; - } - else - Out << "\\l"; - - Out << " (" << (void*) I.getKey() << ") "; - I.getKey()->printPretty(Out); - Out << " : "; - I.getData().print(Out); - } - } - - static void PrintEQ(std::ostream& Out, GRState* St) { - GRState::ConstEqTy CE = St->ConstEq; - - if (CE.isEmpty()) - return; - - Out << "\\l\\|'==' constraints:"; - - for (GRState::ConstEqTy::iterator I=CE.begin(), E=CE.end(); I!=E;++I) - Out << "\\l $" << I.getKey() << " : " << I.getData()->toString(); - } - - static void PrintNE(std::ostream& Out, GRState* St) { - GRState::ConstNotEqTy NE = St->ConstNotEq; - - if (NE.isEmpty()) - return; - - Out << "\\l\\|'!=' constraints:"; - - for (GRState::ConstNotEqTy::iterator I=NE.begin(), EI=NE.end(); - I != EI; ++I){ - - Out << "\\l $" << I.getKey() << " : "; - bool isFirst = true; - - GRState::IntSetTy::iterator J=I.getData().begin(), - EJ=I.getData().end(); - for ( ; J != EJ; ++J) { - if (isFirst) isFirst = false; - else Out << ", "; - - Out << (*J)->toString(); - } - } - } - static std::string getNodeAttributes(const GRExprEngine::NodeTy* N, void*) { if (GraphPrintCheckerState->isImplicitNullDeref(N) || @@ -2509,7 +2413,8 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> : Out << "\\|StateID: " << (void*) N->getState() << "\\|"; - N->getState()->printDOT(Out, GraphStatePrinterBeg, GraphStatePrinterEnd); + GRStateRef state(N->getState(), GraphPrintCheckerState->getStateManager()); + state.printDOT(Out); Out << "\\l"; return Out.str(); @@ -2575,19 +2480,10 @@ void GRExprEngine::ViewGraph(bool trim) { GraphPrintCheckerState = this; GraphPrintSourceManager = &getContext().getSourceManager(); - // Get the state printers. - std::vector<GRState::Printer*> Printers; - getTF().getStatePrinters(Printers); - GraphStatePrinterBeg = Printers.empty() ? 0 : &Printers[0]; - GraphStatePrinterEnd = Printers.empty() ? 0 : &Printers[0]+Printers.size(); - - llvm::ViewGraph(*G.roots_begin(), "GRExprEngine"); GraphPrintCheckerState = NULL; GraphPrintSourceManager = NULL; - GraphStatePrinterBeg = NULL; - GraphStatePrinterEnd = NULL; } #endif } @@ -2596,13 +2492,7 @@ void GRExprEngine::ViewGraph(NodeTy** Beg, NodeTy** End) { #ifndef NDEBUG GraphPrintCheckerState = this; GraphPrintSourceManager = &getContext().getSourceManager(); - - // Get the state printers. - std::vector<GRState::Printer*> Printers; - getTF().getStatePrinters(Printers); - GraphStatePrinterBeg = Printers.empty() ? 0 : &Printers[0]; - GraphStatePrinterEnd = Printers.empty() ? 0 : &Printers[0]+Printers.size(); - + GRExprEngine::GraphTy* TrimmedG = G.Trim(Beg, End); if (!TrimmedG) @@ -2614,7 +2504,5 @@ void GRExprEngine::ViewGraph(NodeTy** Beg, NodeTy** End) { GraphPrintCheckerState = NULL; GraphPrintSourceManager = NULL; - GraphStatePrinterBeg = NULL; - GraphStatePrinterEnd = NULL; #endif } |