-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Support location info for macro-expanded Clang imports #82006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
j-hui
merged 2 commits into
swiftlang:main
from
j-hui:jump-to-def-for-macro-expanded-clang-imports
Jun 19, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: split-file %s %t | ||
//--- Main.swift | ||
import FromClang // NOTE: line offset = -4 | ||
|
||
// REQUIRES: swift_feature_SafeInteropWrappers | ||
// REQUIRES: swift_feature_LifetimeDependence | ||
|
||
// The macro-generated interface we're looking up source info for | ||
// (this is more so for documentation than checking correctness) | ||
// | ||
// INTERFACE: @_alwaysEmitIntoClient @_disfavoredOverload public func hasBufferOverload(_ p: UnsafeMutableBufferPointer<Int32>) | ||
// INTERFACE: @{{_?}}lifetime(p: copy p) | ||
// INTERFACE-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func hasSpanOverload(_ p: inout MutableSpan<Int32>) | ||
// RUN: %target-swift-ide-test \ | ||
// RUN: -print-module -module-to-print=FromClang -source-filename=x \ | ||
// RUN: -plugin-path %swift-plugin-dir -I %t/Inputs \ | ||
// RUN: -enable-experimental-feature SafeInteropWrappers \ | ||
// RUN: -enable-experimental-feature LifetimeDependence \ | ||
// RUN: | %FileCheck %t/Main.swift --check-prefix INTERFACE | ||
|
||
@inlinable | ||
public func callWithBufferPtr(_ p: UnsafeMutableBufferPointer<CInt>) { | ||
hasBufferOverload(p) | ||
// RUN: %sourcekitd-test -req=cursor -pos=%(line-4):3 %t/Main.swift -- -I %t/Inputs %t/Main.swift \ | ||
// RUN: -enable-experimental-feature SafeInteropWrappers \ | ||
// RUN: -enable-experimental-feature LifetimeDependence \ | ||
// RUN: | %FileCheck %t/Inputs/from-clang.h --check-prefix BUFFER-OVERLOAD | ||
} | ||
|
||
@available(visionOS 1.1, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) | ||
@lifetime(p: copy p) | ||
@inlinable | ||
public func callReturnLifetimeBound(_ p: inout MutableSpan<CInt>) { | ||
hasSpanOverload(p) | ||
// RUN: %sourcekitd-test -req=cursor -pos=%(line-4):3 %t/Main.swift -- -I %t/Inputs %t/Main.swift \ | ||
// RUN: -enable-experimental-feature SafeInteropWrappers \ | ||
// RUN: -enable-experimental-feature LifetimeDependence \ | ||
// RUN: | %FileCheck %t/Inputs/from-clang.h --check-prefix SPAN-OVERLOAD | ||
} | ||
|
||
//--- Inputs/module.modulemap | ||
module FromClang { | ||
header "from-clang.h" | ||
export * | ||
} | ||
|
||
//--- Inputs/from-clang.h | ||
#pragma once | ||
|
||
#define __counted_by(x) __attribute__((__counted_by__(x))) | ||
#define __noescape __attribute__((noescape)) | ||
#define __lifetimebound __attribute__((lifetimebound)) | ||
|
||
void hasBufferOverload(int len, int * __counted_by(len) p); | ||
// BUFFER-OVERLOAD: source.lang.swift.ref.function.free | ||
// BUFFER-OVERLOAD-SAME: from-clang.h:[[@LINE-2]] | ||
|
||
void hasSpanOverload(int len, int * __counted_by(len) __noescape p); | ||
// SPAN-OVERLOAD: source.lang.swift.ref.function.free | ||
// SPAN-OVERLOAD-SAME: from-clang.h:[[@LINE-2]] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.