Author: rnk Date: Tue Mar 1 19:21:48 2016 New Revision: 262442 URL: http://llvm.org/viewvc/llvm-project?rev=262442&view=rev Log: Add a few dllimport/dllexport tests. NFC
Summary: 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. -Warren Ristow SN Systems - Sony Computer Entertainment Group Reviewers: rnk Subscribers: silvas Differential Revision: http://reviews.llvm.org/D17775 Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp cfe/trunk/test/CodeGenCXX/dllimport.cpp Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=262442&r1=262441&r2=262442&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Mar 1 19:21:48 2016 @@ -570,6 +570,30 @@ struct __declspec(dllexport) T { USEVAR(T::b) int T::c; +// Export template class with static member variable +// MSC-DAG: @"\01?StaticClassVarExpTmplClass@?$TmplClass@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@H@@YAHH@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. Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=262442&r1=262441&r2=262442&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Tue Mar 1 19:21:48 2016 @@ -27,6 +27,7 @@ struct ExplicitSpec_NotImported {}; #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 @@ struct __declspec(dllimport) T { void a() {} // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a@T@@QAEXXZ" + static void StaticMethod(); + // MSC-DAG: declare dllimport void @"\01?StaticMethod@T@@SAXXZ"() + // GNU-DAG: declare dllimport void @_ZN1T12StaticMethodEv() + static int b; // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32 @@ -602,6 +607,7 @@ struct __declspec(dllimport) T { // 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) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits