[clangd] Setting recovery-ast flag in buildCompilerInvocation, NFC.
authorHaojian Wu <hokein.wu@gmail.com>
Thu, 14 May 2020 11:08:59 +0000 (13:08 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Thu, 14 May 2020 11:16:59 +0000 (13:16 +0200)
This saves some duplicated code (in buildPreamble and buildAST).

clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp

index 04d48b0..ee9b187 100644 (file)
@@ -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;
 }
 
index e63f105..e7678f3 100644 (file)
@@ -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;
index 640a2c6..9d9c5ef 100644 (file)
@@ -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.");