Files
swift-mirror/SwiftCompilerSources/Sources/SIL/DeclRef.swift
Erik Eckstein 1c9a7cd562 SwiftCompilerSources: refactor DiagnosticEngine
* move it from the SIL to the AST module (where it belongs)
* change the signature of `diagnose` from `diagnose(location, .some_error)` to `diagnose(.some_error, at: location)`
* add an overload to allow passing a `SIL.Location` directly to `diagnose`
* add a `Diagnostic : Error` utility struct which allows throwing a `Diagnostic`
2025-04-18 06:58:38 +02:00

40 lines
1.4 KiB
Swift

//===--- DeclRef.swift ----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import SILBridging
import AST
/// A key for referencing an AST declaration in SIL.
///
/// In addition to the AST reference, there are discriminators for referencing different
/// implementation-level entities associated with a single language-level declaration,
/// such as the allocating and initializing entry points of a constructor, etc.
public struct DeclRef: CustomStringConvertible, NoReflectionChildren {
public let bridged: BridgedDeclRef
public var location: Location { Location(bridged: bridged.getLocation()) }
public var description: String { String(taking: bridged.getDebugDescription()) }
public var decl: Decl { bridged.getDecl().decl }
public static func ==(lhs: DeclRef, rhs: DeclRef) -> Bool {
lhs.bridged.isEqualTo(rhs.bridged)
}
}
extension DeclRef: DiagnosticArgument {
public func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
fn(bridged.asDiagnosticArgument())
}
}