/
PrettyStackTrace.h
134 lines (116 loc) · 4.37 KB
/
PrettyStackTrace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//===--- PrettyStackTrace.h - Crash trace information -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines RAII classes that give better diagnostic output
// about when, exactly, a crash is occurring.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_PRETTYSTACKTRACE_H
#define SWIFT_PRETTYSTACKTRACE_H
#include "llvm/Support/PrettyStackTrace.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/AST/Type.h"
namespace swift {
class ASTContext;
class Decl;
class Expr;
class Pattern;
class Stmt;
class TypeRepr;
void printSourceLocDescription(llvm::raw_ostream &out, SourceLoc loc,
ASTContext &Context);
/// PrettyStackTraceLocation - Observe that we are doing some
/// processing starting at a fixed location.
class PrettyStackTraceLocation : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
SourceLoc Loc;
const char *Action;
public:
PrettyStackTraceLocation(ASTContext &C, const char *action, SourceLoc loc)
: Context(C), Loc(loc), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
void printDeclDescription(llvm::raw_ostream &out, const Decl *D,
ASTContext &Context);
/// PrettyStackTraceDecl - Observe that we are processing a specific
/// declaration.
class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
const Decl *TheDecl;
const char *Action;
public:
PrettyStackTraceDecl(const char *action, const Decl *D)
: TheDecl(D), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
void printExprDescription(llvm::raw_ostream &out, Expr *E,
ASTContext &Context);
/// PrettyStackTraceExpr - Observe that we are processing a specific
/// expression.
class PrettyStackTraceExpr : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Expr *TheExpr;
const char *Action;
public:
PrettyStackTraceExpr(ASTContext &C, const char *action, Expr *E)
: Context(C), TheExpr(E), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
void printStmtDescription(llvm::raw_ostream &out, Stmt *S,
ASTContext &Context);
/// PrettyStackTraceStmt - Observe that we are processing a specific
/// statement.
class PrettyStackTraceStmt : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Stmt *TheStmt;
const char *Action;
public:
PrettyStackTraceStmt(ASTContext &C, const char *action, Stmt *S)
: Context(C), TheStmt(S), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
void printPatternDescription(llvm::raw_ostream &out, Pattern *P,
ASTContext &Context);
/// PrettyStackTracePattern - Observe that we are processing a
/// specific pattern.
class PrettyStackTracePattern : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Pattern *ThePattern;
const char *Action;
public:
PrettyStackTracePattern(ASTContext &C, const char *action, Pattern *P)
: Context(C), ThePattern(P), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
void printTypeDescription(llvm::raw_ostream &out, Type T,
ASTContext &Context);
/// PrettyStackTraceType - Observe that we are processing a specific type.
class PrettyStackTraceType : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
Type TheType;
const char *Action;
public:
PrettyStackTraceType(ASTContext &C, const char *action, Type type)
: Context(C), TheType(type), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
/// Observe that we are processing a specific type representation.
class PrettyStackTraceTypeRepr : public llvm::PrettyStackTraceEntry {
ASTContext &Context;
TypeRepr *TheType;
const char *Action;
public:
PrettyStackTraceTypeRepr(ASTContext &C, const char *action, TypeRepr *type)
: Context(C), TheType(type), Action(action) {}
virtual void print(llvm::raw_ostream &OS) const;
};
} // end namespace swift
#endif