mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sink private-file import support down to SerializedASTFile
Implementing it in LoadedFile is nice in theory, but causes a leak in practice because that type is ASTContext-allocated and usually never destroyed. https://bugs.swift.org/browse/SR-11366
This commit is contained in:
@@ -1387,28 +1387,14 @@ protected:
|
||||
: FileUnit(Kind, M) {
|
||||
assert(classof(this) && "invalid kind");
|
||||
}
|
||||
|
||||
/// A map from private/fileprivate decls to the file they were defined in.
|
||||
llvm::DenseMap<const ValueDecl *, Identifier> FilenameForPrivateDecls;
|
||||
|
||||
public:
|
||||
|
||||
/// Returns an arbitrary string representing the storage backing this file.
|
||||
///
|
||||
/// This is usually a filesystem path.
|
||||
virtual StringRef getFilename() const;
|
||||
|
||||
void addFilenameForPrivateDecl(const ValueDecl *decl, Identifier id) {
|
||||
assert(!FilenameForPrivateDecls.count(decl) ||
|
||||
FilenameForPrivateDecls[decl] == id);
|
||||
FilenameForPrivateDecls[decl] = id;
|
||||
}
|
||||
|
||||
StringRef getFilenameForPrivateDecl(const ValueDecl *decl) {
|
||||
auto it = FilenameForPrivateDecls.find(decl);
|
||||
if (it == FilenameForPrivateDecls.end())
|
||||
return StringRef();
|
||||
return it->second.str();
|
||||
virtual StringRef getFilenameForPrivateDecl(const ValueDecl *decl) const {
|
||||
return StringRef();
|
||||
}
|
||||
|
||||
/// Look up an operator declaration.
|
||||
|
||||
Reference in New Issue
Block a user