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