mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Hack SourceFile::lookupLocalType() to look through local types.
This is only currently exercised by swift-remoteast-test, so do the minimum to ensure that we’re getting cached mangled names, but don’t fret over the linear-time search.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "swift/AST/PrettyStackTrace.h"
|
||||
#include "swift/AST/PrintOptions.h"
|
||||
#include "swift/AST/ProtocolConformance.h"
|
||||
#include "swift/AST/TypeCheckRequests.h"
|
||||
#include "swift/Basic/Compiler.h"
|
||||
#include "swift/Basic/SourceManager.h"
|
||||
#include "swift/Basic/Statistic.h"
|
||||
@@ -565,6 +566,22 @@ void SourceFile::getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results) const {
|
||||
Results.append(LocalTypeDecls.begin(), LocalTypeDecls.end());
|
||||
}
|
||||
|
||||
TypeDecl *SourceFile::lookupLocalType(llvm::StringRef mangledName) const {
|
||||
ASTContext &ctx = getASTContext();
|
||||
for (auto typeDecl : LocalTypeDecls) {
|
||||
auto typeMangledName = evaluateOrDefault(ctx.evaluator,
|
||||
USRGenerationRequest { typeDecl },
|
||||
std::string());
|
||||
if (typeMangledName.find("s:") == 0)
|
||||
typeMangledName = typeMangledName.substr(2);
|
||||
|
||||
if (mangledName == typeMangledName)
|
||||
return typeDecl;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
|
||||
// FIXME: Should this do extra access control filtering?
|
||||
FORWARD(getDisplayDecls, (Results));
|
||||
|
||||
Reference in New Issue
Block a user