1259701Sdim//==- PrettyStackTraceLocationContext.h - show analysis backtrace --*- C++ -*-// 2259701Sdim// 3259701Sdim// The LLVM Compiler Infrastructure 4259701Sdim// 5259701Sdim// This file is distributed under the University of Illinois Open Source 6259701Sdim// License. See LICENSE.TXT for details. 7259701Sdim// 8259701Sdim//===----------------------------------------------------------------------===// 9259701Sdim 10259701Sdim#ifndef LLVM_CLANG_STATICANALYZER_PRETTYSTACKTRACELOCATIONCONTEXT_H 11259701Sdim#define LLVM_CLANG_STATICANALYZER_PRETTYSTACKTRACELOCATIONCONTEXT_H 12259701Sdim 13259701Sdim#include "clang/Analysis/AnalysisContext.h" 14259701Sdim 15259701Sdimnamespace clang { 16259701Sdimnamespace ento { 17259701Sdim 18259701Sdim/// While alive, includes the current analysis stack in a crash trace. 19259701Sdim/// 20259701Sdim/// Example: 21259701Sdim/// \code 22259701Sdim/// 0. Program arguments: ... 23259701Sdim/// 1. <eof> parser at end of file 24259701Sdim/// 2. While analyzing stack: 25259701Sdim/// #0 void inlined() 26259701Sdim/// #1 void test() 27259701Sdim/// 3. crash-trace.c:6:3: Error evaluating statement 28259701Sdim/// \endcode 29259701Sdimclass PrettyStackTraceLocationContext : public llvm::PrettyStackTraceEntry { 30259701Sdim const LocationContext *LCtx; 31259701Sdimpublic: 32259701Sdim PrettyStackTraceLocationContext(const LocationContext *LC) : LCtx(LC) { 33259701Sdim assert(LCtx); 34259701Sdim } 35259701Sdim 36259701Sdim virtual void print(raw_ostream &OS) const { 37259701Sdim OS << "While analyzing stack: \n"; 38259701Sdim LCtx->dumpStack(OS, "\t"); 39259701Sdim } 40259701Sdim}; 41259701Sdim 42259701Sdim} // end ento namespace 43259701Sdim} // end clang namespace 44259701Sdim 45259701Sdim#endif 46