diff --git a/lib/Interpreter/CIFactory.cpp b/lib/Interpreter/CIFactory.cpp index 7490b68f..90f8c99d 100644 --- a/lib/Interpreter/CIFactory.cpp +++ b/lib/Interpreter/CIFactory.cpp @@ -731,7 +731,7 @@ namespace { const SrcMgr::ContentCache* MainFileCC = MainFileSLocE.getFile().getContentCache(); if (!Buffer) - Buffer = llvm::MemoryBuffer::getMemBuffer("/*CLING DEFAULT MEMBUF*/\n"); + Buffer = llvm::MemoryBuffer::getMemBuffer("/*CLING DEFAULT MEMBUF*/;\n"); const_cast(MainFileCC)->setBuffer(std::move(Buffer)); // Set up the preprocessor diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index 3679ded2..5d2e5be9 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -177,6 +177,11 @@ namespace cling { if (External) External->StartTranslationUnit(m_Consumer); + Parser::DeclGroupPtrTy ADecl; + // Start parsing the "main file" to warm up lexing (enter caching lex mode + // for ParseInternal()'s call EnterSourceFile() to make sense. + while (!m_Parser->ParseTopLevelDecl(ADecl)) {} + // If I belong to the parent Interpreter, only then do // the #include if (!isChildInterpreter && m_CI->getLangOpts().CPlusPlus) {