virtual const GRState *RemoveDeadBindings(const GRState *state,
SymbolReaper& SymReaper) = 0;
- virtual void print(const GRState *state, std::ostream& Out,
+ virtual void print(const GRState *state, llvm::raw_ostream& Out,
const char* nl, const char *sep) = 0;
virtual void EndPath(const GRState *state) {}
#include "llvm/ADT/DenseSet.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/raw_ostream.h"
#include <functional>
class Printer {
public:
virtual ~Printer() {}
- virtual void Print(std::ostream& Out, const GRState* state,
+ virtual void Print(llvm::raw_ostream& Out, const GRState* state,
const char* nl, const char* sep) = 0;
};
// Pretty-printing.
- void print(std::ostream& Out, const char *nl = "\n",
+ void print(llvm::raw_ostream& Out, const char *nl = "\n",
const char *sep = "") const;
void printStdErr() const;
- void printDOT(std::ostream& Out) const;
+ void printDOT(llvm::raw_ostream& Out) const;
// Tags used for the Generic Data Map.
struct NullDerefTag {
/// return that expression. Otherwise return NULL.
const SymExpr *getAsSymbolicExpression() const;
- void print(std::ostream& OS) const;
void print(llvm::raw_ostream& OS) const;
void printStdErr() const;
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
-#include <iosfwd>
namespace clang {
return state;
}
- virtual void print(Store store, std::ostream& Out,
+ virtual void print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) = 0;
class BindingsHandler {
llvm::raw_ostream& operator<<(llvm::raw_ostream& Out,
const clang::SymExpr *SE);
}
-namespace std {
- std::ostream& operator<<(std::ostream& Out,
- const clang::SymExpr *SE);
-}
-
#endif
const GRState* RemoveDeadBindings(const GRState* state, SymbolReaper& SymReaper);
- void print(const GRState* state, std::ostream& Out,
+ void print(const GRState* state, llvm::raw_ostream& Out,
const char* nl, const char *sep);
};
return state->set<ConstNotEq>(CNE);
}
-void BasicConstraintManager::print(const GRState* state, std::ostream& Out,
+void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
// Print equality constraints.
if (!CE.isEmpty()) {
Out << nl << sep << "'==' constraints:";
-
- for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) {
- Out << nl << " $" << I.getKey();
- llvm::raw_os_ostream OS(Out);
- OS << " : " << *I.getData();
- }
+ for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I)
+ Out << nl << " $" << I.getKey() << " : " << *I.getData();
}
// Print != constraints.
return BindingsTy(static_cast<const BindingsTy::TreeTy*>(store));
}
- void print(Store store, std::ostream& Out, const char* nl, const char *sep);
+ void print(Store store, llvm::raw_ostream& Out, const char* nl,
+ const char *sep);
private:
ASTContext& getContext() { return StateMgr.getContext(); }
return store;
}
-void BasicStoreManager::print(Store store, std::ostream& O,
+void BasicStoreManager::print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
- llvm::raw_os_ostream Out(O);
BindingsTy B = GetBindings(store);
Out << "Variables:" << nl;
bool isFirst = true;
for (BindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I) {
- if (isFirst) isFirst = false;
- else Out << nl;
+ if (isFirst)
+ isFirst = false;
+ else
+ Out << nl;
Out << ' ' << I.getKey() << " : ";
I.getData().print(Out);
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/STLExtras.h"
-#include <ostream>
#include <stdarg.h>
using namespace clang;
ID.Add(T);
}
- void print(std::ostream& Out) const;
+ void print(llvm::raw_ostream& Out) const;
};
-void RefVal::print(std::ostream& Out) const {
+void RefVal::print(llvm::raw_ostream& Out) const {
if (!T.isNull())
Out << "Tracked Type:" << T.getAsString() << '\n';
public:
class BindingsPrinter : public GRState::Printer {
public:
- virtual void Print(std::ostream& Out, const GRState* state,
+ virtual void Print(llvm::raw_ostream& Out, const GRState* state,
const char* nl, const char* sep);
};
} // end anonymous namespace
-static void PrintPool(std::ostream &Out, SymbolRef Sym, const GRState *state) {
+static void PrintPool(llvm::raw_ostream &Out, SymbolRef Sym,
+ const GRState *state) {
Out << ' ';
if (Sym)
Out << Sym->getSymbolID();
Out << '}';
}
-void CFRefCount::BindingsPrinter::Print(std::ostream& Out, const GRState* state,
+void CFRefCount::BindingsPrinter::Print(llvm::raw_ostream& Out,
+ const GRState* state,
const char* nl, const char* sep) {
-
-
RefBindings B = state->get<RefBindings>();
#include "clang/AST/Expr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Basic/LangOptions.h"
-#include <sstream>
using namespace clang;
// Find ivars that are unused.
for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
if (I->second == Unused) {
-
- std::ostringstream os;
+ std::string sbuf;
+ llvm::raw_string_ostream os(sbuf);
os << "Instance variable '" << I->first->getNameAsString()
<< "' in class '" << ID->getNameAsString()
<< "' is never used by the methods in its @implementation "
static std::string getNodeLabel(const GRExprEngine::NodeTy* N, void*,
bool ShortNames) {
- std::ostringstream Out;
+
+ std::string sbuf;
+ llvm::raw_string_ostream Out(sbuf);
// Program Location.
ProgramPoint Loc = N->getLocation();
SourceLocation SLoc = S->getLocStart();
Out << S->getStmtClassName() << ' ' << (void*) S << ' ';
- llvm::raw_os_ostream OutS(Out);
- S->printPretty(OutS);
- OutS.flush();
+ S->printPretty(Out);
if (SLoc.isFileID()) {
Out << "\\lline="
SourceLocation SLoc = T->getLocStart();
Out << "\\|Terminator: ";
-
- llvm::raw_os_ostream OutS(Out);
- E.getSrc()->printTerminator(OutS);
- OutS.flush();
+ E.getSrc()->printTerminator(Out);
if (SLoc.isFileID()) {
Out << "\\lline="
if (Label) {
if (CaseStmt* C = dyn_cast<CaseStmt>(Label)) {
Out << "\\lcase ";
- llvm::raw_os_ostream OutS(Out);
- C->getLHS()->printPretty(OutS);
- OutS.flush();
+ C->getLHS()->printPretty(Out);
if (Stmt* RHS = C->getRHS()) {
Out << " .. ";
- RHS->printPretty(OutS);
- OutS.flush();
+ RHS->printPretty(Out);
}
Out << ":";
-//= GRState*cpp - Path-Sens. "State" for tracking valuues -----*- C++ -*--=//
+//= GRState.cpp - Path-Sensitive "State" for tracking values -----*- C++ -*--=//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
//
-// This file defines SymbolRef, ExprBindKey, and GRState*
+// This file implements GRState and GRStateManager.
//
//===----------------------------------------------------------------------===//
using namespace clang;
// Give the vtable for ConstraintManager somewhere to live.
+// FIXME: Move this elsewhere.
ConstraintManager::~ConstraintManager() {}
GRStateManager::~GRStateManager() {
// State pretty-printing.
//===----------------------------------------------------------------------===//
-void GRState::print(std::ostream& Out, const char* nl, const char* sep) const {
+void GRState::print(llvm::raw_ostream& Out, const char* nl,
+ const char* sep) const {
// Print the store.
Mgr->getStoreManager().print(getStore(), Out, nl, sep);
else { Out << nl; }
Out << " (" << (void*) I.getKey() << ") ";
- llvm::raw_os_ostream OutS(Out);
- I.getKey()->printPretty(OutS);
- OutS.flush();
+ I.getKey()->printPretty(Out);
Out << " : ";
I.getData().print(Out);
}
else { Out << nl; }
Out << " (" << (void*) I.getKey() << ") ";
- llvm::raw_os_ostream OutS(Out);
- I.getKey()->printPretty(OutS);
- OutS.flush();
+ I.getKey()->printPretty(Out);
Out << " : ";
I.getData().print(Out);
}
}
}
-void GRState::printDOT(std::ostream& Out) const {
+void GRState::printDOT(llvm::raw_ostream& Out) const {
print(Out, "\\l", "\\|");
}
void GRState::printStdErr() const {
- print(*llvm::cerr);
+ print(llvm::errs());
}
//===----------------------------------------------------------------------===//
return newRanges;
}
- void Print(std::ostream &os) const {
+ void print(llvm::raw_ostream &os) const {
bool isFirst = true;
os << "{ ";
for (iterator i = begin(), e = end(); i != e; ++i) {
const GRState* RemoveDeadBindings(const GRState* St, SymbolReaper& SymReaper);
- void print(const GRState* St, std::ostream& Out,
+ void print(const GRState* St, llvm::raw_ostream& Out,
const char* nl, const char *sep);
private:
// Pretty-printing.
//===------------------------------------------------------------------------===/
-void RangeConstraintManager::print(const GRState* St, std::ostream& Out,
+void RangeConstraintManager::print(const GRState* St, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
ConstraintRangeTy Ranges = St->get<ConstraintRange>();
for (ConstraintRangeTy::iterator I=Ranges.begin(), E=Ranges.end(); I!=E; ++I){
Out << nl << ' ' << I.getKey() << " : ";
- I.getData().Print(Out);
+ I.getData().print(Out);
}
}
CastResult CastRegion(const GRState *state, const MemRegion* R,
QualType CastToTy);
- SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,NonLoc R);
-
-
-
+ SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,
+ NonLoc R);
Store getInitialStore() { return RBFactory.GetEmptyMap().getRoot(); }
return SelfRegion;
}
-
-
//===-------------------------------------------------------------------===//
// Binding values to regions.
return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
}
- void print(Store store, std::ostream& Out, const char* nl, const char *sep);
+ void print(Store store, llvm::raw_ostream& Out, const char* nl,
+ const char *sep);
void iterBindings(Store store, BindingsHandler& f) {
// FIXME: Implement.
// Utility methods.
//===----------------------------------------------------------------------===//
-void RegionStoreManager::print(Store store, std::ostream& Out,
+void RegionStoreManager::print(Store store, llvm::raw_ostream& OS,
const char* nl, const char *sep) {
- llvm::raw_os_ostream OS(Out);
RegionBindingsTy B = GetRegionBindings(store);
OS << "Store:" << nl;
void SVal::printStdErr() const { print(llvm::errs()); }
-void SVal::print(std::ostream& Out) const {
- llvm::raw_os_ostream out(Out);
- print(out);
-}
-
void SVal::print(llvm::raw_ostream& Out) const {
switch (getBaseKind()) {
return os;
}
-std::ostream& std::operator<<(std::ostream& os, const SymExpr *SE) {
- llvm::raw_os_ostream O(os);
- print(O, SE);
- return os;
-}
-
const SymbolRegionValue*
SymbolManager::getRegionValueSymbol(const MemRegion* R, QualType T) {
llvm::FoldingSetNodeID profile;