Debian Codegraph @

clang/test/CIR/CodeGen/non-type-template-param.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 template <const int N>
9 void template_foo() {
10 int a = N + 5;
11 }
12
13 // CIR: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
14 // CIR: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
15 // CIR: %[[CONST_2:.*]] = cir.const #cir.int<5> : !s32i
16 // CIR: %[[ADD:.*]] = cir.binop(add, %[[CONST_1]], %[[CONST_2]]) nsw : !s32i
17 // CIR: cir.store{{.*}} %[[ADD]], %[[INIT]] : !s32i, !cir.ptr<!s32i>
18
19 // LLVM: %[[INIT:.*]] = alloca i32, i64 1, align 4
20 // LLVM: store i32 6, ptr %[[INIT]], align 4
21
22 // OGCG: %[[INIT:.*]] = alloca i32, align 4
23 // OGCG: store i32 6, ptr %[[INIT]], align 4
24
25 void foo() {
26 template_foo<1>();
27 }