diff options
Diffstat (limited to 'clang/test/Modules')
-rw-r--r-- | clang/test/Modules/Inputs/codegen-nodep/foo.h | 5 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/codegen-nodep/foo.modulemap | 1 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/codegen/foo.h | 26 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/codegen/use.cpp | 8 | ||||
-rw-r--r-- | clang/test/Modules/codegen-nodep.test | 13 | ||||
-rw-r--r-- | clang/test/Modules/codegen.test | 25 |
6 files changed, 74 insertions, 4 deletions
diff --git a/clang/test/Modules/Inputs/codegen-nodep/foo.h b/clang/test/Modules/Inputs/codegen-nodep/foo.h new file mode 100644 index 00000000000..af91e8d263b --- /dev/null +++ b/clang/test/Modules/Inputs/codegen-nodep/foo.h @@ -0,0 +1,5 @@ +template <typename T> +void ftempl() { +} +inline void f() { +} diff --git a/clang/test/Modules/Inputs/codegen-nodep/foo.modulemap b/clang/test/Modules/Inputs/codegen-nodep/foo.modulemap new file mode 100644 index 00000000000..2e095d2794c --- /dev/null +++ b/clang/test/Modules/Inputs/codegen-nodep/foo.modulemap @@ -0,0 +1 @@ +module foo { header "foo.h" } diff --git a/clang/test/Modules/Inputs/codegen/foo.h b/clang/test/Modules/Inputs/codegen/foo.h index 3fcab718573..e77e8d1824e 100644 --- a/clang/test/Modules/Inputs/codegen/foo.h +++ b/clang/test/Modules/Inputs/codegen/foo.h @@ -2,3 +2,29 @@ inline void f1(const char* fmt, ...) { __builtin_va_list args; __builtin_va_start(args, fmt); } + +struct non_trivial_dtor { + ~non_trivial_dtor(); +}; + +struct implicit_dtor { + non_trivial_dtor d; +}; + +struct uninst_implicit_dtor { + non_trivial_dtor d; +}; + +inline void use_implicit_dtor() { + implicit_dtor d; +} + +template <typename T> +void inst() { +} + +inline void inst_decl() { + // cause inst<int>'s declaration to be instantiated, without a definition. + (void)sizeof(&inst<int>); + inst<float>(); +} diff --git a/clang/test/Modules/Inputs/codegen/use.cpp b/clang/test/Modules/Inputs/codegen/use.cpp new file mode 100644 index 00000000000..cd1a4a642d0 --- /dev/null +++ b/clang/test/Modules/Inputs/codegen/use.cpp @@ -0,0 +1,8 @@ +#include "foo.h" +void non_modular_use_of_implicit_dtor() { + implicit_dtor d1; + uninst_implicit_dtor d2; +} +void use_of_instantiated_declaration_without_definition() { + inst<int>(); +} diff --git a/clang/test/Modules/codegen-nodep.test b/clang/test/Modules/codegen-nodep.test new file mode 100644 index 00000000000..cb2b4e37e9d --- /dev/null +++ b/clang/test/Modules/codegen-nodep.test @@ -0,0 +1,13 @@ +RUN: rm -rf %t +REQUIRES: x86-registered-target + +RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules \ +RUN: -emit-module -fmodule-name=foo \ +RUN: %S/Inputs/codegen-nodep/foo.modulemap -o - \ +RUN: | llvm-bcanalyzer - -dump \ +RUN: | FileCheck %s + +Ensure there's only one modular codegen decl - the sentinel plain inline +function, not any for the function template. + +CHECK: <MODULAR_CODEGEN_DECLS op0={{[0-9]+}}/> diff --git a/clang/test/Modules/codegen.test b/clang/test/Modules/codegen.test index f1823d55baf..6807640e603 100644 --- a/clang/test/Modules/codegen.test +++ b/clang/test/Modules/codegen.test @@ -3,8 +3,25 @@ REQUIRES: x86-registered-target RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm -RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck %s +RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s +RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s -CHECK: $_Z2f1PKcz = comdat any -CHECK: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat -CHECK: call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}}) +FOO: $_Z2f1PKcz = comdat any +FOO: $_ZN13implicit_dtorD1Ev = comdat any +USE: $_Z4instIiEvv = comdat any +FOO: $_ZN13implicit_dtorD2Ev = comdat any +FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat +FOO: call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}}) + +Test that implicit special members are emitted into the FOO module if they're +ODR used there, otherwise emit them linkonce_odr as usual in the use. + +FIXME: Proactively instantiate any valid implicit special members to emit them into the module object. + +FOO: define weak_odr void @_ZN13implicit_dtorD1Ev +FOO: define weak_odr void @_Z4instIfEvv +FOO: define weak_odr void @_ZN13implicit_dtorD2Ev + +USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev +USE: define linkonce_odr void @_Z4instIiEvv +USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev |