[clang-tools-extra] [clangd] Use TargetOpts from preamble when building ASTs (PR #88381)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 15 08:51:41 PDT 2024


================
@@ -451,6 +451,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
   DiagnosticConsumer *DiagConsumer = &ASTDiags;
   IgnoreDiagnostics DropDiags;
   if (Preamble) {
+    CI->TargetOpts = Preamble->TargetOpts;
     Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble);
----------------
kadircet wrote:

well, idea also crossed my mind while putting together the patch but wasn't so sure if that would be the best place. since preamble-patch'ing was mostly for adjusting the compilation to "patch" changes in the preamble contents.

but considering the fact that this actually needs to be done on all the places that re-uses a preamble (CodeCompletion, SignatureHelp), I guess PreamblePatch is a nice common ground (I was leaning towards `prepareCompilerInstance` but unfortunately that one can't depend on Preamble.h :/)

https://github.com/llvm/llvm-project/pull/88381


More information about the cfe-commits mailing list