Stop leaking memory from Module and FileUnit.

Also, disallow creating Modules and FileUnits on the stack. They must always
live as long as the ASTContext.

<rdar://problem/15596964>

Swift SVN r13671
This commit is contained in:
Jordan Rose
2014-02-08 02:12:57 +00:00
parent 1e3fd1a5b1
commit cbcf17f9bd
11 changed files with 37 additions and 14 deletions

View File

@@ -33,8 +33,8 @@ bool ide::isSourceInputComplete(std::unique_ptr<llvm::MemoryBuffer> MemBuf) {
ASTContext Ctx(LangOpts, SearchPathOpts, SM, Diags);
auto ModName = Ctx.getIdentifier("input");
Module Mod(ModName, Ctx);
SourceFile SF(Mod, SourceFileKind::Main, BufferID);
Module &Mod = *Module::create(ModName, Ctx);
SourceFile &SF = *new (Ctx) SourceFile(Mod, SourceFileKind::Main, BufferID);
PersistentParserState PersistentState;
Parser P(BufferID, SF, /*SIL=*/nullptr, &PersistentState);