xref: /openbsd-src/gnu/llvm/clang/include/clang/Basic/PrettyStackTrace.h (revision e5dd70708596ae51455a0ffa086a00c5b29f8583)
1*e5dd7070Spatrick //===- clang/Basic/PrettyStackTrace.h - Pretty Crash Handling --*- 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 /// \file
10*e5dd7070Spatrick /// Defines the PrettyStackTraceEntry class, which is used to make
11*e5dd7070Spatrick /// crashes give more contextual information about what the program was doing
12*e5dd7070Spatrick /// when it crashed.
13*e5dd7070Spatrick ///
14*e5dd7070Spatrick //===----------------------------------------------------------------------===//
15*e5dd7070Spatrick 
16*e5dd7070Spatrick #ifndef LLVM_CLANG_BASIC_PRETTYSTACKTRACE_H
17*e5dd7070Spatrick #define LLVM_CLANG_BASIC_PRETTYSTACKTRACE_H
18*e5dd7070Spatrick 
19*e5dd7070Spatrick #include "clang/Basic/SourceLocation.h"
20*e5dd7070Spatrick #include "llvm/Support/PrettyStackTrace.h"
21*e5dd7070Spatrick 
22*e5dd7070Spatrick namespace clang {
23*e5dd7070Spatrick 
24*e5dd7070Spatrick   /// If a crash happens while one of these objects are live, the message
25*e5dd7070Spatrick   /// is printed out along with the specified source location.
26*e5dd7070Spatrick   class PrettyStackTraceLoc : public llvm::PrettyStackTraceEntry {
27*e5dd7070Spatrick     SourceManager &SM;
28*e5dd7070Spatrick     SourceLocation Loc;
29*e5dd7070Spatrick     const char *Message;
30*e5dd7070Spatrick   public:
PrettyStackTraceLoc(SourceManager & sm,SourceLocation L,const char * Msg)31*e5dd7070Spatrick     PrettyStackTraceLoc(SourceManager &sm, SourceLocation L, const char *Msg)
32*e5dd7070Spatrick       : SM(sm), Loc(L), Message(Msg) {}
33*e5dd7070Spatrick     void print(raw_ostream &OS) const override;
34*e5dd7070Spatrick   };
35*e5dd7070Spatrick }
36*e5dd7070Spatrick 
37*e5dd7070Spatrick #endif
38