summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
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
commit6fcefb53e36abe2c280ded6e53126337ec8507f0 (patch)
treeb8da4eae2e4484b92cca80be88174ab6b7ee9bef /clang/lib/StaticAnalyzer
parente0219f78d3b7f3b7095bc45fde037dbdd6c6e535 (diff)
downloadbcm5719-llvm-6fcefb53e36abe2c280ded6e53126337ec8507f0.tar.gz
bcm5719-llvm-6fcefb53e36abe2c280ded6e53126337ec8507f0.zip
Make MallocChecker debug output useful.
llvm-svn: 171439
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index af902a00963..cfbcc53c17d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/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) \
OpenPOWER on IntegriCloud