brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · aaf25ca Raw
44 lines · cpp
1// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -O1 -emit-llvm -fextend-variable-liveness -o - | FileCheck %s2// Make sure we don't crash compiling a lambda that is not nested in a function.3// We also check that fake uses are properly issued in lambdas.4 5int glob;6 7extern int foo();8 9struct S {10  static const int a;11};12 13const int S::a = [](int b) __attribute__((noinline)) {14  return b * foo();15}16(glob);17 18int func(int param) {19  return ([=](int lambdaparm) __attribute__((noinline))->int {20    int lambdalocal = lambdaparm * 2;21    return lambdalocal;22  }(glob));23}24 25// We are looking for the first lambda's call operator, which should contain26// 2 fake uses, one for 'b' and one for its 'this' pointer (in that order).27// The mangled function name contains a $_0, followed by 'cl'.28// This lambda is an orphaned lambda, i.e. one without lexical parent.29//30// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}}31// CHECK-NOT:   ret32// CHECK:       fake.use(i3233// CHECK-NOT:   ret34// CHECK:       fake.use(ptr35 36// The second lambda. We are looking for 3 fake uses.37// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}}38// CHECK-NOT:   ret39// CHECK:       fake.use(i3240// CHECK-NOT:   ret41// CHECK:       fake.use(i3242// CHECK-NOT:   ret43// CHECK:       fake.use(ptr44