[lld] r289451 - COFF: Fix memory leaks reported by lsan.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 10:42:10 PST 2016
Author: pcc
Date: Mon Dec 12 12:42:09 2016
New Revision: 289451
URL: http://llvm.org/viewvc/llvm-project?rev=289451&view=rev
Log:
COFF: Fix memory leaks reported by lsan.
Modified:
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/COFF/Symbols.cpp
lld/trunk/COFF/Symbols.h
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=289451&r1=289450&r2=289451&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Mon Dec 12 12:42:09 2016
@@ -420,7 +420,7 @@ std::vector<ObjectFile *> SymbolTable::c
std::vector<ObjectFile *> ObjFiles;
for (SmallString<0> &Obj : Objs) {
- auto *ObjFile = new ObjectFile(MemoryBufferRef(Obj, "<LTO object>"));
+ auto *ObjFile = make<ObjectFile>(MemoryBufferRef(Obj, "<LTO object>"));
ObjectFiles.push_back(ObjFile);
ObjFiles.push_back(ObjFile);
}
Modified: lld/trunk/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.cpp?rev=289451&r1=289450&r2=289451&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.cpp (original)
+++ lld/trunk/COFF/Symbols.cpp Mon Dec 12 12:42:09 2016
@@ -59,9 +59,9 @@ DefinedImportThunk::DefinedImportThunk(S
uint16_t Machine)
: Defined(DefinedImportThunkKind, Name) {
switch (Machine) {
- case AMD64: Data.reset(new ImportThunkChunkX64(S)); return;
- case I386: Data.reset(new ImportThunkChunkX86(S)); return;
- case ARMNT: Data.reset(new ImportThunkChunkARM(S)); return;
+ case AMD64: Data = make<ImportThunkChunkX64>(S); return;
+ case I386: Data = make<ImportThunkChunkX86>(S); return;
+ case ARMNT: Data = make<ImportThunkChunkARM>(S); return;
default: llvm_unreachable("unknown machine type");
}
}
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=289451&r1=289450&r2=289451&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Mon Dec 12 12:42:09 2016
@@ -13,6 +13,7 @@
#include "Chunks.h"
#include "Config.h"
#include "lld/Core/LLVM.h"
+#include "lld/Support/Memory.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFF.h"
@@ -312,10 +313,10 @@ public:
}
uint64_t getRVA() { return Data->getRVA(); }
- Chunk *getChunk() { return Data.get(); }
+ Chunk *getChunk() { return Data; }
private:
- std::unique_ptr<Chunk> Data;
+ Chunk *Data;
};
// If you have a symbol "__imp_foo" in your object file, a symbol name
@@ -326,17 +327,17 @@ private:
class DefinedLocalImport : public Defined {
public:
DefinedLocalImport(StringRef N, Defined *S)
- : Defined(DefinedLocalImportKind, N), Data(new LocalImportChunk(S)) {}
+ : Defined(DefinedLocalImportKind, N), Data(make<LocalImportChunk>(S)) {}
static bool classof(const SymbolBody *S) {
return S->kind() == DefinedLocalImportKind;
}
uint64_t getRVA() { return Data->getRVA(); }
- Chunk *getChunk() { return Data.get(); }
+ Chunk *getChunk() { return Data; }
private:
- std::unique_ptr<LocalImportChunk> Data;
+ LocalImportChunk *Data;
};
class DefinedBitcode : public Defined {
More information about the llvm-commits
mailing list