PrepareForParsing should no longer be called with empty code

This commit is contained in:
Philippe Canal 2014-09-12 04:20:29 -05:00 committed by sftnight
parent 91e924b262
commit 96029946fc

View File

@ -111,25 +111,25 @@ namespace cling {
if (!PP.isIncrementalProcessingEnabled()) {
PP.enableIncrementalProcessing();
}
if (!code.empty()) {
//
// Create a fake file to parse the type name.
//
llvm::MemoryBuffer* SB
assert(!code.empty()&&"prepareForParsing should only be called when needd");
//
// Create a fake file to parse the type name.
//
llvm::MemoryBuffer* SB
= llvm::MemoryBuffer::getMemBufferCopy(code.str() + "\n",
bufferName.str());
SourceLocation NewLoc = Interp->getNextAvailableLoc();
FileID FID = S.getSourceManager().createFileID(SB, SrcMgr::C_User,
/*LoadedID*/0,
/*LoadedOffset*/0, NewLoc);
//
// Switch to the new file the way #include does.
//
// Note: To switch back to the main file we must consume an eof token.
//
PP.EnterSourceFile(FID, /*DirLookup*/0, NewLoc);
PP.Lex(const_cast<Token&>(P.getCurToken()));
}
SourceLocation NewLoc = Interp->getNextAvailableLoc();
FileID FID = S.getSourceManager().createFileID(SB, SrcMgr::C_User,
/*LoadedID*/0,
/*LoadedOffset*/0, NewLoc);
//
// Switch to the new file the way #include does.
//
// Note: To switch back to the main file we must consume an eof token.
//
PP.EnterSourceFile(FID, /*DirLookup*/0, NewLoc);
PP.Lex(const_cast<Token&>(P.getCurToken()));
}
QualType LookupHelper::findType(llvm::StringRef typeName,