Skip to content

Commit 1f54810

Browse files
committed
Just declare MinidumpFile::getListStream in the header instead of extern template
1 parent 12e26d1 commit 1f54810

File tree

2 files changed

+21
-40
lines changed

2 files changed

+21
-40
lines changed

llvm/include/llvm/Object/Minidump.h

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@
1515
#include "llvm/ADT/iterator.h"
1616
#include "llvm/BinaryFormat/Minidump.h"
1717
#include "llvm/Object/Binary.h"
18-
#include "llvm/Support/Compiler.h"
1918
#include "llvm/Support/Error.h"
2019

2120
namespace llvm {
22-
namespace minidump {
23-
struct Module;
24-
struct Thread;
25-
struct MemoryDescriptor;
26-
} // namespace minidump
2721
namespace object {
2822

2923
/// A class providing access to the contents of a minidump file.
@@ -377,13 +371,27 @@ Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t> Data,
377371
return ArrayRef<T>(reinterpret_cast<const T *>(Slice->data()), Count);
378372
}
379373

380-
// Needed by MinidumpTest.cpp
381-
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::Module>>
382-
MinidumpFile::getListStream(minidump::StreamType) const;
383-
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::Thread>>
384-
MinidumpFile::getListStream(minidump::StreamType) const;
385-
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::MemoryDescriptor>>
386-
MinidumpFile::getListStream(minidump::StreamType) const;
374+
template <typename T>
375+
Expected<ArrayRef<T>>
376+
MinidumpFile::getListStream(minidump::StreamType Type) const {
377+
std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
378+
if (!Stream)
379+
return createError("No such stream");
380+
auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
381+
if (!ExpectedSize)
382+
return ExpectedSize.takeError();
383+
384+
size_t ListSize = ExpectedSize.get()[0];
385+
386+
size_t ListOffset = 4;
387+
// Some producers insert additional padding bytes to align the list to an
388+
// 8-byte boundary. Check for that by comparing the list size with the overall
389+
// stream size.
390+
if (ListOffset + sizeof(T) * ListSize < Stream->size())
391+
ListOffset = 8;
392+
393+
return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
394+
}
387395

388396
} // end namespace object
389397
} // end namespace llvm

llvm/lib/Object/Minidump.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,6 @@ MinidumpFile::getMemoryInfoList() const {
7878
MemoryInfoIterator({}, H.SizeOfEntry));
7979
}
8080

81-
template <typename T>
82-
Expected<ArrayRef<T>> MinidumpFile::getListStream(StreamType Type) const {
83-
std::optional<ArrayRef<uint8_t>> Stream = getRawStream(Type);
84-
if (!Stream)
85-
return createError("No such stream");
86-
auto ExpectedSize = getDataSliceAs<support::ulittle32_t>(*Stream, 0, 1);
87-
if (!ExpectedSize)
88-
return ExpectedSize.takeError();
89-
90-
size_t ListSize = ExpectedSize.get()[0];
91-
92-
size_t ListOffset = 4;
93-
// Some producers insert additional padding bytes to align the list to an
94-
// 8-byte boundary. Check for that by comparing the list size with the overall
95-
// stream size.
96-
if (ListOffset + sizeof(T) * ListSize < Stream->size())
97-
ListOffset = 8;
98-
99-
return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
100-
}
101-
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<Module>>
102-
MinidumpFile::getListStream(StreamType) const;
103-
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<Thread>>
104-
MinidumpFile::getListStream(StreamType) const;
105-
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<MemoryDescriptor>>
106-
MinidumpFile::getListStream(StreamType) const;
107-
10881
Expected<ArrayRef<uint8_t>> MinidumpFile::getDataSlice(ArrayRef<uint8_t> Data,
10982
uint64_t Offset,
11083
uint64_t Size) {

0 commit comments

Comments
 (0)