Clang Project

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