Clang Project

clang_source_code/test/CodeGen/lifetime-debuginfo-2.c
1// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s
2// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-directives-only %s -o - | FileCheck %s
3
4// Inserting lifetime markers should not affect debuginfo: lifetime.end is not
5// a destructor, but instrumentation for the compiler. Ensure the debug info for
6// the return statement (in the IR) does not point to the function closing '}'
7// which is used to show some destructors have been called before leaving the
8// function.
9
10extern int f(int);
11extern int g(int);
12
13// CHECK-LABEL: define i32 @test
14int test(int a, int b) {
15  int res;
16
17  if (a==2) {
18    int r = f(b);
19    res = r + b;
20    a += 2;
21  } else {
22    int r = f(a);
23    res = r + a;
24    b += 1;
25  }
26
27  return res;
28// CHECK: ret i32 %{{.*}}, !dbg [[DI:![0-9]+]]
29// CHECK: [[DI]] = !DILocation(line: [[@LINE-2]]
30}
31