55 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -std=c++17 %s -o %t.cir2// RUN: FileCheck %s --input-file=%t.cir --check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -std=c++17 %s -o %t-cir.ll4// RUN: FileCheck %s --input-file=%t-cir.ll --check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++17 %s -o %t.ll6// RUN: FileCheck %s --input-file=%t.ll --check-prefix=OGCG7 8void bar(const int &i = 42);9 10void foo() {11 bar();12}13 14// CIR: cir.func {{.*}} @_Z3foov()15// CIR: cir.scope {16// CIR: %[[TMP0:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["ref.tmp0"]17// CIR: %[[TMP1:.*]] = cir.const #cir.int<42>18// CIR: cir.store{{.*}} %[[TMP1]], %[[TMP0]]19// CIR: cir.call @_Z3barRKi(%[[TMP0]])20// CIR: }21 22// LLVM: define{{.*}} @_Z3foov()23// LLVM: %[[TMP0:.*]] = alloca i3224// LLVM: br label %[[SCOPE_LABEL:.*]]25// LLVM: [[SCOPE_LABEL]]:26// LLVM: store i32 42, ptr %[[TMP0]]27// LLVM: call void @_Z3barRKi(ptr %[[TMP0]])28 29// OGCG: define{{.*}} @_Z3foov()30// OGCG: %[[TMP0:.*]] = alloca i3231// OGCG: store i32 42, ptr %[[TMP0]]32// OGCG: call void @_Z3barRKi(ptr {{.*}} %[[TMP0]])33 34struct S35{36 S(int n = 2);37};38 39void test_ctor_defaultarg() {40 S s;41}42 43// CIR: cir.func {{.*}} @_Z20test_ctor_defaultargv()44// CIR: %[[S:.*]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["s", init]45// CIR: %[[TWO:.*]] = cir.const #cir.int<2> : !s32i46// CIR: cir.call @_ZN1SC1Ei(%[[S]], %[[TWO]]) : (!cir.ptr<!rec_S>, !s32i) -> ()47 48// LLVM: define{{.*}} @_Z20test_ctor_defaultargv()49// LLVM: %[[S:.*]] = alloca %struct.S50// LLVM: call void @_ZN1SC1Ei(ptr %[[S]], i32 2)51 52// OGCG: define{{.*}} @_Z20test_ctor_defaultargv()53// OGCG: %[[S:.*]] = alloca %struct.S54// OGCG: call void @_ZN1SC1Ei(ptr{{.*}} %[[S]], i32 {{.*}} 2)55