[clang] [CIR] Add if statement support (PR #134333)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 6 11:26:48 PDT 2025
================
@@ -0,0 +1,254 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
+
+int if0(bool a) {
+
+ if (a)
----------------
Andres-Salamanca wrote:
I’ve added a test for the `if (auto x = something)` case let me know if it looks good now!
I didn’t include the `if (auto x = something; x.something_else)` style yet because I was thinking of doing something like:
```cpp
int if_init_and_cond() {
if (int x = 42; x > 0) {
return x + 2;
} else {
return x - 2;
}
}
```
but `x > 0` fails with BinaryOperator Not Yet Implemented:
If `if (int x = 42; true)` is good enough for now, I can go ahead and add a test for that too just let me know what you prefer.
https://github.com/llvm/llvm-project/pull/134333
More information about the cfe-commits
mailing list