Skip to content

Commit 35902a5

Browse files
[swiftsrc2cpg] Added more std lib builtin functions (#5598)
1 parent 5e29bd4 commit 35902a5

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

joern-cli/frontends/swiftsrc2cpg/src/main/scala/io/joern/swiftsrc2cpg/passes/GlobalBuiltins.scala

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ object GlobalBuiltins {
88
"print", // Prints values to standard output
99
"debugPrint", // Prints debug description of values
1010
"dump", // Dumps detailed object structure information
11+
"readLine", // Returns a string read from standard input through the end of the current line or until EOF is reached
1112

1213
// Type Conversion Functions
1314
"String", // Converts a value to a string
@@ -19,6 +20,12 @@ object GlobalBuiltins {
1920
"Dictionary", // Creates a dictionary from a sequence of key-value pairs
2021
"Set", // Creates a set from a sequence
2122

23+
// Types and type casting
24+
"type", // Returns the dynamic type of a value
25+
"numericCast", // Returns the given integer as the equivalent value in a different integer type
26+
"unsafeDowncast", // Returns the given instance cast unconditionally to the specified type
27+
"unsafeBitCast", // Returns the bits of the given instance, interpreted as having the specified type
28+
2229
// Collection Functions
2330
"min", // Returns the minimum element in a sequence
2431
"max", // Returns the maximum element in a sequence
@@ -46,18 +53,20 @@ object GlobalBuiltins {
4653
"ceil", // Returns the smallest integer not less than the given number
4754

4855
// Memory Management Functions
56+
"extendLifetime", // Extends the lifetime of the given instance
57+
"withExtendedLifetime", // Extends the lifetime of an object during the execution of a closure
58+
"withoutActuallyEscaping", // Temporarily treats a non-escaping closure as an escaping one
4959
"withUnsafePointer", // Invokes a closure with a pointer to a value
5060
"withUnsafeMutablePointer", // Invokes a closure with a mutable pointer to a value
5161
"withUnsafeBytes", // Invokes a closure with the bytes of a value
5262
"withUnsafeMutableBytes", // Invokes a closure with mutable bytes of a value
53-
"autoreleasepool", // Creates an autorelease pool and executes the given closure within it
63+
"withUnsafeTemporaryAllocation", // Provides scoped access to a buffer pointer to memory of the specified type and with the specified capacity
64+
"autoreleasepool", // Creates an autorelease pool and executes the given closure within it
5465

5566
// Runtime Functions
56-
"type", // Returns the dynamic type of a value
5767
"MemoryLayout.size", // Returns the size in bytes of the given value's type
5868
"MemoryLayout.stride", // Returns the stride in bytes of the given value's type
5969
"MemoryLayout.alignment", // Returns the alignment in bytes of the given value's type
60-
"unsafeBitCast", // Reinterprets the bits of a value of one type as another type
6170

6271
// Error Handling Functions
6372
"assert", // Checks a condition and stops execution if it's false (in debug builds)
@@ -66,9 +75,25 @@ object GlobalBuiltins {
6675
"preconditionFailure", // Indicates that a precondition has failed (in all builds)
6776
"fatalError", // Unconditionally prints a message and stops execution
6877

78+
// Concurrrency
79+
"withTaskGroup", // Starts a new scope that can contain a dynamic number of child tasks
80+
"withThrowingTaskGroup", // Starts a new scope that can contain a dynamic number of throwing child tasks
81+
"withDiscardingTaskGroup", // Starts a new scope that can contain a dynamic number of child tasks
82+
"withThrowingDiscardingTaskGroup", // Starts a new scope that can contain a dynamic number of child tasks
83+
"withCheckedContinuation", // Invokes the passed in closure with a checked continuation for the current task
84+
"withCheckedThrowingContinuation", // Invokes the passed in closure with a checked continuation for the current task
85+
"withUnsafeContinuation", // Invokes the passed in closure with a unsafe continuation for the current task
86+
"withUnsafeThrowingContinuation", // Invokes the passed in closure with a unsafe continuation for the current task
87+
"extractIsolation", // Returns a reference to the actor to which the function is isolated, or nil if it is nonisolated
88+
"withTaskExecutorPreference", // Configure the current task hierarchy’s task executor preference to the passed TaskExecutor, and execute the passed in closure by immediately hopping to that executor
89+
90+
// C Interoperability
91+
"withVaList", // Invokes the given closure with a C va_list argument derived from the given array of arguments
92+
"getVaList", // Returns a CVaListPointer that is backed by autoreleased storage, built from the given array of arguments
93+
6994
// Miscellaneous Functions
70-
"swap", // Exchanges the values of two variables
71-
"withExtendedLifetime" // Extends the lifetime of an object during the execution of a closure
95+
"swap", // Exchanges the values of two variables
96+
"exchange" // Replaces the value of a mutable value with the supplied new value, returning the original.
7297
)
7398

7499
}

0 commit comments

Comments
 (0)