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