Skip to content

Commit 85275d2

Browse files
authored
Add some more PrettyStackTrace entries to AST (#17208)
No functionality change.
1 parent fb8c815 commit 85275d2

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

include/swift/AST/PrettyStackTrace.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "llvm/Support/PrettyStackTrace.h"
2222
#include "swift/Basic/SourceLoc.h"
23+
#include "swift/AST/Identifier.h"
2324
#include "swift/AST/Type.h"
2425

2526
namespace swift {
@@ -148,6 +149,15 @@ class PrettyStackTraceGenericSignature : public llvm::PrettyStackTraceEntry {
148149
void print(llvm::raw_ostream &out) const override;
149150
};
150151

152+
class PrettyStackTraceSelector : public llvm::PrettyStackTraceEntry {
153+
ObjCSelector Selector;
154+
const char *Action;
155+
public:
156+
PrettyStackTraceSelector(const char *action, ObjCSelector S)
157+
: Selector(S), Action(action) {}
158+
void print(llvm::raw_ostream &OS) const override;
159+
};
160+
151161
} // end namespace swift
152162

153163
#endif

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/AST/ModuleLoader.h"
3131
#include "swift/AST/NameLookup.h"
3232
#include "swift/AST/ParameterList.h"
33+
#include "swift/AST/PrettyStackTrace.h"
3334
#include "swift/AST/ProtocolConformance.h"
3435
#include "swift/AST/RawComment.h"
3536
#include "swift/AST/SubstitutionMap.h"
@@ -1401,6 +1402,7 @@ void ASTContext::addModuleLoader(std::unique_ptr<ModuleLoader> loader,
14011402

14021403
void ASTContext::loadExtensions(NominalTypeDecl *nominal,
14031404
unsigned previousGeneration) {
1405+
PrettyStackTraceDecl stackTrace("loading extensions for", nominal);
14041406
for (auto &loader : getImpl().ModuleLoaders) {
14051407
loader->loadExtensions(nominal, previousGeneration);
14061408
}
@@ -1412,6 +1414,8 @@ void ASTContext::loadObjCMethods(
14121414
bool isInstanceMethod,
14131415
unsigned previousGeneration,
14141416
llvm::TinyPtrVector<AbstractFunctionDecl *> &methods) {
1417+
PrettyStackTraceSelector stackTraceSelector("looking for", selector);
1418+
PrettyStackTraceDecl stackTraceDecl("...in", classDecl);
14151419
for (auto &loader : getImpl().ModuleLoaders) {
14161420
loader->loadObjCMethods(classDecl, selector, isInstanceMethod,
14171421
previousGeneration, methods);

lib/AST/PrettyStackTrace.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,7 @@ void PrettyStackTraceGenericSignature::print(llvm::raw_ostream &out) const {
221221
}
222222
out << '\n';
223223
}
224+
225+
void PrettyStackTraceSelector::print(llvm::raw_ostream &out) const {
226+
out << "While " << Action << " '" << Selector << "'";
227+
}

0 commit comments

Comments
 (0)