From c37fad6d8b483b636e96f568202f24cb2b714db4 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 3 Jan 2013 01:30:12 +0000 Subject: [PATCH] Make MallocChecker debug output useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171439 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index af902a0096..cfbcc53c17 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -70,6 +70,19 @@ public: ID.AddInteger(K); ID.AddPointer(S); } + + void dump(llvm::raw_ostream &OS) const { + static const char *Table[] = { + "Allocated", + "Released", + "Relinquished" + }; + OS << Table[(unsigned) K]; + } + + LLVM_ATTRIBUTE_USED void dump() const { + dump(llvm::errs()); + } }; enum ReallocPairKind { @@ -1561,8 +1574,15 @@ void MallocChecker::printState(raw_ostream &Out, ProgramStateRef State, RegionStateTy RS = State->get(); - if (!RS.isEmpty()) - Out << "Has Malloc data" << NL; + if (!RS.isEmpty()) { + Out << Sep << "MallocChecker:" << NL; + for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) { + I.getKey()->dumpToStream(Out); + Out << " : "; + I.getData().dump(Out); + Out << NL; + } + } } #define REGISTER_CHECKER(name) \ -- 2.40.0