Skip to content

Commit e74720b

Browse files
Merge pull request #66260 from adrian-prantl/109123395
Ensure calls to getters have a source location.
2 parents d16329c + 958a157 commit e74720b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

include/swift/SIL/SILLocation.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class SILLocation {
343343
/// Marks the location as coming from auto-generated body.
344344
void markAutoGenerated() { kindAndFlags.fields.autoGenerated = true; }
345345

346-
/// Marks the location as not bein auto-generated.
346+
/// Marks the location as not being auto-generated.
347347
/// FIXME: This functionality is only used to work around bugs and should be
348348
/// removed.
349349
void markNonAutoGenerated() { kindAndFlags.fields.autoGenerated = false; }
@@ -364,6 +364,9 @@ class SILLocation {
364364
/// and these two properties should be merged.
365365
bool isImplicit() const { return kindAndFlags.fields.implicit; }
366366

367+
/// Mark this location as not being implicit.
368+
void markExplicit() { kindAndFlags.fields.implicit = false; }
369+
367370
/// Returns false if the location should be represented in debuginfo.
368371
bool isHiddenFromDebugInfo() const {
369372
return (isAutoGenerated() || isImplicit()) && !hasASTNodeForDebugging();

lib/SILGen/SILGenApply.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -6635,6 +6635,11 @@ RValue SILGenFunction::emitGetAccessor(
66356635
// Scope any further writeback just within this operation.
66366636
FormalEvaluationScope writebackScope(*this);
66376637

6638+
// Calls to getters are implicit because the compiler inserts them on a
6639+
// property access, but the location is useful in backtraces so it should be
6640+
// preserved.
6641+
loc.markExplicit();
6642+
66386643
Callee getter = emitSpecializedAccessorFunctionRef(
66396644
*this, loc, get, substitutions, selfValue, isSuper, isDirectUse,
66406645
isOnSelfParameter);

test/DebugInfo/lazy-getter.swift

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend %s -Onone -emit-ir -g -o - -parse-as-library -module-name a | %FileCheck %s
2+
func use<T>(_ t : T) {}
3+
public func f() -> (() -> ()) {
4+
lazy var i : Int = 0
5+
return {
6+
// CHECK: call {{.*}} @"$s1a1fyycyF1iL_Sivg"({{.*}}), !dbg ![[GETTER_LOC:[0-9]+]]
7+
// CHECK: ![[GETTER_LOC]] = !DILocation(line: [[@LINE+1]], column: 11
8+
use(i)
9+
}
10+
}

0 commit comments

Comments
 (0)