Index: clang/include/clang/Lex/Preprocessor.h =================================================================== --- clang/include/clang/Lex/Preprocessor.h +++ clang/include/clang/Lex/Preprocessor.h @@ -1773,17 +1773,6 @@ /// CurTokenLexer pointers. void recomputeCurLexerKind(); - /// Returns true if incremental processing is enabled - bool isIncrementalProcessingEnabled() const { - return getLangOpts().IncrementalExtensions; - } - - /// Enables the incremental processing - void enableIncrementalProcessing(bool value = true) { - // FIXME: Drop this interface. - const_cast(getLangOpts()).IncrementalExtensions = value; - } - /// Specify the point at which code-completion will be performed. /// /// \param File the file in which code completion should occur. If Index: clang/lib/Interpreter/IncrementalParser.cpp =================================================================== --- clang/lib/Interpreter/IncrementalParser.cpp +++ clang/lib/Interpreter/IncrementalParser.cpp @@ -216,7 +216,7 @@ llvm::Expected IncrementalParser::Parse(llvm::StringRef input) { Preprocessor &PP = CI->getPreprocessor(); - assert(PP.isIncrementalProcessingEnabled() && "Not in incremental mode!?"); + assert(PP.getLangOpts().IncrementalExtensions && "Not in incremental mode!?"); std::ostringstream SourceName; SourceName << "input_line_" << InputCount++; Index: clang/lib/Lex/PPLexerChange.cpp =================================================================== --- clang/lib/Lex/PPLexerChange.cpp +++ clang/lib/Lex/PPLexerChange.cpp @@ -550,12 +550,11 @@ << PPOpts->PCHThroughHeader << 0; } - if (!isIncrementalProcessingEnabled()) + if (!getLangOpts().IncrementalExtensions) { // We're done with lexing. CurLexer.reset(); - - if (!isIncrementalProcessingEnabled()) CurPPLexer = nullptr; + } if (TUKind == TU_Complete) { // This is the end of the top-level file. 'WarnUnusedMacroLocs' has Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -5382,7 +5382,7 @@ } Parser::DeclGroupPtrTy Parser::ParseTopLevelStmtDecl() { - assert(PP.isIncrementalProcessingEnabled() && "Not in incremental mode"); + assert(PP.getLangOpts().IncrementalExtensions && "Not in incremental mode"); // Parse a top-level-stmt. Parser::StmtVector Stmts; Index: clang/lib/Parse/Parser.cpp =================================================================== --- clang/lib/Parse/Parser.cpp +++ clang/lib/Parse/Parser.cpp @@ -614,7 +614,7 @@ // Skip over the EOF token, flagging end of previous input for incremental // processing - if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof)) + if (PP.getLangOpts().IncrementalExtensions && Tok.is(tok::eof)) ConsumeToken(); Result = nullptr; @@ -1028,7 +1028,7 @@ ConsumeToken(); return nullptr; } - if (PP.isIncrementalProcessingEnabled() && + if (PP.getLangOpts().IncrementalExtensions && !isDeclarationStatement(/*DisambiguatingWithExpression=*/true)) return ParseTopLevelStmtDecl(); Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1166,9 +1166,9 @@ }), UnusedFileScopedDecls.end()); + // Translation unit prefixes don't need any of the checking below. if (TUKind == TU_Prefix) { - // Translation unit prefixes don't need any of the checking below. - if (!PP.isIncrementalProcessingEnabled()) + if (!LangOpts.IncrementalExtensions) TUScope = nullptr; return; } @@ -1435,7 +1435,7 @@ assert(ParsingInitForAutoVars.empty() && "Didn't unmark var as having its initializer parsed"); - if (!PP.isIncrementalProcessingEnabled()) + if (TUKind != TU_Incremental) TUScope = nullptr; } Index: clang/unittests/Frontend/FrontendActionTest.cpp =================================================================== --- clang/unittests/Frontend/FrontendActionTest.cpp +++ clang/unittests/Frontend/FrontendActionTest.cpp @@ -30,22 +30,12 @@ class TestASTFrontendAction : public ASTFrontendAction { public: - TestASTFrontendAction(bool enableIncrementalProcessing = false, - bool actOnEndOfTranslationUnit = false) - : EnableIncrementalProcessing(enableIncrementalProcessing), - ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit) { } + TestASTFrontendAction(bool actOnEndOfTranslationUnit = false) + : ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit) {} - bool EnableIncrementalProcessing; bool ActOnEndOfTranslationUnit; std::vector decl_names; - bool BeginSourceFileAction(CompilerInstance &ci) override { - if (EnableIncrementalProcessing) - ci.getPreprocessor().enableIncrementalProcessing(); - - return ASTFrontendAction::BeginSourceFileAction(ci); - } - std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override { return std::make_unique(CI, ActOnEndOfTranslationUnit, @@ -108,11 +98,12 @@ FrontendInputFile("test.cc", Language::CXX)); invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; + invocation->getLangOpts()->IncrementalExtensions = 1; CompilerInstance compiler; compiler.setInvocation(std::move(invocation)); compiler.createDiagnostics(); - TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true); + TestASTFrontendAction test_action; ASSERT_TRUE(compiler.ExecuteAction(test_action)); ASSERT_EQ(2U, test_action.decl_names.size()); EXPECT_EQ("main", test_action.decl_names[0]); @@ -123,6 +114,7 @@ auto invocation = std::make_shared(); invocation->getLangOpts()->CPlusPlus = true; invocation->getLangOpts()->DelayedTemplateParsing = true; + invocation->getLangOpts()->IncrementalExtensions = 1; invocation->getPreprocessorOpts().addRemappedFile( "test.cc", MemoryBuffer::getMemBuffer( "template struct A { A(T); T data; };\n" @@ -139,8 +131,7 @@ compiler.setInvocation(std::move(invocation)); compiler.createDiagnostics(); - TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true, - /*actOnEndOfTranslationUnit=*/true); + TestASTFrontendAction test_action(/*actOnEndOfTranslationUnit=*/true); ASSERT_TRUE(compiler.ExecuteAction(test_action)); ASSERT_EQ(13U, test_action.decl_names.size()); EXPECT_EQ("A", test_action.decl_names[0]); Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -609,7 +609,8 @@ "-target", arch.GetTriple().str(), "-fmodules-validate-system-headers", - "-Werror=non-modular-include-in-framework-module"}; + "-Werror=non-modular-include-in-framework-module", + "-Xclang=-fincremental-extensions"}; target.GetPlatform()->AddClangModuleCompilationOptions( &target, compiler_invocation_arguments); @@ -701,8 +702,6 @@ instance->getFrontendOpts().Inputs[0])) return nullptr; - instance->getPreprocessor().enableIncrementalProcessing(); - instance->createASTReader(); instance->createSema(action->getTranslationUnitKind(), nullptr);