1*e5dd7070Spatrick //==- PrettyStackTraceLocationContext.h - show analysis backtrace --*- C++ -*-// 2*e5dd7070Spatrick // 3*e5dd7070Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e5dd7070Spatrick // See https://llvm.org/LICENSE.txt for license information. 5*e5dd7070Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e5dd7070Spatrick // 7*e5dd7070Spatrick //===----------------------------------------------------------------------===// 8*e5dd7070Spatrick 9*e5dd7070Spatrick #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H 10*e5dd7070Spatrick #define LLVM_CLANG_LIB_STATICANALYZER_CORE_PRETTYSTACKTRACELOCATIONCONTEXT_H 11*e5dd7070Spatrick 12*e5dd7070Spatrick #include "clang/Analysis/AnalysisDeclContext.h" 13*e5dd7070Spatrick 14*e5dd7070Spatrick namespace clang { 15*e5dd7070Spatrick namespace ento { 16*e5dd7070Spatrick 17*e5dd7070Spatrick /// While alive, includes the current analysis stack in a crash trace. 18*e5dd7070Spatrick /// 19*e5dd7070Spatrick /// Example: 20*e5dd7070Spatrick /// \code 21*e5dd7070Spatrick /// 0. Program arguments: ... 22*e5dd7070Spatrick /// 1. <eof> parser at end of file 23*e5dd7070Spatrick /// 2. While analyzing stack: 24*e5dd7070Spatrick /// #0 void inlined() 25*e5dd7070Spatrick /// #1 void test() 26*e5dd7070Spatrick /// 3. crash-trace.c:6:3: Error evaluating statement 27*e5dd7070Spatrick /// \endcode 28*e5dd7070Spatrick class PrettyStackTraceLocationContext : public llvm::PrettyStackTraceEntry { 29*e5dd7070Spatrick const LocationContext *LCtx; 30*e5dd7070Spatrick public: PrettyStackTraceLocationContext(const LocationContext * LC)31*e5dd7070Spatrick PrettyStackTraceLocationContext(const LocationContext *LC) : LCtx(LC) { 32*e5dd7070Spatrick assert(LCtx); 33*e5dd7070Spatrick } 34*e5dd7070Spatrick print(raw_ostream & Out)35*e5dd7070Spatrick void print(raw_ostream &Out) const override { 36*e5dd7070Spatrick Out << "While analyzing stack: \n"; 37*e5dd7070Spatrick LCtx->dumpStack(Out); 38*e5dd7070Spatrick } 39*e5dd7070Spatrick }; 40*e5dd7070Spatrick 41*e5dd7070Spatrick } // end ento namespace 42*e5dd7070Spatrick } // end clang namespace 43*e5dd7070Spatrick 44*e5dd7070Spatrick #endif 45