Skip to content

Commit 1ac4b4d

Browse files
committedMay 14, 2024
[SwiftCompilerSources] Add swift_get_access_base unit tests.
Add a unit test harness to SwiftCompilerSources to match the one in C++ since both source bases have different implementations of the same utilities, and they must be consistent for correctness.

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===--- AccessUtils.swift - Utilities for analyzing memory accesses ------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// TODO: Move this to AccessUtils.swift when FunctionTest is available.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
let getAccessBaseTest = FunctionTest("swift_get_access_base") {
18+
function, arguments, context in
19+
let address = arguments.takeValue()
20+
print("Address: \(address)")
21+
let base = address.accessBase
22+
print("Base: \(base)")
23+
}

‎SwiftCompilerSources/Sources/Optimizer/Utilities/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
swift_compiler_sources(Optimizer
10+
AccessUtilsTest.swift
1011
AddressUtils.swift
1112
BorrowedFromUpdater.swift
1213
BorrowUtils.swift

‎SwiftCompilerSources/Sources/Optimizer/Utilities/Test.swift

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ extension BridgedTestArguments {
153153
public func registerOptimizerTests() {
154154
// Register each test.
155155
registerFunctionTests(
156+
getAccessBaseTest,
156157
argumentConventionsTest,
157158
borrowIntroducersTest,
158159
enclosingValuesTest,

0 commit comments

Comments
 (0)
Please sign in to comment.