diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-13 23:31:04 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-13 23:31:04 +0000 |
commit | 8800ad4eaa1621f6d23c8264971063b9f8da6a2e (patch) | |
tree | 0b875122b136a18d23824df6be74e310827f8c0b /lib | |
parent | 54ca9b1d45fbfb0b3eeab581e0d10403cc922e62 (diff) |
Change pretty-printing API for SymExprs and MemRegions to use a naming convention and style similar to other elements in Clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/MemRegion.cpp | 37 | ||||
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 2 | ||||
-rw-r--r-- | lib/Analysis/SymbolManager.cpp | 43 |
3 files changed, 33 insertions, 49 deletions
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index 0dac76be11..ec0608bc98 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -143,26 +143,26 @@ void CodeTextRegion::Profile(llvm::FoldingSetNodeID& ID) const { // Region pretty-printing. //===----------------------------------------------------------------------===// -void MemRegion::printStdErr() const { - print(llvm::errs()); +void MemRegion::dump() const { + dumpToStream(llvm::errs()); } std::string MemRegion::getString() const { std::string s; llvm::raw_string_ostream os(s); - print(os); + dumpToStream(os); return os.str(); } -void MemRegion::print(llvm::raw_ostream& os) const { +void MemRegion::dumpToStream(llvm::raw_ostream& os) const { os << "<Unknown Region>"; } -void AllocaRegion::print(llvm::raw_ostream& os) const { +void AllocaRegion::dumpToStream(llvm::raw_ostream& os) const { os << "alloca{" << (void*) Ex << ',' << Cnt << '}'; } -void CodeTextRegion::print(llvm::raw_ostream& os) const { +void CodeTextRegion::dumpToStream(llvm::raw_ostream& os) const { os << "code{"; if (isDeclared()) os << getDecl()->getDeclName().getAsString(); @@ -172,37 +172,34 @@ void CodeTextRegion::print(llvm::raw_ostream& os) const { os << '}'; } -void CompoundLiteralRegion::print(llvm::raw_ostream& os) const { +void CompoundLiteralRegion::dumpToStream(llvm::raw_ostream& os) const { // FIXME: More elaborate pretty-printing. os << "{ " << (void*) CL << " }"; } -void ElementRegion::print(llvm::raw_ostream& os) const { - superRegion->print(os); - os << '['; Index.print(os); os << ']'; +void ElementRegion::dumpToStream(llvm::raw_ostream& os) const { + os << superRegion << '['; Index.print(os); os << ']'; } -void FieldRegion::print(llvm::raw_ostream& os) const { - superRegion->print(os); - os << "->" << getDecl()->getNameAsString(); +void FieldRegion::dumpToStream(llvm::raw_ostream& os) const { + os << superRegion << "->" << getDecl()->getNameAsString(); } -void StringRegion::print(llvm::raw_ostream& os) const { +void StringRegion::dumpToStream(llvm::raw_ostream& os) const { LangOptions LO; // FIXME. Str->printPretty(os, 0, PrintingPolicy(LO)); } -void SymbolicRegion::print(llvm::raw_ostream& os) const { +void SymbolicRegion::dumpToStream(llvm::raw_ostream& os) const { os << "SymRegion-" << sym; } -void TypedViewRegion::print(llvm::raw_ostream& os) const { - os << "typed_view{" << LValueType.getAsString() << ','; - getSuperRegion()->print(os); - os << '}'; +void TypedViewRegion::dumpToStream(llvm::raw_ostream& os) const { + os << "typed_view{" << LValueType.getAsString() << ',' + << getSuperRegion() << '}'; } -void VarRegion::print(llvm::raw_ostream& os) const { +void VarRegion::dumpToStream(llvm::raw_ostream& os) const { os << cast<VarDecl>(D)->getNameAsString(); } diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 00a086d374..2999225a43 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -1439,7 +1439,7 @@ void RegionStoreManager::print(Store store, llvm::raw_ostream& OS, OS << "Store:" << nl; for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) { - OS << ' '; I.getKey()->print(OS); OS << " : "; + OS << ' ' << I.getKey() << " : "; I.getData().print(OS); OS << nl; } } diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp index 275f30a296..e59d0bd437 100644 --- a/lib/Analysis/SymbolManager.cpp +++ b/lib/Analysis/SymbolManager.cpp @@ -18,7 +18,9 @@ using namespace clang; -static void print(llvm::raw_ostream& os, const SymExpr *SE); +void SymExpr::dump() const { + dumpToStream(llvm::errs()); +} static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) { switch (Op) { @@ -44,45 +46,30 @@ static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) { } } -static void print(llvm::raw_ostream& os, const SymIntExpr *SE) { +void SymIntExpr::dumpToStream(llvm::raw_ostream& os) const { os << '('; - print(os, SE->getLHS()); + getLHS()->dumpToStream(os); os << ") "; - print(os, SE->getOpcode()); - os << ' ' << SE->getRHS().getZExtValue(); - if (SE->getRHS().isUnsigned()) os << 'U'; + print(os, getOpcode()); + os << ' ' << getRHS().getZExtValue(); + if (getRHS().isUnsigned()) os << 'U'; } -static void print(llvm::raw_ostream& os, const SymSymExpr *SE) { +void SymSymExpr::dumpToStream(llvm::raw_ostream& os) const { os << '('; - print(os, SE->getLHS()); + getLHS()->dumpToStream(os); os << ") "; os << '('; - print(os, SE->getRHS()); + getRHS()->dumpToStream(os); os << ')'; } -static void print(llvm::raw_ostream& os, const SymExpr *SE) { - switch (SE->getKind()) { - case SymExpr::BEGIN_SYMBOLS: - case SymExpr::RegionValueKind: - case SymExpr::ConjuredKind: - case SymExpr::END_SYMBOLS: - os << '$' << cast<SymbolData>(SE)->getSymbolID(); - return; - case SymExpr::SymIntKind: - print(os, cast<SymIntExpr>(SE)); - return; - case SymExpr::SymSymKind: - print(os, cast<SymSymExpr>(SE)); - return; - } +void SymbolConjured::dumpToStream(llvm::raw_ostream& os) const { + os << "conj_$" << getSymbolID(); } - -llvm::raw_ostream& llvm::operator<<(llvm::raw_ostream& os, const SymExpr *SE) { - print(os, SE); - return os; +void SymbolRegionValue::dumpToStream(llvm::raw_ostream& os) const { + os << "reg_$" << getSymbolID() << "<" << R << ">"; } const SymbolRegionValue* |