Skip to content

Commit 0a8fb8e

Browse files
authored
Merge pull request #166 from CodaFi/by-another-name
Metadata -> IRMetadata
2 parents 020994e + fdeae42 commit 0a8fb8e

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

Sources/LLVM/DIBuilder.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ extension DIBuilder {
984984
/// - line: Line number of the declaration.
985985
/// - name: The name of the imported declaration.
986986
public func buildImportedDeclaration(
987-
in context: DIScope, declaration: Metadata,
987+
in context: DIScope, declaration: IRMetadata,
988988
file: FileMetadata, line: Int, name: String = ""
989989
) -> ImportedEntityMetadata {
990990
guard let mod = LLVMDIBuilderCreateImportedDeclaration(
@@ -1111,7 +1111,7 @@ extension DIBuilder {
11111111
scope: DIScope, file: FileMetadata, line: Int,
11121112
isLocal: Bool = true,
11131113
expression: ExpressionMetadata? = nil,
1114-
declaration: Metadata? = nil,
1114+
declaration: IRMetadata? = nil,
11151115
alignment: Alignment = .zero
11161116
) -> ExpressionMetadata {
11171117
let radix = UInt32(self.module.dataLayout.intPointerType().width)

Sources/LLVM/Metadata.swift renamed to Sources/LLVM/IRMetadata.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ public protocol _IRMetadataInitializerHack {
4141
/// to compile a program to native machine code and standard debugging
4242
/// formats. This allows compatibility with traditional machine-code level
4343
/// debuggers, like GDB, DBX, or CodeView.
44-
public protocol Metadata: _IRMetadataInitializerHack {
44+
public protocol IRMetadata: _IRMetadataInitializerHack {
4545
/// Retrieves the underlying LLVM metadata object.
4646
func asMetadata() -> LLVMMetadataRef
4747
}
4848

49-
extension Metadata {
49+
extension IRMetadata {
5050
/// Replaces all uses of the this metadata with the given metadata.
5151
///
5252
/// - parameter metadata: The new value to swap in.
53-
public func replaceAllUses(with metadata: Metadata) {
53+
public func replaceAllUses(with metadata: IRMetadata) {
5454
LLVMMetadataReplaceAllUsesWith(self.asMetadata(), metadata.asMetadata())
5555
}
5656
}
5757

58-
extension Metadata {
58+
extension IRMetadata {
5959
/// Dumps a representation of this metadata to stderr.
6060
public func dump() {
6161
LLVMDumpValue(LLVMMetadataAsValue(LLVMGetGlobalContext(), self.asMetadata()))
@@ -66,13 +66,13 @@ extension Metadata {
6666
/// - warning: In general, use of this method is discouraged and can
6767
/// lead to unpredictable results or undefined behavior. No checks are
6868
/// performed before, during, or after the cast.
69-
public func forceCast<DestTy: Metadata>(to: DestTy.Type) -> DestTy {
69+
public func forceCast<DestTy: IRMetadata>(to: DestTy.Type) -> DestTy {
7070
return DestTy(llvm: self.asMetadata())
7171
}
7272
}
7373

7474
/// Denotes a scope in which child metadata nodes can be inserted.
75-
public protocol DIScope: Metadata {}
75+
public protocol DIScope: IRMetadata {}
7676

7777
/// Denotes metadata for a type.
7878
public protocol DIType: DIScope {}
@@ -113,7 +113,7 @@ extension DIType {
113113
}
114114

115115
/// A `DebugLocation` represents a location in source.
116-
public struct DebugLocation: Metadata {
116+
public struct DebugLocation: IRMetadata {
117117
internal let llvm: LLVMMetadataRef
118118

119119
public func asMetadata() -> LLVMMetadataRef {
@@ -140,7 +140,7 @@ public struct DebugLocation: Metadata {
140140
}
141141
}
142142

143-
struct AnyMetadata: Metadata {
143+
struct AnyMetadata: IRMetadata {
144144
let llvm: LLVMMetadataRef
145145

146146
func asMetadata() -> LLVMMetadataRef {
@@ -271,7 +271,7 @@ public struct LexicalBlockFileMetadata: DIScope {
271271

272272
/// `LocalVariableMetadata` nodes represent local variables and function
273273
/// parameters in the source language.
274-
public struct LocalVariableMetadata: Metadata {
274+
public struct LocalVariableMetadata: IRMetadata {
275275
internal let llvm: LLVMMetadataRef
276276

277277
public func asMetadata() -> LLVMMetadataRef {
@@ -284,7 +284,7 @@ public struct LocalVariableMetadata: Metadata {
284284
}
285285

286286
/// `ObjectiveCPropertyMetadata` nodes represent Objective-C property nodes.
287-
public struct ObjectiveCPropertyMetadata: Metadata {
287+
public struct ObjectiveCPropertyMetadata: IRMetadata {
288288
internal let llvm: LLVMMetadataRef
289289

290290
public func asMetadata() -> LLVMMetadataRef {
@@ -362,7 +362,7 @@ public struct NameSpaceMetadata: DIScope {
362362
///
363363
/// Though DWARF supports hundreds of expressions, LLVM currently implements
364364
/// a very limited subset.
365-
public struct ExpressionMetadata: Metadata {
365+
public struct ExpressionMetadata: IRMetadata {
366366
internal let llvm: LLVMMetadataRef
367367

368368
public func asMetadata() -> LLVMMetadataRef {

Sources/LLVM/NamedMetadata.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public class NamedMetadata {
1717
}
1818

1919
/// Computes the operands of a named metadata node.
20-
public var operands: [Metadata] {
20+
public var operands: [IRMetadata] {
2121
let count = Int(LLVMGetNamedMetadataNumOperands(self.module.llvm, name))
2222
let operands = UnsafeMutablePointer<LLVMValueRef?>.allocate(capacity: count)
2323
LLVMGetNamedMetadataOperands(self.module.llvm, name, operands)
2424

25-
var ops = [Metadata]()
25+
var ops = [IRMetadata]()
2626
ops.reserveCapacity(count)
2727
for i in 0..<count {
2828
guard let rawOperand = operands[i] else {
@@ -37,7 +37,7 @@ public class NamedMetadata {
3737
}
3838

3939
/// Appends a metadata node as an operand.
40-
public func addOperand(_ op: Metadata) {
40+
public func addOperand(_ op: IRMetadata) {
4141
let metaVal = LLVMMetadataAsValue(self.module.context.llvm, op.asMetadata())
4242
LLVMAddNamedMetadataOperand(self.module.llvm, self.name, metaVal)
4343
}

0 commit comments

Comments
 (0)