[clang] f4fbbeb - [clang] Add test for CWG1807 (#77637)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 05:14:29 PST 2024


Author: Vlad Serebrennikov
Date: 2024-01-18T17:14:25+04:00
New Revision: f4fbbebb5edcaad459ce154c011f71fc38fe4052

URL: https://github.com/llvm/llvm-project/commit/f4fbbebb5edcaad459ce154c011f71fc38fe4052
DIFF: https://github.com/llvm/llvm-project/commit/f4fbbebb5edcaad459ce154c011f71fc38fe4052.diff

LOG: [clang] Add test for CWG1807 (#77637)

The test checks that objects in arrays are destructed in reverse order during stack unwinding.

This patch is trying to establish a precedent how codegen tests for C++ defect report test suite should be written. Refer to PR for exact reasoning.

Added: 
    clang/test/CXX/drs/dr1807.cpp

Modified: 
    clang/test/CXX/drs/dr18xx.cpp
    clang/www/cxx_dr_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr1807.cpp b/clang/test/CXX/drs/dr1807.cpp
new file mode 100644
index 00000000000000..0e16eedac71ef2
--- /dev/null
+++ b/clang/test/CXX/drs/dr1807.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,CXX98
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+
+namespace dr1807 { // dr1807: 3.0
+struct S {
+  S() {}
+  ~S() {}
+};
+
+void f() {
+  S s[3];
+}
+}
+
+// CHECK-LABEL:      define dso_local void @dr1807::f()
+// CHECK:              invoke void @dr1807::S::S(){{.+}}
+// CHECK-NEXT:         {{.+}} unwind label %lpad
+// CHECK-LABEL:      lpad:
+// CHECK:              br {{.+}}, label {{.+}}, label %arraydestroy.body
+// CHECK-LABEL:      arraydestroy.body:         
+// CHECK:              [[ARRAYDESTROY_ELEMENT:%.*]] = getelementptr {{.+}}, i64 -1
+// CXX98-NEXT:         invoke void @dr1807::S::~S()({{.*}}[[ARRAYDESTROY_ELEMENT]])
+// SINCE-CXX11-NEXT:   call void @dr1807::S::~S()({{.*}}[[ARRAYDESTROY_ELEMENT]])

diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 3a4ce71aa73942..0245f03986dd73 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -164,6 +164,8 @@ void A<double, U>::C<V>::f4() {
 }
 } // namespace dr1804
 
+// dr1807 is in dr1807.cpp
+
 namespace dr1812 { // dr1812: no
                    // NB: dup 1710
 #if __cplusplus >= 201103L

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 5e7c1a0fa2f246..3ee359945582fa 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -10650,7 +10650,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1807.html">1807</a></td>
     <td>CD4</td>
     <td>Order of destruction of array elements after an exception</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Clang 3.0</td>
   </tr>
   <tr class="open" id="1808">
     <td><a href="https://cplusplus.github.io/CWG/issues/1808.html">1808</a></td>


        


More information about the cfe-commits mailing list