[llvm] [Minidump] Add extern template declarations for MinidumpFile::getListStream (PR #112568)

Thomas Fransham via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 08:31:14 PDT 2024


https://github.com/fsfod created https://github.com/llvm/llvm-project/pull/112568

Add extern template defs along with visibility macros to MinidumpFile::getListStream that is needed by MinidumpTest.cpp when llvm is built as shared library on windows with explicit visibility macros enabled.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.

>From 12e26d1b1eb4aa557b5554a461eaa9ef1d75484a Mon Sep 17 00:00:00 2001
From: Thomas Fransham <tfransham at gmail.com>
Date: Tue, 15 Oct 2024 22:05:40 +0100
Subject: [PATCH] [Minidump] Add extern template declarations for
 MinidumpFile::getListStream

Add extern template defs along with visibility macros to MinidumpFile::getListStream
thats needed by MinidumpTest.cpp when llvm is built as shared library on windows
with explicit visibility macros enabled.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.
---
 llvm/include/llvm/Object/Minidump.h | 14 ++++++++++++++
 llvm/lib/Object/Minidump.cpp        |  6 +++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h
index e6b21979ccaa1d..5002a2a54c7555 100644
--- a/llvm/include/llvm/Object/Minidump.h
+++ b/llvm/include/llvm/Object/Minidump.h
@@ -15,9 +15,15 @@
 #include "llvm/ADT/iterator.h"
 #include "llvm/BinaryFormat/Minidump.h"
 #include "llvm/Object/Binary.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
+namespace minidump {
+struct Module;
+struct Thread;
+struct MemoryDescriptor;
+} // namespace minidump
 namespace object {
 
 /// A class providing access to the contents of a minidump file.
@@ -371,6 +377,14 @@ Expected<ArrayRef<T>> MinidumpFile::getDataSliceAs(ArrayRef<uint8_t> Data,
   return ArrayRef<T>(reinterpret_cast<const T *>(Slice->data()), Count);
 }
 
+// Needed by MinidumpTest.cpp
+extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::Module>>
+    MinidumpFile::getListStream(minidump::StreamType) const;
+extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::Thread>>
+    MinidumpFile::getListStream(minidump::StreamType) const;
+extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<minidump::MemoryDescriptor>>
+    MinidumpFile::getListStream(minidump::StreamType) const;
+
 } // end namespace object
 } // end namespace llvm
 
diff --git a/llvm/lib/Object/Minidump.cpp b/llvm/lib/Object/Minidump.cpp
index fe768c4c90711b..50d4c608456900 100644
--- a/llvm/lib/Object/Minidump.cpp
+++ b/llvm/lib/Object/Minidump.cpp
@@ -98,11 +98,11 @@ Expected<ArrayRef<T>> MinidumpFile::getListStream(StreamType Type) const {
 
   return getDataSliceAs<T>(*Stream, ListOffset, ListSize);
 }
-template Expected<ArrayRef<Module>>
+template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<Module>>
     MinidumpFile::getListStream(StreamType) const;
-template Expected<ArrayRef<Thread>>
+template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<Thread>>
     MinidumpFile::getListStream(StreamType) const;
-template Expected<ArrayRef<MemoryDescriptor>>
+template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<MemoryDescriptor>>
     MinidumpFile::getListStream(StreamType) const;
 
 Expected<ArrayRef<uint8_t>> MinidumpFile::getDataSlice(ArrayRef<uint8_t> Data,



More information about the llvm-commits mailing list