diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5f29195f5192..f63fc63fe8c8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -48,6 +48,7 @@ Driver::Driver(const char *_Name, const char *_Dir, Driver::~Driver() { delete Opts; + delete Host; } ArgList *Driver::ParseArgStrings(const char **ArgBegin, const char **ArgEnd) { diff --git a/clang/lib/Driver/HostInfo.cpp b/clang/lib/Driver/HostInfo.cpp index 5fb9f9929ec6..d43d234c2f3e 100644 --- a/clang/lib/Driver/HostInfo.cpp +++ b/clang/lib/Driver/HostInfo.cpp @@ -46,11 +46,12 @@ class DarwinHostInfo : public HostInfo { unsigned GCCVersion[3]; /// Cache of tool chains we have created. - mutable llvm::StringMap ToolChains; + mutable llvm::StringMap ToolChains; public: DarwinHostInfo(const Driver &D, const char *Arch, const char *Platform, const char *OS); + ~DarwinHostInfo(); virtual bool useDriverDriver() const; @@ -74,6 +75,12 @@ DarwinHostInfo::DarwinHostInfo(const Driver &D, const char *_Arch, GCCVersion[2] = 1; } +DarwinHostInfo::~DarwinHostInfo() { + for (llvm::StringMap::iterator + it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) + delete it->second; +} + bool DarwinHostInfo::useDriverDriver() const { return true; } @@ -122,6 +129,7 @@ class UnknownHostInfo : public HostInfo { public: UnknownHostInfo(const Driver &D, const char *Arch, const char *Platform, const char *OS); + ~UnknownHostInfo(); virtual bool useDriverDriver() const; @@ -134,6 +142,12 @@ UnknownHostInfo::UnknownHostInfo(const Driver &D, const char *Arch, : HostInfo(D, Arch, Platform, OS) { } +UnknownHostInfo::~UnknownHostInfo() { + for (llvm::StringMap::iterator + it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it) + delete it->second; +} + bool UnknownHostInfo::useDriverDriver() const { return false; } diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h index aa8d2a1babd6..b879c18c3f92 100644 --- a/clang/lib/Driver/ToolChains.h +++ b/clang/lib/Driver/ToolChains.h @@ -31,6 +31,12 @@ class VISIBILITY_HIDDEN Generic_GCC : public ToolChain { public: Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, const char *OS) : ToolChain(Host, Arch, Platform, OS) {} + ~Generic_GCC() { + // Free tool implementations. + for (llvm::DenseMap::iterator + it = Tools.begin(), ie = Tools.end(); it != ie; ++it) + delete it->second; + } virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }