Skip to content

Commit

Permalink
Globally enable incremental extensions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hahnjo authored and jenkins committed Aug 9, 2024
1 parent 9c3ae91 commit 52df1a5
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion include/cling/Utils/ParserStateRAII.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ namespace {
// Opts.StackProtector = 0;
#endif // _MSC_VER

Opts.IncrementalExtensions = 1;

Opts.Exceptions = 1;
if (Opts.CPlusPlus) {
Opts.CXXExceptions = 1;
Expand Down
1 change: 0 additions & 1 deletion lib/Interpreter/IncrementalParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions lib/Interpreter/LookupHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@ namespace cling {
// Tell the parser to not attempt spelling correction.
//
const_cast<LangOptions&>(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");

Expand Down
3 changes: 0 additions & 3 deletions lib/Utils/ParserStateRAII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 52df1a5

Please sign in to comment.