[clang-tools-extra] 2045189 - [clangd] Setting recovery-ast flag in buildCompilerInvocation, NFC.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 14 04:17:33 PDT 2020
Author: Haojian Wu
Date: 2020-05-14T13:16:59+02:00
New Revision: 2045189043d4e2748ed82915dd7bdf3e96728738
URL: https://github.com/llvm/llvm-project/commit/2045189043d4e2748ed82915dd7bdf3e96728738
DIFF: https://github.com/llvm/llvm-project/commit/2045189043d4e2748ed82915dd7bdf3e96728738.diff
LOG: [clangd] Setting recovery-ast flag in buildCompilerInvocation, NFC.
This saves some duplicated code (in buildPreamble and buildAST).
Added:
Modified:
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp
index 04d48b08865d..ee9b187258b2 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -82,6 +82,10 @@ buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
CI->getPreprocessorOpts().PCHThroughHeader.clear();
CI->getPreprocessorOpts().PCHWithHdrStop = false;
CI->getPreprocessorOpts().PCHWithHdrStopCreate = false;
+
+ // Recovery expression currently only works for C++.
+ if (CI->getLangOpts()->CPlusPlus)
+ CI->getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
return CI;
}
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index e63f105b1b6c..e7678f3d69e9 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -262,9 +262,6 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
const PrecompiledPreamble *PreamblePCH =
Preamble ? &Preamble->Preamble : nullptr;
- // Recovery expression currently only works for C++.
- if (CI->getLangOpts()->CPlusPlus)
- CI->getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
// This is on-by-default in windows to allow parsing SDK headers, but it
// breaks many features. Disable it for the main-file (not preamble).
CI->getLangOpts()->DelayedTemplateParsing = false;
diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp
index 640a2c66b3c9..9d9c5eff8c68 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -219,10 +219,6 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
// to read back. We rely on dynamic index for the comments instead.
CI.getPreprocessorOpts().WriteCommentListToPCH = false;
- // Recovery expression currently only works for C++.
- if (CI.getLangOpts()->CPlusPlus)
- CI.getLangOpts()->RecoveryAST = Inputs.Opts.BuildRecoveryAST;
-
CppFilePreambleCallbacks SerializedDeclsCollector(FileName, PreambleCallback);
if (Inputs.FS->setCurrentWorkingDirectory(Inputs.CompileCommand.Directory)) {
log("Couldn't set working directory when building the preamble.");
More information about the cfe-commits
mailing list