mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user