aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-11 18:04:58 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-11 18:04:58 +0000
commit32c1a2ae8b31f32e478c8e504ed81db8c8d25713 (patch)
tree2df7472fb925e7b49da562fb262bd54c92849eac
parentfd48cb31d409cb1f8e1f119426965e498652e2d1 (diff)
Driver: Free Action objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98263 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/Action.h12
-rw-r--r--lib/Driver/Action.cpp6
-rw-r--r--lib/Driver/Driver.cpp5
3 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h
index 679704c395..ab3162a047 100644
--- a/include/clang/Driver/Action.h
+++ b/include/clang/Driver/Action.h
@@ -66,17 +66,23 @@ private:
ActionList Inputs;
+ unsigned OwnsInputs : 1;
+
protected:
- Action(ActionClass _Kind, types::ID _Type) : Kind(_Kind), Type(_Type) {}
+ Action(ActionClass _Kind, types::ID _Type)
+ : Kind(_Kind), Type(_Type), OwnsInputs(true) {}
Action(ActionClass _Kind, Action *Input, types::ID _Type)
- : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1) {}
+ : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1), OwnsInputs(true) {}
Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
- : Kind(_Kind), Type(_Type), Inputs(_Inputs) {}
+ : Kind(_Kind), Type(_Type), Inputs(_Inputs), OwnsInputs(true) {}
public:
virtual ~Action();
const char *getClassName() const { return Action::getClassName(getKind()); }
+ bool getOwnsInputs() { return OwnsInputs; }
+ void setOwnsInputs(bool Value) { OwnsInputs = Value; }
+
ActionClass getKind() const { return Kind; }
types::ID getType() const { return Type; }
diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp
index 62434893f9..b9a3306d53 100644
--- a/lib/Driver/Action.cpp
+++ b/lib/Driver/Action.cpp
@@ -13,8 +13,10 @@
using namespace clang::driver;
Action::~Action() {
- // FIXME: Free the inputs. The problem is that BindArchAction shares
- // inputs; so we can't just walk the inputs.
+ if (OwnsInputs) {
+ for (iterator it = begin(), ie = end(); it != ie; ++it)
+ delete *it;
+ }
}
const char *Action::getClassName(ActionClass AC) {
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 64168b4d83..3257ee55a7 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -503,8 +503,11 @@ void Driver::BuildUniversalActions(const ArgList &Args,
<< types::getTypeName(Act->getType());
ActionList Inputs;
- for (unsigned i = 0, e = Archs.size(); i != e; ++i)
+ for (unsigned i = 0, e = Archs.size(); i != e; ++i) {
Inputs.push_back(new BindArchAction(Act, Archs[i]));
+ if (i != 0)
+ Inputs.back()->setOwnsInputs(false);
+ }
// Lipo if necessary, we do it this way because we need to set the arch flag
// so that -Xarch_ gets overwritten.