Skip to content

Commit 446c56a

Browse files
committed
SwiftCompilerSources: add VarDecl.sourceLoc
1 parent 66938f4 commit 446c56a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,11 @@ public struct VarDecl {
396396
guard let decl = bridged.raw else { return nil }
397397
self.bridged = BridgedVarDecl(raw: decl)
398398
}
399-
399+
400+
public var sourceLoc: SourceLoc? {
401+
return SourceLoc(bridged: bridged.getSourceLocation())
402+
}
403+
400404
public var userFacingName: String { String(bridged.getUserFacingName()) }
401405
}
402406

@@ -943,6 +947,8 @@ final public class BeginBorrowInst : SingleValueInstruction, UnaryInstruction, B
943947
public var borrowedValue: Value { operand.value }
944948

945949
public var isLexical: Bool { bridged.BeginBorrow_isLexical() }
950+
951+
public var isFromVarDecl: Bool { bridged.BeginBorrow_isFromVarDecl() }
946952
}
947953

948954
final public class ProjectBoxInst : SingleValueInstruction, UnaryInstruction {
@@ -957,6 +963,8 @@ final public class CopyValueInst : SingleValueInstruction, UnaryInstruction {
957963
final public class MoveValueInst : SingleValueInstruction, UnaryInstruction {
958964
public var fromValue: Value { operand.value }
959965

966+
public var isLexical: Bool { bridged.MoveValue_isLexical() }
967+
960968
public var isFromVarDecl: Bool { bridged.MoveValue_isFromVarDecl() }
961969
}
962970

include/swift/AST/ASTBridgingImpl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ BridgedSubscriptDecl_asAbstractStorageDecl(BridgedSubscriptDecl decl) {
5858
// MARK: BridgedVarDecl
5959
//===----------------------------------------------------------------------===//
6060

61+
BridgedSourceLoc BridgedVarDecl_getSourceLocation(BridgedVarDecl decl) {
62+
swift::SourceLoc sourceLoc = decl.unbridged()->getNameLoc();
63+
return BridgedSourceLoc(sourceLoc.getOpaquePointerValue());
64+
}
65+
6166
BridgedStringRef BridgedVarDecl_getUserFacingName(BridgedVarDecl decl) {
6267
return decl.unbridged()->getBaseName().userFacingName();
6368
}

include/swift/SIL/SILBridging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,10 @@ struct BridgedInstruction {
762762
BRIDGED_INLINE OptionalBridgedValue StructInst_getUniqueNonTrivialFieldValue() const;
763763
BRIDGED_INLINE SwiftInt StructElementAddrInst_fieldIndex() const;
764764
BRIDGED_INLINE bool BeginBorrow_isLexical() const;
765+
BRIDGED_INLINE bool BeginBorrow_isFromVarDecl() const;
766+
BRIDGED_INLINE bool MoveValue_isLexical() const;
767+
BRIDGED_INLINE bool MoveValue_isFromVarDecl() const;
768+
765769
BRIDGED_INLINE SwiftInt ProjectBoxInst_fieldIndex() const;
766770
BRIDGED_INLINE bool EndCOWMutationInst_doKeepUnique() const;
767771
BRIDGED_INLINE SwiftInt EnumInst_caseIndex() const;

0 commit comments

Comments
 (0)