r280157 - Fix memory leak by storing returned pointer in std::unique_ptr

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 14:12:48 PDT 2016


Author: rtrieu
Date: Tue Aug 30 16:12:48 2016
New Revision: 280157

URL: http://llvm.org/viewvc/llvm-project?rev=280157&view=rev
Log:
Fix memory leak by storing returned pointer in std::unique_ptr

Modified:
    cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=280157&r1=280156&r2=280157&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Aug 30 16:12:48 2016
@@ -244,10 +244,9 @@ bool ToolInvocation::run() {
   const char *const BinaryName = Argv[0];
   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
   unsigned MissingArgIndex, MissingArgCount;
-  llvm::opt::InputArgList ParsedArgs =
-      driver::createDriverOptTable()->ParseArgs(
-          ArrayRef<const char *>(Argv).slice(1), MissingArgIndex,
-          MissingArgCount);
+  std::unique_ptr<llvm::opt::OptTable> Opts(driver::createDriverOptTable());
+  llvm::opt::InputArgList ParsedArgs = Opts->ParseArgs(
+      ArrayRef<const char *>(Argv).slice(1), MissingArgIndex, MissingArgCount);
   ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
   TextDiagnosticPrinter DiagnosticPrinter(
       llvm::errs(), &*DiagOpts);




More information about the cfe-commits mailing list