diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-05-18 02:26:59 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-05-18 02:26:59 +0000 |
commit | 7c40d078b5473e83a80886aa56c561f6a43cf325 (patch) | |
tree | 8a100ca0adbf336ea6166378e938604dd348576e /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | 433b0f5455416fb61ee81d4cb26f2e64678a6ecd (diff) | |
download | bcm5719-llvm-7c40d078b5473e83a80886aa56c561f6a43cf325.tar.gz bcm5719-llvm-7c40d078b5473e83a80886aa56c561f6a43cf325.zip |
[analyzer] Add a debug dump for PathPieces, a list of PathDiagnosticPieces.
Originally implemented by Ted, extended by me.
llvm-svn: 182186
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 519555396dd..d4277fc218d 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1873,6 +1873,60 @@ static bool isIncrementOrInitInForLoop(const Stmt *S, const Stmt *FL) { typedef llvm::DenseSet<const PathDiagnosticCallPiece *> OptimizedCallsSet; +void PathPieces::dump() const { + unsigned index = 0; + for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I ) { + llvm::errs() << "[" << index++ << "]"; + + switch ((*I)->getKind()) { + case PathDiagnosticPiece::Call: + llvm::errs() << " CALL\n--------------\n"; + + if (const Stmt *SLoc = getLocStmt((*I)->getLocation())) { + SLoc->dump(); + } else { + const PathDiagnosticCallPiece *Call = cast<PathDiagnosticCallPiece>(*I); + if (const NamedDecl *ND = dyn_cast<NamedDecl>(Call->getCallee())) + llvm::errs() << *ND << "\n"; + } + break; + case PathDiagnosticPiece::Event: + llvm::errs() << " EVENT\n--------------\n"; + llvm::errs() << (*I)->getString() << "\n"; + if (const Stmt *SLoc = getLocStmt((*I)->getLocation())) { + llvm::errs() << " ---- at ----\n"; + SLoc->dump(); + } + break; + case PathDiagnosticPiece::Macro: + llvm::errs() << " MACRO\n--------------\n"; + // FIXME: print which macro is being invoked. + break; + case PathDiagnosticPiece::ControlFlow: { + const PathDiagnosticControlFlowPiece *CP = + cast<PathDiagnosticControlFlowPiece>(*I); + llvm::errs() << " CONTROL\n--------------\n"; + + if (const Stmt *s1Start = getLocStmt(CP->getStartLocation())) + s1Start->dump(); + else + llvm::errs() << "NULL\n"; + + llvm::errs() << " ---- to ----\n"; + + if (const Stmt *s1End = getLocStmt(CP->getEndLocation())) + s1End->dump(); + else + llvm::errs() << "NULL\n"; + + break; + } + } + + llvm::errs() << "\n"; + } +} + static bool optimizeEdges(PathPieces &path, SourceManager &SM, OptimizedCallsSet &OCS, LocationContextMap &LCM) { |