Summary:
createInvocationFromCommandLine sets DisableFree to true by default,
which leads memory leak in clangd. The fix is to use the `BuildCompilationInvocation`
to create CI with the correct options (DisableFree is false).
Fix https://bugs.llvm.org/show_bug.cgi?id=39991.
Reviewers: kadircet
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D55702
llvm-svn: 349145
Inputs.Contents = Code;
Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
auto PCHs = std::make_shared<PCHContainerOperations>();
+ auto CI = buildCompilerInvocation(Inputs);
+ assert(CI && "Failed to build compilation invocation.");
auto Preamble =
- buildPreamble(FullFilename, *createInvocationFromCommandLine(Cmd),
+ buildPreamble(FullFilename, *CI,
/*OldPreamble=*/nullptr,
/*OldCompileCommand=*/Inputs.CompileCommand, Inputs, PCHs,
/*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);