From 23ae22b66927479a8b828f7f580bd02a6113e049 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 14 Dec 2018 13:19:38 +0000 Subject: [PATCH] [clangd] Fix memory leak in ClangdTests. 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 --- clang-tools-extra/unittests/clangd/TestTU.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/unittests/clangd/TestTU.cpp b/clang-tools-extra/unittests/clangd/TestTU.cpp index e8fb63c..4e14262 100644 --- a/clang-tools-extra/unittests/clangd/TestTU.cpp +++ b/clang-tools-extra/unittests/clangd/TestTU.cpp @@ -38,8 +38,10 @@ ParsedAST TestTU::build() const { Inputs.Contents = Code; Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}}); auto PCHs = std::make_shared(); + 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); -- 2.7.4