Skip to content

Commit fa0bbcf

Browse files
committed
[SE-0382] Stage in prototypes of macros defined in the standard library.
This are inactive at the moment; we'll conditionally take advantage of them later on. Part of rdar://104346457.
1 parent a9e5075 commit fa0bbcf

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

stdlib/public/core/Macros.swift

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if compiler(>=5.8) && hasAttribute(freestanding)
1413
/// Specifies the module and type name for an externally-defined macro, which
1514
/// must conform to the appropriate set of `Macro` protocols.
1615
///
@@ -24,4 +23,40 @@
2423
public macro externalMacro<T>(module: String, type: String) -> T =
2524
Builtin.ExternalMacro
2625

27-
#endif
26+
// File and path-related information
27+
28+
/// Produces a unique identifier for the given source file, comprised of
29+
/// the module and file name.
30+
@freestanding(expression)
31+
public macro fileID<T: ExpressibleByStringLiteral>() -> T =
32+
Builtin.FileIDMacro
33+
34+
/// Produces the complete path for the given source file.
35+
@freestanding(expression)
36+
public macro filePath<T: ExpressibleByStringLiteral>() -> T =
37+
Builtin.FilePathMacro
38+
39+
/// Produces either the result of `#filePath` or `#file`, depending
40+
/// on whether concise file paths (SE-0274) are enabled.
41+
@freestanding(expression)
42+
public macro file<T: ExpressibleByStringLiteral>() -> T =
43+
Builtin.FileMacro
44+
45+
/// Produces a string representation of the current function name.
46+
@freestanding(expression)
47+
public macro function<T: ExpressibleByStringLiteral>() -> T =
48+
Builtin.FunctionMacro
49+
50+
/// Produces the line number at which the macro is expanded.
51+
@freestanding(expression)
52+
public macro line<T: ExpressibleByIntegerLiteral>() -> T =
53+
Builtin.LineMacro
54+
55+
/// Produces the column number at which the macro is expanded.
56+
@freestanding(expression)
57+
public macro column<T: ExpressibleByIntegerLiteral>() -> T =
58+
Builtin.ColumnMacro
59+
60+
/// Produces the shared object handle for the macro expansion location.
61+
@freestanding(expression)
62+
public macro dsohandle() -> UnsafeRawPointer = Builtin.DSOHandleMacro

0 commit comments

Comments
 (0)