203 lines · cpp
1// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \2// RUN: -std=c++11 -gcodeview -gno-column-info -emit-llvm -o - %s \3// RUN: | FileCheck -check-prefix=NONEST %s4// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \5// RUN: -std=c++11 -gcodeview -emit-llvm -o - %s \6// RUN: | FileCheck -check-prefix=COLUMNS %s7// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \8// RUN: -std=c++11 -gno-column-info -emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s9// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \10// RUN: -std=c++11 -emit-llvm -o - %s \11// RUN: | FileCheck -check-prefix=COLUMNS %s12 13class Foo {14public:15 static Foo create();16 void func();17 int *begin();18 int *end();19};20 21int bar(int x, int y);22int baz(int x, int y);23int qux(int x, int y);24int onearg(int x);25int noargs();26int noargs1();27Foo range(int x);28 29int foo(int x, int y, int z) {30 int a = bar(x, y) +31 baz(x, z) +32 qux(y, z);33 // NONEST: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]]34 // NONEST: call noundef i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]]35 // NONEST: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]]36 // NONEST: store i32 {{.*}}, ptr %a,{{.*}} !dbg ![[LOC]]37 // NESTED: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]38 // NESTED: call noundef i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]39 // NESTED: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]40 // NESTED: store i32 {{.*}}, ptr %a,{{.*}} !dbg ![[BAR]]41 // COLUMNS: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]]42 // COLUMNS: call noundef i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]]43 // COLUMNS: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]]44 // COLUMNS: store i32 {{.*}}, ptr %a,{{.*}} !dbg ![[DECLA:[0-9]+]]45 46 int i = 1, b = 0, c = 0;47 // NONEST: store i32 1, ptr %i,{{.*}} !dbg ![[ILOC:[0-9]+]]48 // NONEST: store i32 0, ptr %b,{{.*}} !dbg ![[ILOC]]49 // NONEST: store i32 0, ptr %c,{{.*}} !dbg ![[ILOC]]50 // NESTED: store i32 1, ptr %i,{{.*}} !dbg ![[ILOC:[0-9]+]]51 // NESTED: store i32 0, ptr %b,{{.*}} !dbg ![[ILOC]]52 // NESTED: store i32 0, ptr %c,{{.*}} !dbg ![[ILOC]]53 // COLUMNS: store i32 1, ptr %i,{{.*}} !dbg ![[ILOC:[0-9]+]]54 // COLUMNS: store i32 0, ptr %b,{{.*}} !dbg ![[BLOC:[0-9]+]]55 // COLUMNS: store i32 0, ptr %c,{{.*}} !dbg ![[CLOC:[0-9]+]]56 57 while (i > 0) {58 b = bar(a, b);59 --i;60 }61 // NONEST: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]62 // NONEST: store i32 %{{[^,]+}}, ptr %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]63 // NESTED: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]64 // NESTED: store i32 %{{[^,]+}}, ptr %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]65 // COLUMNS: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]]66 // COLUMNS: store i32 %{{[^,]+}}, ptr %i,{{.*}} !dbg ![[WHILE2:[0-9]+]]67 68 for (i = 0; i < 1; i++) {69 b = bar(a, b);70 c = qux(a, c);71 }72 // NONEST: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]73 // NONEST: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]74 // NESTED: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]75 // NESTED: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]76 // COLUMNS: call noundef i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]]77 // COLUMNS: call noundef i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]]78 79 if (a < b) {80 int t = a;81 a = b;82 b = t;83 }84 // NONEST: store i32 %{{[^,]+}}, ptr %t,{{.*}} !dbg ![[IF1:[0-9]+]]85 // NONEST: store i32 %{{[^,]+}}, ptr %a,{{.*}} !dbg ![[IF2:[0-9]+]]86 // NONEST: store i32 %{{[^,]+}}, ptr %b,{{.*}} !dbg ![[IF3:[0-9]+]]87 // NESTED: store i32 %{{[^,]+}}, ptr %t,{{.*}} !dbg ![[IF1:[0-9]+]]88 // NESTED: store i32 %{{[^,]+}}, ptr %a,{{.*}} !dbg ![[IF2:[0-9]+]]89 // NESTED: store i32 %{{[^,]+}}, ptr %b,{{.*}} !dbg ![[IF3:[0-9]+]]90 // COLUMNS: store i32 %{{[^,]+}}, ptr %t,{{.*}} !dbg ![[IF1:[0-9]+]]91 // COLUMNS: store i32 %{{[^,]+}}, ptr %a,{{.*}} !dbg ![[IF2:[0-9]+]]92 // COLUMNS: store i32 %{{[^,]+}}, ptr %b,{{.*}} !dbg ![[IF3:[0-9]+]]93 94 int d = onearg(95 noargs());96 // NONEST: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[DECLD:[0-9]+]]97 // NONEST: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[DECLD]]98 // NONEST: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[DECLD]]99 // NESTED: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[DNOARGS:[0-9]+]]100 // NESTED: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[DECLD:[0-9]+]]101 // NESTED: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[DECLD]]102 // COLUMNS: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[DNOARGS:[0-9]+]]103 // COLUMNS: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[DONEARG:[0-9]+]]104 // COLUMNS: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[DECLD:[0-9]+]]105 106 d = onearg(noargs());107 // NONEST: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[SETD:[0-9]+]]108 // NONEST: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[SETD]]109 // NONEST: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[SETD]]110 // NESTED: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[SETD:[0-9]+]]111 // NESTED: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[SETD]]112 // NESTED: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[SETD]]113 // COLUMNS: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[SETDNOARGS:[0-9]+]]114 // COLUMNS: call noundef i32 @{{.*}}onearg{{.*}}, !dbg ![[SETDONEARG:[0-9]+]]115 // COLUMNS: store i32 %{{[^,]+}}, ptr %d,{{.*}} !dbg ![[SETD:[0-9]+]]116 117 for (const auto x : range(noargs())) noargs1();118 // NONEST: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[RANGEFOR:[0-9]+]]119 // NONEST: call {{.+}} @{{.*}}range{{.*}}, !dbg ![[RANGEFOR]]120 // NONEST: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[RANGEFOR_BODY:[0-9]+]]121 // NESTED: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[RANGEFOR:[0-9]+]]122 // NESTED: call {{.+}} @{{.*}}range{{.*}}, !dbg ![[RANGEFOR]]123 // NESTED: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[RANGEFOR_BODY:[0-9]+]]124 // COLUMNS: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[RANGEFOR_NOARGS:[0-9]+]]125 // COLUMNS: call {{.+}} @{{.*}}range{{.*}}, !dbg ![[RANGEFOR_RANGE:[0-9]+]]126 // COLUMNS: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[RANGEFOR_BODY:[0-9]+]]127 128 if (noargs() && noargs1()) {129 Foo::create().func();130 }131 // NONEST: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[AND:[0-9]+]]132 // NONEST: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[AND]]133 // NONEST: call {{.+}} @{{.*}}create{{.*}}, !dbg ![[AND_BODY:[0-9]+]]134 // NONEST: call void @{{.*}}func{{.*}}, !dbg ![[AND_BODY]]135 // NESTED: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[AND:[0-9]+]]136 // NESTED: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[AND]]137 // NESTED: call {{.+}} @{{.*}}create{{.*}}, !dbg ![[AND_BODY:[0-9]+]]138 // NESTED: call void @{{.*}}func{{.*}}, !dbg ![[AND_BODY]]139 // COLUMNS: call noundef i32 @{{.*}}noargs{{.*}}, !dbg ![[ANDLHS:[0-9]+]]140 // COLUMNS: call noundef i32 @{{.*}}noargs1{{.*}}, !dbg ![[ANDRHS:[0-9]+]]141 // COLUMNS: call {{.+}} @{{.*}}create{{.*}}, !dbg ![[AND_CREATE:[0-9]+]]142 // COLUMNS: call void @{{.*}}func{{.*}}, !dbg ![[AND_FUNC:[0-9]+]]143 144 return a -145 (b * z);146 // NONEST: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]]147 // NONEST: sub nsw i32 {{.*}}, !dbg ![[RETLOC]]148 // NONEST: ret i32 {{.*}}, !dbg ![[RETLOC]]149 // NESTED: mul nsw i32 {{.*}}, !dbg ![[RETMUL:[0-9]+]]150 // NESTED: sub nsw i32 {{.*}}, !dbg ![[RETSUB:[0-9]+]]151 // NESTED: ret i32 {{.*}}, !dbg !152 // COLUMNS: mul nsw i32 {{.*}}, !dbg ![[RETMUL:[0-9]+]]153 // COLUMNS: sub nsw i32 {{.*}}, !dbg ![[RETSUB:[0-9]+]]154 // COLUMNS: ret i32 {{.*}}, !dbg !155}156 157// NONEST: ![[WHILE1]] = !DILocation(158// NONEST: ![[WHILE2]] = !DILocation(159// NONEST: ![[FOR1]] = !DILocation(160// NONEST: ![[FOR2]] = !DILocation(161// NONEST: ![[IF1]] = !DILocation(162// NONEST: ![[IF2]] = !DILocation(163// NONEST: ![[IF3]] = !DILocation(164// NONEST: ![[RANGEFOR]] = !DILocation(165// NONEST-SAME: line: [[RANGEFOR_LINE:[0-9]+]]166// NONEST: ![[RANGEFOR_BODY]] = !DILocation(167// NONEST-SAME: line: [[RANGEFOR_LINE]]168 169// NESTED: ![[BAR]] = !DILocation(170// NESTED: ![[BAZ]] = !DILocation(171// NESTED: ![[QUX]] = !DILocation(172// NESTED: ![[DECLD]] = !DILocation173// NESTED: ![[DNOARGS]] = !DILocation174// NESTED: ![[RANGEFOR]] = !DILocation(175// NESTED-SAME: line: [[RANGEFOR_LINE:[0-9]+]]176// NESTED: ![[RANGEFOR_BODY]] = !DILocation(177// NESTED-SAME: line: [[RANGEFOR_LINE]]178// NESTED: ![[RETSUB]] = !DILocation(179// NESTED: ![[RETMUL]] = !DILocation(180 181// COLUMNS: ![[DECLA]] = !DILocation(182// COLUMNS: ![[BAR]] = !DILocation(183// COLUMNS: ![[BAZ]] = !DILocation(184// COLUMNS: ![[QUX]] = !DILocation(185// COLUMNS: ![[ILOC]] = !DILocation(186// COLUMNS: ![[BLOC]] = !DILocation(187// COLUMNS: ![[CLOC]] = !DILocation(188// COLUMNS: ![[DECLD]] = !DILocation(189// COLUMNS: ![[DNOARGS]] = !DILocation(190// COLUMNS: ![[DONEARG]] = !DILocation(191// COLUMNS: ![[SETDNOARGS]] = !DILocation(192// COLUMNS: ![[SETDONEARG]] = !DILocation(193// COLUMNS: ![[SETD]] = !DILocation(194// COLUMNS: ![[RANGEFOR_NOARGS]] = !DILocation(195// COLUMNS: ![[RANGEFOR_RANGE]] = !DILocation(196// COLUMNS: ![[RANGEFOR_BODY]] = !DILocation(197// COLUMNS: ![[ANDLHS]] = !DILocation198// COLUMNS: ![[ANDRHS]] = !DILocation199// COLUMNS: ![[AND_CREATE]] = !DILocation200// COLUMNS: ![[AND_FUNC]] = !DILocation201// COLUNMS: ![[RETSUB]] = !DILocation(202// COLUMNS: ![[RETMUL]] = !DILocation(203