Files
swift-mirror/test/DebugInfo/byref-capture.swift
Adrian Prantl 6632a200f2 Represent indirect function arguments in the DWARF expression instead of the type.
The current approach has several problems:

- Types that are not inout types but loadable may incorrectly get
  marked as inout types.

- When inout arguments get inlined or otherwise optimized LLDB cannot
  rely on the type to decide to dereference that value.

- One argument may get represented by different types in the same
  function depending on what code is generated for it.

Fixes rdar://problem/rdar://problem/39023374
2018-04-03 09:46:58 -07:00

22 lines
740 B
Swift

// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
func makeIncrementor(_ inc : Int64) -> () -> Int64
{
var sum : Int64 = 0
// CHECK: define {{.*}}5inner
func inner() -> Int64 {
// CHECK: call void @llvm.dbg.declare(metadata %Ts5Int64V**
// CHECK-SAME: metadata ![[SUM_CAPTURE:[0-9]+]],
// CHECK-SAME: metadata !DIExpression(DW_OP_deref))
// CHECK: ![[INOUTTY:[0-9]+]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VD"
// CHECK: ![[SUM_CAPTURE]] = !DILocalVariable(name: "sum", arg: 1,
// CHECK-SAME: line: [[@LINE-8]], type: ![[INOUTTY]]
sum += inc
return sum
}
return inner
}
var incrementor = makeIncrementor(5)
incrementor()