Skip to content

Commit 1d49d22

Browse files
committed
Keep the memory allocator local to module loaders, instead of module map parser.
1 parent 7a736f6 commit 1d49d22

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct ExplicitModuleInfo {
191191
// ]
192192
class ExplicitModuleMapParser {
193193
public:
194-
ExplicitModuleMapParser(ASTContext &Ctx) : Ctx(Ctx), Saver(Allocator) {}
194+
ExplicitModuleMapParser(llvm::BumpPtrAllocator &Allocator) : Saver(Allocator) {}
195195

196196
std::error_code
197197
parseSwiftExplicitModuleMap(const StringRef fileName,
@@ -201,9 +201,6 @@ class ExplicitModuleMapParser {
201201
StringRef getScalaNodeText(llvm::yaml::Node *N);
202202
bool parseSingleModuleEntry(llvm::yaml::Node &node,
203203
llvm::StringMap<ExplicitModuleInfo> &moduleMap);
204-
205-
ASTContext &Ctx;
206-
llvm::BumpPtrAllocator Allocator;
207204
llvm::StringSaver Saver;
208205
};
209206

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,11 +1513,12 @@ bool InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleN
15131513

15141514
struct ExplicitSwiftModuleLoader::Implementation {
15151515
ASTContext &Ctx;
1516+
llvm::BumpPtrAllocator Allocator;
15161517
llvm::StringMap<ExplicitModuleInfo> ExplicitModuleMap;
15171518
Implementation(ASTContext &Ctx) : Ctx(Ctx) {}
15181519

15191520
void parseSwiftExplicitModuleMap(StringRef fileName) {
1520-
ExplicitModuleMapParser parser(Ctx);
1521+
ExplicitModuleMapParser parser(Allocator);
15211522
auto result =
15221523
parser.parseSwiftExplicitModuleMap(fileName, ExplicitModuleMap);
15231524
if (result == std::errc::invalid_argument)
@@ -1587,8 +1588,6 @@ std::error_code ExplicitModuleMapParser::parseSwiftExplicitModuleMap(
15871588
}
15881589
}
15891590
} else {
1590-
Ctx.Diags.diagnose(SourceLoc(), diag::explicit_swift_module_map_corrupted,
1591-
fileName);
15921591
return std::make_error_code(std::errc::invalid_argument);
15931592
}
15941593
}

lib/Serialization/ModuleDependencyScanner.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class ExternalSwiftModuleStubScanner : public ModuleDependencyScanner {
102102
/// Scan the given external module map
103103
void parseExternalModuleMap(StringRef fileName);
104104
llvm::StringMap<ExplicitModuleInfo> ExternalDependencyModuleMap;
105+
llvm::BumpPtrAllocator Allocator;
105106

106107
public:
107108
ExternalSwiftModuleStubScanner(ASTContext &ctx, ModuleLoadingMode LoadMode,
@@ -139,17 +140,11 @@ class ExternalSwiftModuleStubScanner : public ModuleDependencyScanner {
139140
this->dependencies = std::move(dependencies);
140141
return std::error_code{};
141142
}
142-
143-
public:
144-
static std::unique_ptr<ExternalSwiftModuleStubScanner>
145-
create(ASTContext &ctx, DependencyTracker *tracker,
146-
ModuleLoadingMode loadMode, StringRef ExternalDependencyModuleMap,
147-
bool IgnoreSwiftSourceInfoFile);
148143
};
149144
} // namespace
150145

151146
void ExternalSwiftModuleStubScanner::parseExternalModuleMap(StringRef fileName) {
152-
ExplicitModuleMapParser parser(Ctx);
147+
ExplicitModuleMapParser parser(Allocator);
153148
auto result =
154149
parser.parseSwiftExplicitModuleMap(fileName, ExternalDependencyModuleMap);
155150
if (result == std::errc::invalid_argument)

0 commit comments

Comments
 (0)