summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/modules-ts/basic/basic.def.odr
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/modules-ts/basic/basic.def.odr')
-rw-r--r--clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp25
-rw-r--r--clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm76
-rw-r--r--clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp12
3 files changed, 106 insertions, 7 deletions
diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
index c8b8725ed2a..dc6a3635a8e 100644
--- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
+++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
@@ -1,6 +1,19 @@
// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t
// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module
+// CHECK-DAG: @extern_var_exported = external global
+// FIXME: Should this be 'external global'?
+// CHECK-DAG: @inline_var_exported = linkonce_odr global
+// CHECK-DAG: @_ZL19static_var_exported = external global
+// CHECK-DAG: @const_var_exported = external constant
+//
+// FIXME: The module name should be mangled into all of these.
+// CHECK-DAG: @extern_var_module_linkage = external global
+// FIXME: Should this be 'external global'?
+// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global
+// CHECK-DAG: @_ZL25static_var_module_linkage = external global
+// CHECK-DAG: @_ZL24const_var_module_linkage = external constant
+
module Module;
void use() {
@@ -9,8 +22,13 @@ void use() {
// CHECK: declare {{.*}}@_Z18noninline_exportedv
noninline_exported();
+ (void)&extern_var_exported;
+ (void)&inline_var_exported;
+ (void)&static_var_exported; // FIXME: Should not be exported.
+ (void)&const_var_exported;
+
// FIXME: This symbol should not be visible here.
- // CHECK: define internal {{.*}}@_ZL26used_static_module_linkagev
+ // CHECK: declare {{.*}}@_ZL26used_static_module_linkagev
used_static_module_linkage();
// FIXME: The module name should be mangled into the name of this function.
@@ -20,4 +38,9 @@ void use() {
// FIXME: The module name should be mangled into the name of this function.
// CHECK: declare {{.*}}@_Z24noninline_module_linkagev
noninline_module_linkage();
+
+ (void)&extern_var_module_linkage;
+ (void)&inline_var_module_linkage;
+ (void)&static_var_module_linkage; // FIXME: Should not be visible here.
+ (void)&const_var_module_linkage;
}
diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
index be3644efa5b..d452f741a0f 100644
--- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
+++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
@@ -1,9 +1,39 @@
-// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not=unused
+// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module
+
+// CHECK-DAG: @extern_var_global_module = external global
+// CHECK-DAG: @inline_var_global_module = linkonce_odr global
+// CHECK-DAG: @_ZL24static_var_global_module = internal global
+// CHECK-DAG: @_ZL23const_var_global_module = internal constant
+//
+// For ABI compatibility, these symbols do not include the module name.
+// CHECK-DAG: @extern_var_exported = external global
+// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we
+// can discard this global and its initializer (if any), and other TUs are not
+// permitted to run the initializer for this variable.
+// CHECK-DAG: @inline_var_exported = linkonce_odr global
+// CHECK-DAG: @_ZL19static_var_exported = global
+// CHECK-DAG: @const_var_exported = constant
+//
+// FIXME: The module name should be mangled into all of these.
+// CHECK-DAG: @extern_var_module_linkage = external global
+// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we
+// can discard this global and its initializer (if any), and other TUs are not
+// permitted to run the initializer for this variable.
+// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global
+// CHECK-DAG: @_ZL25static_var_module_linkage = global
+// CHECK-DAG: @_ZL24const_var_module_linkage = constant
static void unused_static_global_module() {}
static void used_static_global_module() {}
+
inline void unused_inline_global_module() {}
inline void used_inline_global_module() {}
+
+extern int extern_var_global_module;
+inline int inline_var_global_module;
+static int static_var_global_module;
+const int const_var_global_module = 3;
+
// CHECK: define void {{.*}}@_Z23noninline_global_modulev
void noninline_global_module() {
// FIXME: This should be promoted to module linkage and given a
@@ -15,6 +45,11 @@ void noninline_global_module() {
used_static_global_module();
// CHECK: define linkonce_odr {{.*}}@_Z25used_inline_global_modulev
used_inline_global_module();
+
+ (void)&extern_var_global_module;
+ (void)&inline_var_global_module;
+ (void)&static_var_global_module;
+ (void)&const_var_global_module;
}
export module Module;
@@ -22,33 +57,62 @@ export module Module;
export {
// FIXME: These should be ill-formed: you can't export an internal linkage
// symbol, per [dcl.module.interface]p2.
+ // CHECK: define void {{.*}}@_ZL22unused_static_exportedv
static void unused_static_exported() {}
+ // CHECK: define void {{.*}}@_ZL20used_static_exportedv
static void used_static_exported() {}
inline void unused_inline_exported() {}
inline void used_inline_exported() {}
+
+ extern int extern_var_exported;
+ inline int inline_var_exported;
+ // FIXME: This should be ill-formed: you can't export an internal linkage
+ // symbol.
+ static int static_var_exported;
+ const int const_var_exported = 3;
+
// CHECK: define void {{.*}}@_Z18noninline_exportedv
void noninline_exported() {
- // CHECK: define internal {{.*}}@_ZL20used_static_exportedv
used_static_exported();
// CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv
used_inline_exported();
+
+ (void)&extern_var_exported;
+ (void)&inline_var_exported;
+ (void)&static_var_exported;
+ (void)&const_var_exported;
}
}
+// FIXME: Ideally we wouldn't emit this as its name is not visible outside this
+// TU, but this module interface might contain a template that can use this
+// function so we conservatively emit it for now.
+// FIXME: The module name should be mangled into the name of this function.
+// CHECK: define void {{.*}}@_ZL28unused_static_module_linkagev
static void unused_static_module_linkage() {}
+// FIXME: The module name should be mangled into the name of this function.
+// CHECK: define void {{.*}}@_ZL26used_static_module_linkagev
static void used_static_module_linkage() {}
+
inline void unused_inline_module_linkage() {}
inline void used_inline_module_linkage() {}
+
+extern int extern_var_module_linkage;
+inline int inline_var_module_linkage;
+static int static_var_module_linkage;
+const int const_var_module_linkage = 3;
+
// FIXME: The module name should be mangled into the name of this function.
// CHECK: define void {{.*}}@_Z24noninline_module_linkagev
void noninline_module_linkage() {
- // FIXME: This should be promoted to module linkage and given a
- // module-mangled name, if it's called from an inline function within
- // the module interface.
- // CHECK: define internal {{.*}}@_ZL26used_static_module_linkagev
used_static_module_linkage();
// FIXME: The module name should be mangled into the name of this function.
// CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev
used_inline_module_linkage();
+
+ (void)&extern_var_module_linkage;
+ (void)&inline_var_module_linkage;
+ (void)&static_var_module_linkage;
+ (void)&const_var_module_linkage;
}
diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
index bbd67e2c89a..f6e0238c6b4 100644
--- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
+++ b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
@@ -1,6 +1,13 @@
// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t
// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module
+// CHECK-DAG: @extern_var_exported = external global
+// FIXME: Should this be 'external global'?
+// CHECK-DAG: @inline_var_exported = linkonce_odr global
+// FIXME: These should be 'extern global' and 'extern constant'.
+// CHECK-DAG: @_ZL19static_var_exported = global
+// CHECK-DAG: @const_var_exported = constant
+
import Module;
void use() {
@@ -9,5 +16,10 @@ void use() {
// CHECK: declare {{.*}}@_Z18noninline_exportedv
noninline_exported();
+ (void)&extern_var_exported;
+ (void)&inline_var_exported;
+ (void)&static_var_exported;
+ (void)&const_var_exported;
+
// Module-linkage declarations are not visible here.
}
OpenPOWER on IntegriCloud