From 52df1a551a279565f000d3c88e099e1bee5d030d Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 7 Aug 2024 17:47:27 +0200 Subject: [PATCH] Globally enable incremental extensions We are relying on this since a while, for example for reemission of template symbols. At the moment, we get the incremental extensions because Preprocessor::enableIncrementalProcessing() turns them on internally, but this will change with LLVM 18 where this method only controls incremental processing of a single Preprocessor object. --- include/cling/Utils/ParserStateRAII.h | 1 - lib/Interpreter/CIFactory.cpp | 2 ++ lib/Interpreter/IncrementalParser.cpp | 1 - lib/Interpreter/Interpreter.cpp | 3 --- lib/Interpreter/LookupHelper.cpp | 9 --------- lib/Utils/ParserStateRAII.cpp | 3 --- 6 files changed, 2 insertions(+), 17 deletions(-) diff --git a/include/cling/Utils/ParserStateRAII.h b/include/cling/Utils/ParserStateRAII.h index cb38f79d4e..9457585740 100644 --- a/include/cling/Utils/ParserStateRAII.h +++ b/include/cling/Utils/ParserStateRAII.h @@ -30,7 +30,6 @@ namespace cling { clang::Parser* P; clang::Preprocessor& PP; decltype(clang::Parser::TemplateIds) OldTemplateIds; - bool ResetIncrementalProcessing; bool PPDiagHadErrors; bool SemaDiagHadErrors; bool OldSuppressAllDiagnostics; diff --git a/lib/Interpreter/CIFactory.cpp b/lib/Interpreter/CIFactory.cpp index c4aced66da..aec79e1f19 100644 --- a/lib/Interpreter/CIFactory.cpp +++ b/lib/Interpreter/CIFactory.cpp @@ -396,6 +396,8 @@ namespace { // Opts.StackProtector = 0; #endif // _MSC_VER + Opts.IncrementalExtensions = 1; + Opts.Exceptions = 1; if (Opts.CPlusPlus) { Opts.CXXExceptions = 1; diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index 8f7adb2a86..89cd78d39c 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -870,7 +870,6 @@ namespace cling { nullptr, SourceLocation()); } assert(PP.isIncrementalProcessingEnabled() && "Not in incremental mode!?"); - PP.enableIncrementalProcessing(); smallstream source_name; // FIXME: Pre-increment to avoid failing tests. diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index 4cfed18bcd..1e58d431ab 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -266,9 +266,6 @@ namespace cling { Sema& SemaRef = getSema(); Preprocessor& PP = SemaRef.getPreprocessor(); - // Enable incremental processing, which prevents the preprocessor destroying - // the lexer on EOF token. - PP.enableIncrementalProcessing(); m_LookupHelper.reset(new LookupHelper(new Parser(PP, SemaRef, /*SkipFunctionBodies*/false, diff --git a/lib/Interpreter/LookupHelper.cpp b/lib/Interpreter/LookupHelper.cpp index d8d322c8d6..f94f2e1f8a 100644 --- a/lib/Interpreter/LookupHelper.cpp +++ b/lib/Interpreter/LookupHelper.cpp @@ -89,15 +89,6 @@ namespace cling { // Tell the parser to not attempt spelling correction. // const_cast(PP.getLangOpts()).SpellChecking = 0; - // - // Turn on ignoring of the main file eof token. - // - // Note: We need this because token readahead in the following - // routine calls ends up parsing it multiple times. - // - if (!PP.isIncrementalProcessingEnabled()) { - PP.enableIncrementalProcessing(); - } assert(!code.empty() && "prepareForParsing should only be called when need"); diff --git a/lib/Utils/ParserStateRAII.cpp b/lib/Utils/ParserStateRAII.cpp index d0eae48198..dc7d8aabda 100644 --- a/lib/Utils/ParserStateRAII.cpp +++ b/lib/Utils/ParserStateRAII.cpp @@ -16,8 +16,6 @@ using namespace clang; cling::ParserStateRAII::ParserStateRAII(Parser& p, bool skipToEOF) : P(&p), PP(p.getPreprocessor()), - ResetIncrementalProcessing(p.getPreprocessor() - .isIncrementalProcessingEnabled()), PPDiagHadErrors(PP.getDiagnostics().hasErrorOccurred()), SemaDiagHadErrors(P->getActions().getDiagnostics().hasErrorOccurred()), OldSuppressAllDiagnostics(P->getActions().getDiagnostics() @@ -61,7 +59,6 @@ cling::ParserStateRAII::~ParserStateRAII() { P->SkipUntil(tok::eof); else P->Tok = OldTok; - PP.enableIncrementalProcessing(ResetIncrementalProcessing); if (!SemaDiagHadErrors) { // Doesn't reset the diagnostic mappings P->getActions().getDiagnostics().Reset(/*soft=*/true);