1 //==- PrettyStackTraceLocationContext.h - show analysis backtrace --*- C++ -*-// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H 11 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H 12 13 #include "clang/Analysis/AnalysisContext.h" 14 15 namespace clang { 16 namespace ento { 17 18 /// While alive, includes the current analysis stack in a crash trace. 19 /// 20 /// Example: 21 /// \code 22 /// 0. Program arguments: ... 23 /// 1. <eof> parser at end of file 24 /// 2. While analyzing stack: 25 /// #0 void inlined() 26 /// #1 void test() 27 /// 3. crash-trace.c:6:3: Error evaluating statement 28 /// \endcode 29 class PrettyStackTraceLocationContext : public llvm::PrettyStackTraceEntry { 30 const LocationContext *LCtx; 31 public: PrettyStackTraceLocationContext(const LocationContext * LC)32 PrettyStackTraceLocationContext(const LocationContext *LC) : LCtx(LC) { 33 assert(LCtx); 34 } 35 print(raw_ostream & OS)36 void print(raw_ostream &OS) const override { 37 OS << "While analyzing stack: \n"; 38 LCtx->dumpStack(OS, "\t"); 39 } 40 }; 41 42 } // end ento namespace 43 } // end clang namespace 44 45 #endif 46