From fd48cb31d409cb1f8e1f119426965e498652e2d1 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 11 Mar 2010 18:04:53 +0000 Subject: [PATCH] Driver: Free synthesized derived arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98262 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/ArgList.h | 2 +- lib/Driver/ArgList.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h index ab1abff740..0a8eaeaf23 100644 --- a/include/clang/Driver/ArgList.h +++ b/include/clang/Driver/ArgList.h @@ -287,7 +287,7 @@ namespace driver { arglist_type ActualArgs; /// The list of arguments we synthesized. - arglist_type SynthesizedArgs; + mutable arglist_type SynthesizedArgs; /// Is this only a proxy for the base ArgList? bool OnlyProxy; diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp index 07d24c9410..95805b016b 100644 --- a/lib/Driver/ArgList.cpp +++ b/lib/Driver/ArgList.cpp @@ -218,23 +218,30 @@ const char *DerivedArgList::MakeArgString(llvm::StringRef Str) const { } Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const { - return new FlagArg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg); + Arg *A = new FlagArg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg); + SynthesizedArgs.push_back(A); + return A; } Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt, llvm::StringRef Value) const { - return new PositionalArg(Opt, BaseArgs.MakeIndex(Value), BaseArg); + Arg *A = new PositionalArg(Opt, BaseArgs.MakeIndex(Value), BaseArg); + SynthesizedArgs.push_back(A); + return A; } Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt, llvm::StringRef Value) const { - return new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1, - BaseArg); + Arg *A = new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1, + BaseArg); + SynthesizedArgs.push_back(A); + return A; } Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt, llvm::StringRef Value) const { - std::string Joined(Opt->getName()); - Joined += Value; - return new JoinedArg(Opt, BaseArgs.MakeIndex(Joined.c_str()), BaseArg); + Arg *A = new JoinedArg(Opt, BaseArgs.MakeIndex(Opt->getName() + Value.str()), + BaseArg); + SynthesizedArgs.push_back(A); + return A; }