[PATCH] D55702: [clangd] Fix memory leak in ClangdTests.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 14 04:37:26 PST 2018


hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.

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.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55702

Files:
  unittests/clangd/TestTU.cpp


Index: unittests/clangd/TestTU.cpp
===================================================================
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -38,8 +38,10 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55702.178219.patch
Type: text/x-patch
Size: 795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181214/a71a5ebb/attachment.bin>


More information about the cfe-commits mailing list