[cfe-commits] r105963 - in /cfe/trunk: include/clang/Driver/ArgList.h lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jun 14 14:23:08 PDT 2010
Author: ddunbar
Date: Mon Jun 14 16:23:08 2010
New Revision: 105963
URL: http://llvm.org/viewvc/llvm-project?rev=105963&view=rev
Log:
Driver: Eliminate uses of Arg::getIndex.
Also, fix a memory leak.
Modified:
cfe/trunk/include/clang/Driver/ArgList.h
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/ArgList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ArgList.h?rev=105963&r1=105962&r2=105963&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Mon Jun 14 16:23:08 2010
@@ -338,6 +338,12 @@
/// @name Arg Synthesis
/// @{
+ /// AddSynthesizedArg - Add a argument to the list of synthesized arguments
+ /// (to be freed).
+ void AddSynthesizedArg(Arg *A) {
+ SynthesizedArgs.push_back(A);
+ }
+
virtual const char *MakeArgString(llvm::StringRef Str) const;
/// AddFlagArg - Construct a new FlagArg for the given option \arg Id and
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=105963&r1=105962&r2=105963&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Jun 14 16:23:08 2010
@@ -487,9 +487,8 @@
if (getArchName() != A->getValue(Args, 0))
continue;
- // FIXME: The arg is leaked here, and we should have a nicer
- // interface for this.
- unsigned Prev, Index = Prev = A->getIndex() + 1;
+ unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(Args, 1));
+ unsigned Prev = Index;
Arg *XarchArg = Opts.ParseOneArg(Args, Index);
// If the argument parsing failed or more than one argument was
@@ -509,6 +508,8 @@
XarchArg->setBaseArg(A);
A = XarchArg;
+
+ DAL->AddSynthesizedArg(A);
}
// Sob. These is strictly gcc compatible for the time being. Apple
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=105963&r1=105962&r2=105963&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun 14 16:23:08 2010
@@ -1074,8 +1074,9 @@
else
Std->render(Args, CmdArgs);
- if (Arg *A = Args.getLastArg(options::OPT_trigraphs))
- if (A->getIndex() > Std->getIndex())
+ if (Arg *A = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi,
+ options::OPT_trigraphs))
+ if (A != Std)
A->render(Args, CmdArgs);
} else {
// Honor -std-default.
More information about the cfe-commits
mailing list