Skip to content

Commit f8ced20

Browse files
authored
Revert "[Parse] Split incremental-extensions" (#66281)
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 ```
1 parent 2505904 commit f8ced20

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

clang/include/clang/Lex/Preprocessor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ class Preprocessor {
277277
/// Empty line handler.
278278
EmptylineHandler *Emptyline = nullptr;
279279

280-
/// True to avoid tearing down the lexer etc on EOF
281-
bool IncrementalProcessing = false;
282-
283280
public:
284281
/// The kind of translation unit we are processing.
285282
const TranslationUnitKind TUKind;
@@ -1913,11 +1910,14 @@ class Preprocessor {
19131910
void recomputeCurLexerKind();
19141911

19151912
/// Returns true if incremental processing is enabled
1916-
bool isIncrementalProcessingEnabled() const { return IncrementalProcessing; }
1913+
bool isIncrementalProcessingEnabled() const {
1914+
return getLangOpts().IncrementalExtensions;
1915+
}
19171916

19181917
/// Enables the incremental processing
19191918
void enableIncrementalProcessing(bool value = true) {
1920-
IncrementalProcessing = value;
1919+
// FIXME: Drop this interface.
1920+
const_cast<LangOptions &>(getLangOpts()).IncrementalExtensions = value;
19211921
}
19221922

19231923
/// Specify the point at which code-completion will be performed.

clang/lib/Lex/PPLexerChange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
541541
Result.startToken();
542542
CurLexer->BufferPtr = EndPos;
543543

544-
if (getLangOpts().IncrementalExtensions) {
544+
if (isIncrementalProcessingEnabled()) {
545545
CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_repl_input_end);
546546
Result.setAnnotationEndLoc(Result.getLocation());
547547
Result.setAnnotationValue(nullptr);

clang/lib/Lex/Preprocessor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
146146
Ident_AbnormalTermination = nullptr;
147147
}
148148

149-
// Default incremental processing to -fincremental-extensions, clients can
150-
// override with `enableIncrementalProcessing` if desired.
151-
IncrementalProcessing = LangOpts.IncrementalExtensions;
152-
153149
// If using a PCH where a #pragma hdrstop is expected, start skipping tokens.
154150
if (usingPCHWithPragmaHdrStop())
155151
SkippingUntilPragmaHdrStop = true;

clang/lib/Parse/Parser.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,6 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
615615
Sema::ModuleImportState &ImportState) {
616616
DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
617617

618-
// Skip over the EOF token, flagging end of previous input for incremental
619-
// processing
620-
if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
621-
ConsumeToken();
622-
623618
Result = nullptr;
624619
switch (Tok.getKind()) {
625620
case tok::annot_pragma_unused:
@@ -711,8 +706,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
711706

712707
// Late template parsing can begin.
713708
Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
714-
if (!PP.isIncrementalProcessingEnabled())
715-
Actions.ActOnEndOfTranslationUnit();
709+
Actions.ActOnEndOfTranslationUnit();
716710
//else don't tell Sema that we ended parsing: more input might come.
717711
return true;
718712

@@ -1044,7 +1038,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
10441038
ConsumeToken();
10451039
return nullptr;
10461040
}
1047-
if (getLangOpts().IncrementalExtensions &&
1041+
if (PP.isIncrementalProcessingEnabled() &&
10481042
!isDeclarationStatement(/*DisambiguatingWithExpression=*/true))
10491043
return ParseTopLevelStmtDecl();
10501044

0 commit comments

Comments
 (0)