Skip to content

Commit

Permalink
Revert "[Parse] Split incremental-extensions" (#66281)
Browse files Browse the repository at this point in the history
This reverts commit c2fb112, which
breaks:
```
lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py
lldb-api.lang/objc/modules.TestObjCModules.py
lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py
lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py
lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py
```
  • Loading branch information
bnbarham committed Sep 13, 2023
1 parent 2505904 commit f8ced20
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
10 changes: 5 additions & 5 deletions clang/include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@ class Preprocessor {
/// Empty line handler.
EmptylineHandler *Emptyline = nullptr;

/// True to avoid tearing down the lexer etc on EOF
bool IncrementalProcessing = false;

public:
/// The kind of translation unit we are processing.
const TranslationUnitKind TUKind;
Expand Down Expand Up @@ -1913,11 +1910,14 @@ class Preprocessor {
void recomputeCurLexerKind();

/// Returns true if incremental processing is enabled
bool isIncrementalProcessingEnabled() const { return IncrementalProcessing; }
bool isIncrementalProcessingEnabled() const {
return getLangOpts().IncrementalExtensions;
}

/// Enables the incremental processing
void enableIncrementalProcessing(bool value = true) {
IncrementalProcessing = value;
// FIXME: Drop this interface.
const_cast<LangOptions &>(getLangOpts()).IncrementalExtensions = value;
}

/// Specify the point at which code-completion will be performed.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Lex/PPLexerChange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
Result.startToken();
CurLexer->BufferPtr = EndPos;

if (getLangOpts().IncrementalExtensions) {
if (isIncrementalProcessingEnabled()) {
CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_repl_input_end);
Result.setAnnotationEndLoc(Result.getLocation());
Result.setAnnotationValue(nullptr);
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Lex/Preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
Ident_AbnormalTermination = nullptr;
}

// Default incremental processing to -fincremental-extensions, clients can
// override with `enableIncrementalProcessing` if desired.
IncrementalProcessing = LangOpts.IncrementalExtensions;

// If using a PCH where a #pragma hdrstop is expected, start skipping tokens.
if (usingPCHWithPragmaHdrStop())
SkippingUntilPragmaHdrStop = true;
Expand Down
10 changes: 2 additions & 8 deletions clang/lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,6 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
Sema::ModuleImportState &ImportState) {
DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);

// Skip over the EOF token, flagging end of previous input for incremental
// processing
if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
ConsumeToken();

Result = nullptr;
switch (Tok.getKind()) {
case tok::annot_pragma_unused:
Expand Down Expand Up @@ -711,8 +706,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,

// Late template parsing can begin.
Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
if (!PP.isIncrementalProcessingEnabled())
Actions.ActOnEndOfTranslationUnit();
Actions.ActOnEndOfTranslationUnit();
//else don't tell Sema that we ended parsing: more input might come.
return true;

Expand Down Expand Up @@ -1044,7 +1038,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
ConsumeToken();
return nullptr;
}
if (getLangOpts().IncrementalExtensions &&
if (PP.isIncrementalProcessingEnabled() &&
!isDeclarationStatement(/*DisambiguatingWithExpression=*/true))
return ParseTopLevelStmtDecl();

Expand Down

0 comments on commit f8ced20

Please sign in to comment.