diff options
author | Rui Ueyama <ruiu@google.com> | 2019-11-19 15:04:21 +0900 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2019-11-20 13:14:44 +0900 |
commit | 47feae5dd61d891d4c1382b9784738111b4f9396 (patch) | |
tree | 9511d8646db7f4a9f880fb6bea2cf3d1ba1c52c4 | |
parent | 86c66cea21f065a1f757cb072c544f89ce227284 (diff) | |
download | bcm5719-llvm-47feae5dd61d891d4c1382b9784738111b4f9396.tar.gz bcm5719-llvm-47feae5dd61d891d4c1382b9784738111b4f9396.zip |
Use lld::make<T> to make TpiSource objects
In lld we rarely use std::unique_ptr but instead allocate new instances
using lld::make<T>() so that they are deallocated at the end of linking.
This patch changes existing code so that that follows the convention.
Differential Revision: https://reviews.llvm.org/D70420
-rw-r--r-- | lld/COFF/DebugTypes.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp index 6c7d70ee8dc..0960f16b01e 100644 --- a/lld/COFF/DebugTypes.cpp +++ b/lld/COFF/DebugTypes.cpp @@ -10,6 +10,7 @@ #include "Driver.h" #include "InputFiles.h" #include "lld/Common/ErrorHandler.h" +#include "lld/Common/Memory.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/Native/InfoStream.h" @@ -91,29 +92,25 @@ public: }; } // namespace -static std::vector<std::unique_ptr<TpiSource>> GC; - -TpiSource::TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) { - GC.push_back(std::unique_ptr<TpiSource>(this)); -} +TpiSource::TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) {} TpiSource *makeTpiSource(const ObjFile *f) { - return new TpiSource(TpiSource::Regular, f); + return make<TpiSource>(TpiSource::Regular, f); } TpiSource *makeUseTypeServerSource(const ObjFile *f, const TypeServer2Record *ts) { TypeServerSource::enqueue(f, *ts); - return new UseTypeServerSource(f, ts); + return make<UseTypeServerSource>(f, ts); } TpiSource *makePrecompSource(const ObjFile *f) { - return new PrecompSource(f); + return make<PrecompSource>(f); } TpiSource *makeUsePrecompSource(const ObjFile *f, const PrecompRecord *precomp) { - return new UsePrecompSource(f, precomp); + return make<UsePrecompSource>(f, precomp); } template <> @@ -260,7 +257,7 @@ Expected<TypeServerSource *> TypeServerSource::getInstance(MemoryBufferRef m) { // All PDB Files should have an Info stream. if (!info) return info.takeError(); - return new TypeServerSource(m, session.release()); + return make<TypeServerSource>(m, session.release()); } } // namespace coff |