[PATCH] D17775: Add a few dllimport/dllexport tests. NFC

Warren Ristow via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 1 10:53:32 PST 2016


wristow created this revision.
wristow added reviewers: cfe-commits, rnk, majnemer.

This change just adds tests for some corner cases of dllimport/dllexport,
primarily for some static methods.

We plan to enable dllimport/dllexport support for the PS4, and these
additional tests are for points we previously were testing internally.

Can someone review, and if OK then commit this patch for me, please?

-Warren Ristow
SN Systems - Sony Computer Entertainment Group

http://reviews.llvm.org/D17775

Files:
  llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
  llvm/tools/clang/test/CodeGenCXX/dllimport.cpp

Index: llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
===================================================================
--- llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
@@ -27,6 +27,7 @@
 #define USEVAR(var) USEVARTYPE(int, var)
 #define USE(func) void UNIQ(use)() { func(); }
 #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; }
+#define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return &class::func; }
 #define USECLASS(class) void UNIQ(USE)() { class x; }
 #define USECOPYASSIGN(class) class& (class::*UNIQ(use)())(class&) { return &class::operator=; }
 #define USEMOVEASSIGN(class) class& (class::*UNIQ(use)())(class&&) { return &class::operator=; }
@@ -590,6 +591,10 @@
   void a() {}
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a at T@@QAEXXZ"
 
+  static void StaticMethod();
+  // MSC-DAG: declare dllimport void @"\01?StaticMethod at T@@SAXXZ"()
+  // GNU-DAG: declare dllimport void @_ZN1T12StaticMethodEv()
+
   static int b;
   // MO1-DAG: @"\01?b at T@@2HA" = external dllimport global i32
 
@@ -602,6 +607,7 @@
   // M19-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
 };
 USEMEMFUNC(T, a)
+USESTATICMEMFUNC(T, StaticMethod)
 USEVAR(T::b)
 USECOPYASSIGN(T)
 USEMOVEASSIGN(T)
Index: llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
===================================================================
--- llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
@@ -570,6 +570,30 @@
 USEVAR(T::b)
 int T::c;
 
+// Export template class with static member variable
+// MSC-DAG: @"\01?StaticClassVarExpTmplClass@?$TmplClass at H@@2HA" = weak_odr dllexport global i32 0, comdat, align 4
+// GNU-DAG: @_ZN9TmplClassIiE26StaticClassVarExpTmplClassE = weak_odr dllexport global i32 0, comdat, align 4
+template<typename T>
+struct __declspec(dllexport) TmplClass
+{
+  static T StaticClassVarExpTmplClass;
+};
+
+template<typename T>
+T TmplClass<T>::StaticClassVarExpTmplClass;
+
+// Export a definition of a template function.
+// MSC-DAG: define weak_odr dllexport i32 @"\01??$TypeFunTmpl at H@@YAHH at Z"
+// GNU-DAG: define weak_odr dllexport i32 @_Z11TypeFunTmplIiET_S0_
+template<typename T>
+T __declspec(dllexport) TypeFunTmpl(T t) { return t + t; }
+
+// Instantiate the exported template class and the exported template function.
+int useExportedTmplStaticAndFun()
+{
+  return TmplClass<int>::StaticClassVarExpTmplClass + TypeFunTmpl<int>(10);
+}
+
 template <typename T> struct __declspec(dllexport) U { void foo() {} };
 struct __declspec(dllexport) V : public U<int> { };
 // U<int>'s assignment operator is emitted.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17775.49510.patch
Type: text/x-patch
Size: 2775 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160301/e4ec614d/attachment.bin>


More information about the cfe-commits mailing list