[NFC] Add a test for C++20 Modules
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 16 Feb 2023 09:13:31 +0000 (17:13 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 16 Feb 2023 09:14:16 +0000 (17:14 +0800)
Add a test to check that the template instantiation during the template
specialization wouldn't be emitted again in the importer.

clang/test/Modules/pr60693.cppm

index 117a0f2..c507910 100644 (file)
@@ -16,7 +16,14 @@ constexpr bool f() {
        return true;
 }
 
-export template<typename>
+template <typename T>
+struct u {
+    T unit() {
+        return T();
+    }
+};
+
+export template<typename T>
 struct s {
        static constexpr auto a = f();
        static constexpr auto b = f();
@@ -28,6 +35,9 @@ struct s {
     int bar() {
         return 44;
     }
+    T zoo() {
+        return u<T>().unit();
+    }
 };
 
 template struct s<int>;
@@ -46,9 +56,15 @@ extern "C" long use2() {
     return _.foo();
 }
 
+extern "C" long use3() {
+    s<long> _;
+    return _.zoo();
+}
+
 // CHECK: define{{.*}}@use(
 // CHECK-NOT: }
 // CHECK: ret{{.*}} 4
 
 // CHECK: declare{{.*}}@_ZNW1a1sIlE3fooEv
 // CHECK-NOT: _ZNW1a1sIlE3barEv
+// CHECK: declare{{.*}}_ZNW1a1sIlE3zooEv