From: Hans Wennborg Date: Fri, 2 May 2014 22:55:30 +0000 (+0000) Subject: Fix clang-cl Driver leak X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0c0ad648202f40b99e826d2c116cc1b307a6d13;p=clang Fix clang-cl Driver leak We were synthesizing new arguments from e.g. '/Tcfile.c' arguments, but didn't handle ownership correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207880 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 044872591f..960e5c019a 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -259,7 +259,7 @@ public: /// \param Args - The input arguments. /// \param Inputs - The list to store the resulting compilation /// inputs onto. - void BuildInputs(const ToolChain &TC, const llvm::opt::DerivedArgList &Args, + void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args, InputList &Inputs) const; /// BuildActions - Construct the list of actions to perform for the diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index a238e37c1d..44c41b6b69 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -190,10 +190,11 @@ const { return FinalPhase; } -static Arg* MakeInputArg(const DerivedArgList &Args, OptTable *Opts, +static Arg* MakeInputArg(DerivedArgList &Args, OptTable *Opts, StringRef Value) { Arg *A = new Arg(Opts->getOption(options::OPT_INPUT), Value, Args.getBaseArgs().MakeIndex(Value), Value.data()); + Args.AddSynthesizedArg(A); A->claim(); return A; } @@ -956,7 +957,7 @@ static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args, } // Construct a the list of inputs and their types. -void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args, +void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, InputList &Inputs) const { // Track the current user specified (-x) input. We also explicitly track the // argument used to set the type; we only want to claim the type when we