[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / cxx2b-consteval-if.cpp
blob343b6a0bbd8a6b853d75d74c940d3ec2626ed9b2
1 // RUN: %clang_cc1 -std=c++23 %s -emit-llvm -o - | FileCheck %s
3 void should_be_used_1();
4 void should_be_used_2();
5 void should_be_used_3();
6 constexpr void should_not_be_used() {}
8 constexpr void f() {
9 if consteval {
10 should_not_be_used(); // CHECK-NOT: call {{.*}}should_not_be_used
11 } else {
12 should_be_used_1(); // CHECK: call {{.*}}should_be_used_1
15 if !consteval {
16 should_be_used_2(); // CHECK: call {{.*}}should_be_used_2
19 if !consteval {
20 should_be_used_3(); // CHECK: call {{.*}}should_be_used_3
21 } else {
22 should_not_be_used(); // CHECK-NOT: call {{.*}}should_not_be_used
26 void g() {
27 f();
30 namespace GH55638 {
32 constexpr bool is_constant_evaluated() noexcept {
33 if consteval { return true; } else { return false; }
36 constexpr int compiletime(int) {
37 return 2;
40 constexpr int runtime(int) {
41 return 1;
44 constexpr int test(int x) {
45 if(is_constant_evaluated())
46 return compiletime(x); // CHECK-NOT: call {{.*}}compiletime
47 return runtime(x); // CHECK: call {{.*}}runtime
50 int f(int x) {
51 x = test(x);
52 return x;