This extends the CastOp folder to handle integral casts between different integer types. This only handles scalar values at this time. This is in preparation for a change that will attempt to fold casts as they are generated, but this change only performs the folding via the cir-canonicalize pass.
28 lines
452 B
C++
28 lines
452 B
C++
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
|
|
// RUN: FileCheck %s --input-file=%t.cir
|
|
|
|
enum Numbers {
|
|
Zero,
|
|
One,
|
|
Two,
|
|
Three
|
|
};
|
|
|
|
int f() {
|
|
return Numbers::One;
|
|
}
|
|
|
|
// CHECK: cir.func{{.*}} @_Z1fv
|
|
// CHECK: cir.const #cir.int<1> : !s32i
|
|
|
|
namespace test {
|
|
using enum Numbers;
|
|
};
|
|
|
|
int f2() {
|
|
return test::Two;
|
|
}
|
|
|
|
// CHECK: cir.func{{.*}} @_Z2f2v
|
|
// CHECK: cir.const #cir.int<2> : !s32i
|