xref: /freebsd/contrib/llvm-project/clang/include/clang/AST/PrettyDeclStackTrace.h (revision 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)
1*0b57cec5SDimitry Andric //===- PrettyDeclStackTrace.h - Stack trace for decl processing -*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric //
9*0b57cec5SDimitry Andric // This file defines an llvm::PrettyStackTraceEntry object for showing
10*0b57cec5SDimitry Andric // that a particular declaration was being processed when a crash
11*0b57cec5SDimitry Andric // occurred.
12*0b57cec5SDimitry Andric //
13*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
14*0b57cec5SDimitry Andric 
15*0b57cec5SDimitry Andric #ifndef LLVM_CLANG_AST_PRETTYDECLSTACKTRACE_H
16*0b57cec5SDimitry Andric #define LLVM_CLANG_AST_PRETTYDECLSTACKTRACE_H
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric #include "clang/Basic/SourceLocation.h"
19*0b57cec5SDimitry Andric #include "llvm/Support/PrettyStackTrace.h"
20*0b57cec5SDimitry Andric 
21*0b57cec5SDimitry Andric namespace clang {
22*0b57cec5SDimitry Andric 
23*0b57cec5SDimitry Andric class ASTContext;
24*0b57cec5SDimitry Andric class Decl;
25*0b57cec5SDimitry Andric 
26*0b57cec5SDimitry Andric /// PrettyDeclStackTraceEntry - If a crash occurs in the parser while
27*0b57cec5SDimitry Andric /// parsing something related to a declaration, include that
28*0b57cec5SDimitry Andric /// declaration in the stack trace.
29*0b57cec5SDimitry Andric class PrettyDeclStackTraceEntry : public llvm::PrettyStackTraceEntry {
30*0b57cec5SDimitry Andric   ASTContext &Context;
31*0b57cec5SDimitry Andric   Decl *TheDecl;
32*0b57cec5SDimitry Andric   SourceLocation Loc;
33*0b57cec5SDimitry Andric   const char *Message;
34*0b57cec5SDimitry Andric 
35*0b57cec5SDimitry Andric public:
PrettyDeclStackTraceEntry(ASTContext & Ctx,Decl * D,SourceLocation Loc,const char * Msg)36*0b57cec5SDimitry Andric   PrettyDeclStackTraceEntry(ASTContext &Ctx, Decl *D, SourceLocation Loc,
37*0b57cec5SDimitry Andric                             const char *Msg)
38*0b57cec5SDimitry Andric     : Context(Ctx), TheDecl(D), Loc(Loc), Message(Msg) {}
39*0b57cec5SDimitry Andric 
40*0b57cec5SDimitry Andric   void print(raw_ostream &OS) const override;
41*0b57cec5SDimitry Andric };
42*0b57cec5SDimitry Andric 
43*0b57cec5SDimitry Andric }
44*0b57cec5SDimitry Andric 
45*0b57cec5SDimitry Andric #endif
46