-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen] Implement "if consteval" code generation (#446)
Emit the false-branch of the consteval if statement, if any.
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
|
||
void should_be_used_1(); | ||
void should_be_used_2(); | ||
void should_be_used_3(); | ||
constexpr void should_not_be_used() {} | ||
|
||
constexpr void f() { | ||
if consteval { | ||
should_not_be_used(); // CHECK-NOT: call {{.*}}should_not_be_used | ||
} else { | ||
should_be_used_1(); // CHECK: call {{.*}}should_be_used_1 | ||
} | ||
|
||
if !consteval { | ||
should_be_used_2(); // CHECK: call {{.*}}should_be_used_2 | ||
} else { | ||
should_not_be_used(); // CHECK-NOT: call {{.*}}should_not_be_used | ||
} | ||
|
||
if consteval { | ||
should_not_be_used(); // CHECK-NOT: call {{.*}}should_not_be_used | ||
} | ||
|
||
if !consteval { | ||
should_be_used_3(); // CHECK: call {{.*}}should_be_used_3 | ||
} | ||
} | ||
|
||
void g() { | ||
f(); | ||
} |