r207899 - [leaks] Don't leak the fake arguments we synthesize for LLVM option

Chandler Carruth chandlerc at gmail.com
Sat May 3 01:39:35 PDT 2014


Author: chandlerc
Date: Sat May  3 03:39:35 2014
New Revision: 207899

URL: http://llvm.org/viewvc/llvm-project?rev=207899&view=rev
Log:
[leaks] Don't leak the fake arguments we synthesize for LLVM option
parsing.

Modified:
    cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=207899&r1=207898&r2=207899&view=diff
==============================================================================
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Sat May  3 03:39:35 2014
@@ -212,12 +212,12 @@ bool clang::ExecuteCompilerInvocation(Co
   // This should happen AFTER plugins have been loaded!
   if (!Clang->getFrontendOpts().LLVMArgs.empty()) {
     unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size();
-    const char **Args = new const char*[NumArgs + 2];
+    auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
     Args[0] = "clang (LLVM option parsing)";
     for (unsigned i = 0; i != NumArgs; ++i)
       Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str();
     Args[NumArgs + 1] = 0;
-    llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args);
+    llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
   }
 
 #ifdef CLANG_ENABLE_STATIC_ANALYZER





More information about the cfe-commits mailing list