[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / builtin_LINE.cpp
blobb32c142b34ac8d4b5adc06b107103cc4f76b223d
1 // RUN: %clang_cc1 -std=c++1z -fblocks %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
3 extern "C" int sink;
4 extern "C" const volatile void* volatile ptr_sink = nullptr;
6 struct Tag1 {};
7 struct Tag2 {};
8 struct Tag3 {};
9 struct Tag4 {};
11 constexpr int get_line_constexpr(int l = __builtin_LINE()) {
12 return l;
15 int get_line_nonconstexpr(int l = __builtin_LINE()) {
16 return l;
20 int get_line(int l = __builtin_LINE()) {
21 return l;
24 int get_line2(int l = get_line()) { return l; }
27 // CHECK: @global_one ={{.*}} global i32 [[@LINE+1]], align 4
28 int global_one = __builtin_LINE();
29 // CHECK-NEXT: @global_two ={{.*}} global i32 [[@LINE+1]], align 4
30 int global_two = get_line_constexpr();
31 // CHECK: @_ZL12global_three = internal constant i32 [[@LINE+1]], align 4
32 const int global_three(get_line_constexpr());
34 // CHECK-LABEL: define internal void @__cxx_global_var_init
35 // CHECK: %call = call noundef i32 @_Z21get_line_nonconstexpri(i32 noundef [[@LINE+2]])
36 // CHECK-NEXT: store i32 %call, ptr @global_four, align 4
37 int global_four = get_line_nonconstexpr();
39 struct InClassInit {
40 int Init = __builtin_LINE();
41 int Init2 = get_line2();
42 InClassInit();
43 constexpr InClassInit(Tag1, int l = __builtin_LINE()) : Init(l), Init2(l) {}
44 constexpr InClassInit(Tag2) : Init(__builtin_LINE()), Init2(__builtin_LINE()) {}
45 InClassInit(Tag3, int l = __builtin_LINE());
46 InClassInit(Tag4, int l = get_line2());
48 static void test_class();
50 // CHECK-LABEL: define{{.*}} void @_ZN11InClassInit10test_classEv()
51 void InClassInit::test_class() {
52 // CHECK: call void @_ZN11InClassInitC1Ev(ptr {{[^,]*}} %test_one)
53 InClassInit test_one;
54 // CHECK-NEXT: call void @_ZN11InClassInitC1E4Tag1i(ptr {{[^,]*}} %test_two, i32 noundef [[@LINE+1]])
55 InClassInit test_two{Tag1{}};
56 // CHECK-NEXT: call void @_ZN11InClassInitC1E4Tag2(ptr {{[^,]*}} %test_three)
57 InClassInit test_three{Tag2{}};
58 // CHECK-NEXT: call void @_ZN11InClassInitC1E4Tag3i(ptr {{[^,]*}} %test_four, i32 noundef [[@LINE+1]])
59 InClassInit test_four(Tag3{});
60 // CHECK-NEXT: %[[CALL:.+]] = call noundef i32 @_Z8get_linei(i32 noundef [[@LINE+3]])
61 // CHECK-NEXT: %[[CALL2:.+]] = call noundef i32 @_Z9get_line2i(i32 noundef %[[CALL]])
62 // CHECK-NEXT: call void @_ZN11InClassInitC1E4Tag4i(ptr {{[^,]*}} %test_five, i32 noundef %[[CALL2]])
63 InClassInit test_five(Tag4{});
66 // CHECK-LABEL: define{{.*}} void @_ZN11InClassInitC2Ev
67 // CHECK: store i32 [[@LINE+4]], ptr %Init, align 4
68 // CHECK: %call = call noundef i32 @_Z8get_linei(i32 noundef [[@LINE+3]])
69 // CHECK-NEXT: %call2 = call noundef i32 @_Z9get_line2i(i32 noundef %call)
70 // CHECK-NEXT: store i32 %call2, ptr %Init2, align 4
71 InClassInit::InClassInit() = default;
73 InClassInit::InClassInit(Tag3, int l) : Init(l) {}
75 // CHECK-LABEL: define{{.*}} void @_ZN11InClassInitC2E4Tag4i(ptr {{[^,]*}} %this, i32 noundef %arg)
76 // CHECK: %[[TEMP:.+]] = load i32, ptr %arg.addr, align 4
77 // CHECK-NEXT: store i32 %[[TEMP]], ptr %Init, align 4
78 // CHECK: %[[CALL:.+]] = call noundef i32 @_Z8get_linei(i32 noundef [[@LINE+3]])
79 // CHECK-NEXT: %[[CALL2:.+]] = call noundef i32 @_Z9get_line2i(i32 noundef %[[CALL]])
80 // CHECK-NEXT: store i32 %[[CALL2]], ptr %Init2, align 4
81 InClassInit::InClassInit(Tag4, int arg) : Init(arg) {}
83 // CHECK-LABEL: define{{.*}} void @_Z13get_line_testv()
84 void get_line_test() {
85 // CHECK: %[[CALL:.+]] = call noundef i32 @_Z8get_linei(i32 noundef [[@LINE+2]])
86 // CHECK-NEXT: store i32 %[[CALL]], ptr @sink, align 4
87 sink = get_line();
88 // CHECK-NEXT: store i32 [[@LINE+1]], ptr @sink, align 4
89 sink = __builtin_LINE();
90 ptr_sink = &global_three;
93 void foo() {
94 const int N[] = {__builtin_LINE(), get_line_constexpr()};