Commit f4fbf7fd by Jim Stichnoth

Subzero: Fix a memory leak.

The problem was that Translator and subclasses need to have virtual destructors since they are used as unique_ptr<>. As a result, only the Translator base class destructor was being invoked. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4290 TEST= make -f Makefile.standalone ASAN=1 check-lit R=ascull@google.com Review URL: https://codereview.chromium.org/1281003003.
parent aa0ce790
...@@ -655,7 +655,7 @@ class LLVM2ICEGlobalsConverter : public LLVM2ICEConverter { ...@@ -655,7 +655,7 @@ class LLVM2ICEGlobalsConverter : public LLVM2ICEConverter {
LLVM2ICEGlobalsConverter() = delete; LLVM2ICEGlobalsConverter() = delete;
LLVM2ICEGlobalsConverter(const LLVM2ICEGlobalsConverter &) = delete; LLVM2ICEGlobalsConverter(const LLVM2ICEGlobalsConverter &) = delete;
LLVM2ICEGlobalsConverter & LLVM2ICEGlobalsConverter &
operator-(const LLVM2ICEGlobalsConverter &) = delete; operator=(const LLVM2ICEGlobalsConverter &) = delete;
public: public:
explicit LLVM2ICEGlobalsConverter(Ice::Converter &Converter) explicit LLVM2ICEGlobalsConverter(Ice::Converter &Converter)
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
Converter(llvm::Module *Mod, GlobalContext *Ctx) Converter(llvm::Module *Mod, GlobalContext *Ctx)
: Translator(Ctx), Mod(Mod) {} : Translator(Ctx), Mod(Mod) {}
~Converter() = default; ~Converter() override = default;
/// Converts the LLVM Module to ICE. Sets exit status to false if successful, /// Converts the LLVM Module to ICE. Sets exit status to false if successful,
/// true otherwise. /// true otherwise.
......
...@@ -27,8 +27,6 @@ Translator::Translator(GlobalContext *Ctx) ...@@ -27,8 +27,6 @@ Translator::Translator(GlobalContext *Ctx)
: Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()), : Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()),
ErrorStatus() {} ErrorStatus() {}
Translator::~Translator() = default;
IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) {
if (Index == 0) if (Index == 0)
return Prefix; return Prefix;
......
...@@ -41,7 +41,7 @@ class Translator { ...@@ -41,7 +41,7 @@ class Translator {
public: public:
explicit Translator(GlobalContext *Ctx); explicit Translator(GlobalContext *Ctx);
~Translator(); virtual ~Translator() = default;
const ErrorCode &getErrorStatus() const { return ErrorStatus; } const ErrorCode &getErrorStatus() const { return ErrorStatus; }
GlobalContext *getContext() const { return Ctx; } GlobalContext *getContext() const { return Ctx; }
......
...@@ -34,6 +34,7 @@ class PNaClTranslator : public Translator { ...@@ -34,6 +34,7 @@ class PNaClTranslator : public Translator {
public: public:
explicit PNaClTranslator(GlobalContext *Ctx) : Translator(Ctx) {} explicit PNaClTranslator(GlobalContext *Ctx) : Translator(Ctx) {}
~PNaClTranslator() override = default;
/// Reads the PNaCl bitcode file and translates to ICE, which is then /// Reads the PNaCl bitcode file and translates to ICE, which is then
/// converted to machine code. Sets ErrorStatus to 1 if any errors /// converted to machine code. Sets ErrorStatus to 1 if any errors
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment