(oops, sorry Chandler, accidentally replied rather than reply-all. Re-adding the mailing list)
On Sat, May 3, 2014 at 1:39 AM, Chandler Carruth <[email protected]> wrote: > 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); Would "std::vector<const char*> Args(NumArgs + 2);" be a bit simpler? (yeah, I know, it has resizability which isn't needed here - and the only thing it changes about usage is that it's passed as Args rather than Args.get() to ParseCommandLineOptions below - but at least for me having a local unique_ptr that's not polymorphic and never passed to anywhere strikes me as odd) > 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 > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
