From: Haojian Wu Date: Fri, 14 Dec 2018 13:19:38 +0000 (+0000) Subject: [clangd] Fix memory leak in ClangdTests. X-Git-Tag: llvmorg-8.0.0-rc1~2116 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=23ae22b66927479a8b828f7f580bd02a6113e049;p=platform%2Fupstream%2Fllvm.git [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 --- 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);