REPL: Create a new MemoryBuffer for each input.

Instead of reusing a fixed-size buffer, which causes problems when error messages refer back to previous inputs and corrupts AST references in *LiteralExpr that point back into source buffers, allocate each REPL input into its own buffer with its own SourceMgr entry. Fixes <rdar://problem/13387167>, crashes when using :dump_ast on expressions containing integer/float literal expr nodes, and hopefully sporadic buildbot failures running the Interpreter/repl test.

Swift SVN r5470
This commit is contained in:
Joe Groff
2013-06-04 18:02:44 +00:00
parent b393311086
commit 49dfa58f37
4 changed files with 23 additions and 23 deletions

View File

@@ -102,14 +102,18 @@ swift::buildSingleTranslationUnit(ASTContext &Context,
bool swift::appendToREPLTranslationUnit(TranslationUnit *TU,
REPLContext &RC,
llvm::MemoryBuffer *Buffer,
unsigned &BufferOffset,
unsigned BufferEndOffset) {
assert(TU->Kind == TranslationUnit::Repl && "Can't append to a non-REPL TU");
RC.CurBufferID
= TU->getASTContext().SourceMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc());
bool FoundAnySideEffects = false;
unsigned CurTUElem = RC.CurTUElem;
do {
FoundAnySideEffects |= parseIntoTranslationUnit(TU, RC.BufferID,
FoundAnySideEffects |= parseIntoTranslationUnit(TU, RC.CurBufferID,
&BufferOffset,
BufferEndOffset);
performNameBinding(TU, CurTUElem);