Skip to content

Add some more PrettyStackTrace entries to AST #17208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/swift/AST/PrettyStackTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "llvm/Support/PrettyStackTrace.h"
#include "swift/Basic/SourceLoc.h"
#include "swift/AST/Identifier.h"
#include "swift/AST/Type.h"

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

class PrettyStackTraceSelector : public llvm::PrettyStackTraceEntry {
ObjCSelector Selector;
const char *Action;
public:
PrettyStackTraceSelector(const char *action, ObjCSelector S)
: Selector(S), Action(action) {}
void print(llvm::raw_ostream &OS) const override;
};

} // end namespace swift

#endif
4 changes: 4 additions & 0 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "swift/AST/ModuleLoader.h"
#include "swift/AST/NameLookup.h"
#include "swift/AST/ParameterList.h"
#include "swift/AST/PrettyStackTrace.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/RawComment.h"
#include "swift/AST/SubstitutionMap.h"
Expand Down Expand Up @@ -1401,6 +1402,7 @@ void ASTContext::addModuleLoader(std::unique_ptr<ModuleLoader> loader,

void ASTContext::loadExtensions(NominalTypeDecl *nominal,
unsigned previousGeneration) {
PrettyStackTraceDecl stackTrace("loading extensions for", nominal);
for (auto &loader : getImpl().ModuleLoaders) {
loader->loadExtensions(nominal, previousGeneration);
}
Expand All @@ -1412,6 +1414,8 @@ void ASTContext::loadObjCMethods(
bool isInstanceMethod,
unsigned previousGeneration,
llvm::TinyPtrVector<AbstractFunctionDecl *> &methods) {
PrettyStackTraceSelector stackTraceSelector("looking for", selector);
PrettyStackTraceDecl stackTraceDecl("...in", classDecl);
for (auto &loader : getImpl().ModuleLoaders) {
loader->loadObjCMethods(classDecl, selector, isInstanceMethod,
previousGeneration, methods);
Expand Down
4 changes: 4 additions & 0 deletions lib/AST/PrettyStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,7 @@ void PrettyStackTraceGenericSignature::print(llvm::raw_ostream &out) const {
}
out << '\n';
}

void PrettyStackTraceSelector::print(llvm::raw_ostream &out) const {
out << "While " << Action << " '" << Selector << "'";
}