diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-19 01:29:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-19 01:29:05 +0000 |
commit | bb1110a7ae2b1b0178c294928d108fa205e6de24 (patch) | |
tree | 8fbca24d9843c8c6dd68b7e988cbe9c822674547 /clang/lib/Driver/Driver.cpp | |
parent | 17fd6dd7af5e680ad2686522eda6caedf1d45e7b (diff) | |
download | bcm5719-llvm-bb1110a7ae2b1b0178c294928d108fa205e6de24.tar.gz bcm5719-llvm-bb1110a7ae2b1b0178c294928d108fa205e6de24.zip |
Fix possible memory leak by using an OwningPtr.
llvm-svn: 93834
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ab4bd49dd65..b073c0ae1ef 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -26,6 +26,7 @@ #include "clang/Basic/Version.h" #include "llvm/ADT/StringSet.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" @@ -675,7 +676,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const { } // Build the pipeline for this file. - Action *Current = new InputAction(*InputArg, InputType); + llvm::OwningPtr<Action> Current(new InputAction(*InputArg, InputType)); for (unsigned i = 0; i != NumSteps; ++i) { phases::ID Phase = types::getCompilationPhase(InputType, i); @@ -686,8 +687,7 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const { // Queue linker inputs. if (Phase == phases::Link) { assert(i + 1 == NumSteps && "linking must be final compilation step."); - LinkerInputs.push_back(Current); - Current = 0; + LinkerInputs.push_back(Current.take()); break; } @@ -698,14 +698,14 @@ void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const { continue; // Otherwise construct the appropriate action. - Current = ConstructPhaseAction(Args, Phase, Current); + Current.reset(ConstructPhaseAction(Args, Phase, Current.take())); if (Current->getType() == types::TY_Nothing) break; } // If we ended with something, add to the output list. if (Current) - Actions.push_back(Current); + Actions.push_back(Current.take()); } // Add a link action if necessary. |