[llvm] [clang-tools-extra] [clang] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 05:58:36 PST 2024


================
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
----------------
Endilll wrote:

> I think a good litmus test as to whether a test belong in Clang or not is, "if the test fail, can we fix it?"
And here we would not be able to, lowering IR is not in the purview of the front end, so this is not testing the front end.

Lowering AST to IR _is_ in purview of Clang, and we're responsible that this happens correctly (even if no single individual in this conversation is an expert in that part of Clang). I hope everyone here agrees that middle-end folks are not responsible for the correctness of our CodeGen from the C++ language semantics perspective.

> And sure, there is a wider question here: Does the LLVM middle-end implements and test the semantics of C++
and those core issues that are relevant?

No, there is no such question, and there wasn't at any point in DR testing discussion. CodeGen DR tests are interested in Clang's CodeGen, and I do my best to ensure that middle-end does not interfere. If you think middle-end is still involved somehow, let me know how this can be fixed.

> Keep in mind that changes get tested in multiple places (when done correctly), so when someone implements a DR (or a feature with the DR already applied), they should have test coverage in clang/test/CodeGen* as well as in clang/test/Sema*, and here in the DR test file. We don't need to re-test things covered by other tests, and sometimes the coverage makes more sense elsewhere than a DR test.

This holds for the "usual" DR tests as well. They sure duplicate some of Sema tests. Same goes for the whole CXX directory. On top of the fact that calculating coverage is both time- and resource- consuming, making automatic duplicate discovery a serious burden, regular Sema and CodeGen tests are not necessarily designed to cover use cases DR tests cover. Which means they can change in a ways not fit for DR testing. So we should be careful about depending on them.

> I tend to agree with @cor3ntin that this may be going overboard in terms of test runs.

It wouldn't take too much time for a list of language modes to have the same length. Is cutting a number of language modes DR tests are run in also on the table because of arbitrary limits (as I see them at the moment)?

https://github.com/llvm/llvm-project/pull/80823


More information about the cfe-commits mailing list