[PATCH] D70420: Use lld::make<T> to make TpiSource objects
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 22:20:47 PST 2019
ruiu created this revision.
ruiu added a reviewer: rnk.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70420
Files:
lld/COFF/DebugTypes.cpp
lld/COFF/DebugTypes.h
Index: lld/COFF/DebugTypes.h
===================================================================
--- lld/COFF/DebugTypes.h
+++ lld/COFF/DebugTypes.h
@@ -31,7 +31,7 @@
public:
enum TpiKind { Regular, PCH, UsingPCH, PDB, UsingPDB };
- TpiSource(TpiKind k, const ObjFile *f);
+ TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) {}
virtual ~TpiSource() {}
const TpiKind kind;
@@ -57,4 +57,4 @@
} // namespace coff
} // namespace lld
-#endif
\ No newline at end of file
+#endif
Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ 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 @@
};
} // 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));
-}
+std::vector<std::unique_ptr<TpiSource>> GC;
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 @@
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70420.229974.patch
Type: text/x-patch
Size: 2219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191119/201720c0/attachment.bin>
More information about the llvm-commits
mailing list