// BugReporter.cpp - Generate PathDiagnostics for Bugs ------------*- C++ -*--////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file defines BugReporter, a utility class for generating// PathDiagnostics for analyses based on GRSimpleVals.////===----------------------------------------------------------------------===//#include"clang/Analysis/PathSensitive/BugReporter.h"#include"clang/Analysis/PathSensitive/GRExprEngine.h"#include"clang/Basic/SourceManager.h"#include"clang/Basic/SourceLocation.h"#include"clang/AST/ASTContext.h"#include"clang/AST/CFG.h"#include"clang/AST/Expr.h"#include"clang/AST/ParentMap.h"#include"clang/Analysis/ProgramPoint.h"#include"clang/Analysis/PathDiagnostic.h"#include"llvm/Support/raw_ostream.h"#include"llvm/ADT/DenseMap.h"#include"llvm/ADT/STLExtras.h"#include"llvm/ADT/OwningPtr.h"#include<queue>usingnamespaceclang;//===----------------------------------------------------------------------===//// Helper routines for walking the ExplodedGraph and fetching statements.//===----------------------------------------------------------------------===//staticinlineStmt*GetStmt(ProgramPointP){if(constPostStmt*PS=dyn_cast<PostStmt>(&P))returnPS->getStmt();elseif(constBlockEdge*BE=dyn_cast<BlockEdge>(&P))returnBE->getSrc()->getTerminator();return0;}staticinlineconstExplodedNode<GRState>*GetPredecessorNode(constExplodedNode<GRState>*N){returnN->pred_empty()?NULL:*(N->pred_begin());}staticinlineconstExplodedNode<GRState>*GetSuccessorNode(constExplodedNode<GRState>*N){returnN->succ_empty()?NULL:*(N->succ_begin());}staticStmt*GetPreviousStmt(constExplodedNode<GRState>*N){for(N