@@ -35,28 +35,25 @@ using namespace swift;
35
35
36
36
void PrettyStackTraceDecl::print (llvm::raw_ostream &out) const {
37
37
out << " While " << Action << ' ' ;
38
- if (!TheDecl) {
39
- out << " NULL declaration!\n " ;
40
- return ;
41
- }
42
- printDeclDescription (out, TheDecl, TheDecl->getASTContext ());
38
+ printDeclDescription (out, TheDecl);
43
39
}
44
40
45
41
void PrettyStackTraceDeclAndSubst::print (llvm::raw_ostream &out) const {
46
42
out << " While " << action << ' ' ;
47
- if (!decl) {
48
- out << " NULL declaration!\n " ;
49
- return ;
50
- }
51
- printDeclDescription (out, decl, decl->getASTContext ());
43
+ printDeclDescription (out, decl);
52
44
53
45
out << " with substitution map: " ;
54
46
subst.dump (out);
55
47
}
56
48
57
49
58
50
void swift::printDeclDescription (llvm::raw_ostream &out, const Decl *D,
59
- const ASTContext &Context, bool addNewline) {
51
+ bool addNewline) {
52
+ if (!D) {
53
+ out << " NULL declaration!" ;
54
+ if (addNewline) out << ' \n ' ;
55
+ return ;
56
+ }
60
57
SourceLoc loc = D->getStartLoc ();
61
58
bool hasPrintedName = false ;
62
59
if (auto *named = dyn_cast<ValueDecl>(D)) {
@@ -114,7 +111,7 @@ void swift::printDeclDescription(llvm::raw_ostream &out, const Decl *D,
114
111
115
112
if (loc.isValid ()) {
116
113
out << " (at " ;
117
- loc.print (out, Context .SourceMgr );
114
+ loc.print (out, D-> getASTContext () .SourceMgr );
118
115
out << ' )' ;
119
116
} else {
120
117
out << " (in module '" << D->getModuleContext ()->getName () << " ')" ;
@@ -124,25 +121,25 @@ void swift::printDeclDescription(llvm::raw_ostream &out, const Decl *D,
124
121
125
122
void PrettyStackTraceAnyFunctionRef::print (llvm::raw_ostream &out) const {
126
123
out << " While " << Action << ' ' ;
127
- auto &Context = TheRef.getAsDeclContext ()->getASTContext ();
128
- if (auto *AFD = TheRef.getAbstractFunctionDecl ())
129
- printDeclDescription (out, AFD, Context);
130
- else {
124
+ if (auto *AFD = TheRef.getAbstractFunctionDecl ()) {
125
+ printDeclDescription (out, AFD);
126
+ } else {
131
127
auto *ACE = TheRef.getAbstractClosureExpr ();
132
- printExprDescription (out, ACE, Context );
128
+ printExprDescription (out, ACE, ACE-> getASTContext () );
133
129
}
134
130
}
135
131
136
132
void PrettyStackTraceFreestandingMacroExpansion::print (
137
133
llvm::raw_ostream &out) const {
138
134
out << " While " << Action << ' ' ;
139
- auto &Context = Expansion->getDeclContext ()->getASTContext ();
140
135
switch (Expansion->getFreestandingMacroKind ()) {
141
- case FreestandingMacroKind::Expr:
136
+ case FreestandingMacroKind::Expr: {
137
+ auto &Context = Expansion->getDeclContext ()->getASTContext ();
142
138
printExprDescription (out, cast<MacroExpansionExpr>(Expansion), Context);
143
139
break ;
140
+ }
144
141
case FreestandingMacroKind::Decl:
145
- printDeclDescription (out, cast<MacroExpansionDecl>(Expansion), Context );
142
+ printDeclDescription (out, cast<MacroExpansionDecl>(Expansion));
146
143
break ;
147
144
}
148
145
}
@@ -277,7 +274,7 @@ void swift::printConformanceDescription(llvm::raw_ostream &out,
277
274
}
278
275
279
276
out << " protocol conformance to " ;
280
- printDeclDescription (out, conformance->getProtocol (), ctxt, /* newline*/ false );
277
+ printDeclDescription (out, conformance->getProtocol (), /* newline*/ false );
281
278
out << " for " ;
282
279
printTypeDescription (out, conformance->getType (), ctxt, addNewline);
283
280
}
0 commit comments