Files
swift-mirror/test/DebugInfo/autoclosure.swift
Adrian Prantl c241ff305e Emit compiler-generated debug locations for outlined transparent functions.
In the majority of the use-cases transparent functions are inlined by
the mandatory inliner which by design drops all debug info and
pretends the inlined instructions were always part of the
caller. Since an outlined copy of the function is often still
generated, attaching debug locations to it is inconsistent and can
create the false impression that it were possible to set a breakpoint
in such a function when in reality these functions are only there for
very few edge cases.

<rdar://problem/40258813>
2018-05-17 16:38:04 -07:00

33 lines
1020 B
Swift

// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
// CHECK: define{{.*}}@"$S11autoclosure7call_meyys5Int64VF"
// CHECK-NOT: ret void
// CHECK: call void @llvm.dbg.declare{{.*}}, !dbg
// CHECK-NOT: ret void
// CHECK: _value {{.*}}, !dbg ![[DBG:.*]]
// CHECK: ret void
func get_truth(_ input: Int64) -> Int64 {
return input % 2
}
// Since this is an autoclosure test, don't use &&, which is transparent.
infix operator &&&&& : LogicalConjunctionPrecedence
func &&&&&(lhs: Bool, rhs: @autoclosure () -> Bool) -> Bool {
return lhs ? rhs() : false
}
func call_me(_ input: Int64) -> Void {
// rdar://problem/14627460
// An autoclosure should have a line number in the debug info and a scope line of 0.
// CHECK-DAG: !DISubprogram({{.*}}linkageName: "$S11autoclosure7call_meyys5Int64VFSbyXKfu_",{{.*}} isLocal: true, isDefinition: true
// But not in the line table.
// CHECK-DAG: ![[DBG]] = !DILocation(line: [[@LINE+1]],
if input != 0 &&&&& ( get_truth (input * 2 + 1) > 0 ) {
}
}
call_me(5)