mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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:
@@ -1052,6 +1052,8 @@ public:
|
|||||||
virtual void
|
virtual void
|
||||||
getPrecedenceGroups(SmallVectorImpl<PrecedenceGroupDecl*> &results) const override;
|
getPrecedenceGroups(SmallVectorImpl<PrecedenceGroupDecl*> &results) const override;
|
||||||
|
|
||||||
|
virtual TypeDecl *lookupLocalType(llvm::StringRef MangledName) const override;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &results) const override;
|
getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &results) const override;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "swift/AST/PrettyStackTrace.h"
|
#include "swift/AST/PrettyStackTrace.h"
|
||||||
#include "swift/AST/PrintOptions.h"
|
#include "swift/AST/PrintOptions.h"
|
||||||
#include "swift/AST/ProtocolConformance.h"
|
#include "swift/AST/ProtocolConformance.h"
|
||||||
|
#include "swift/AST/TypeCheckRequests.h"
|
||||||
#include "swift/Basic/Compiler.h"
|
#include "swift/Basic/Compiler.h"
|
||||||
#include "swift/Basic/SourceManager.h"
|
#include "swift/Basic/SourceManager.h"
|
||||||
#include "swift/Basic/Statistic.h"
|
#include "swift/Basic/Statistic.h"
|
||||||
@@ -565,6 +566,22 @@ void SourceFile::getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results) const {
|
|||||||
Results.append(LocalTypeDecls.begin(), LocalTypeDecls.end());
|
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 {
|
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
|
||||||
// FIXME: Should this do extra access control filtering?
|
// FIXME: Should this do extra access control filtering?
|
||||||
FORWARD(getDisplayDecls, (Results));
|
FORWARD(getDisplayDecls, (Results));
|
||||||
|
|||||||
Reference in New Issue
Block a user