aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-01-03 01:30:12 +0000
committerTed Kremenek <kremenek@apple.com>2013-01-03 01:30:12 +0000
commitc37fad6d8b483b636e96f568202f24cb2b714db4 (patch)
tree690b922164860227c5d6b2aca7430f49a616b3aa /lib/StaticAnalyzer/Checkers/MallocChecker.cpp
parent89e19b43b81a6b5d092a81d2ebf6ec9a4097a48d (diff)
Make MallocChecker debug output useful.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r--lib/StaticAnalyzer/Checkers/MallocChecker.cpp24
1 files 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<RegionState>();
- 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) \