15 Commits

Author SHA1 Message Date
Erik Eckstein
63cb683cb7 SIL: improve some Location APIs
* rename `var autoGenerated` -> `var asAutoGenerated`
* add `var asCleanup`
* add `func withScope`
2025-06-20 08:15:00 +02:00
Erik Eckstein
5dc71aa0a5 AST/SIL: support source location in diagnostics for de-serialized debug info
Diagnostics only work with `SourceLoc` which is basically a pointer into a buffer of the loaded source file.
But when debug info is de-serialized, the SIL `Location` consists of a filename+line+column.
To "convert" this to a `SourceLoc`, the file must be loaded.
This change adds `DiagnosticEngine.getLocationFromExternalSource` for this purpose.
Also, the new protocol `ProvidingSourceLocation` - to which `SourceLoc` and `Location` conform - help to generalize the helper struct `Diagnostic` and make this "conversion" happen automatically.
2025-05-14 11:43:47 +02:00
Erik Eckstein
cab62320eb Swift SIL: improvements for Location
* make `var sourceLoc` return nil if the location doesn't have a valid line number
* add `var decl`
2025-04-18 06:58:39 +02:00
Emil Pedersen
4b1ce86f48 Add Location.isInlined to SwiftCompilerSources 2024-05-23 16:04:05 -07:00
Andrew Trick
e2333cdcfc SwiftCompilerSources: diagnostics bridging. 2023-10-12 14:33:37 -07:00
Erik Eckstein
2dbd6cc56b SwiftCompilerSources: rework bridging
Introduce two modes of bridging:
* inline mode: this is basically how it worked so far. Using full C++ interop which allows bridging functions to be inlined.
* pure mode: bridging functions are not inlined but compiled in a cpp file. This allows to reduce the C++ interop requirements to a minimum. No std/llvm/swift headers are imported.

This change requires a major refactoring of bridging sources. The implementation of bridging functions go to two separate files: SILBridgingImpl.h and OptimizerBridgingImpl.h.
Depending on the mode, those files are either included in the corresponding header files (inline mode), or included in the c++ file (pure mode).

The mode can be selected with the BRIDGING_MODE cmake variable. By default it is set to the inline mode (= existing behavior). The pure mode is only selected in certain configurations to work around C++ interop issues:
* In debug builds, to workaround a problem with LLDB's `po` command (rdar://115770255).
* On windows to workaround a build problem.
2023-10-09 09:52:52 +02:00
Erik Eckstein
ee1c52bc77 Swift SIL: add some APIs 2023-05-22 15:34:26 +02:00
Erik Eckstein
7905a9ac64 Swift Bridging: remove C bridging functions for SILDebugLocation 2023-03-21 15:33:09 +01:00
Erik Eckstein
e92f27c01a Swift SIL: add some APIs to Location
* `hasValidLineNumber`
* `isAutoGenerated`
* `isDebugSteppable`
2023-02-09 06:50:05 +01:00
Erik Eckstein
d96ef3bedd Swift SIL: add some APIs to Location
* `var description`
* `func ==`
* `func hasSameSourceLocation(as:)`
2023-01-16 19:00:09 +01:00
Egor Zhdan
3dc584e948 [cxx-interop][SwiftCompilerSources] Use swift::SILDebugLocation instead of BridgedLocation
rdar://83361087
2022-09-15 11:36:29 +01:00
Erik Eckstein
32af2dd5a4 Swift SIL: an autogenerated Location needs to keep the debug scope.
Therefore, instead of creating an autogenerated location with a null scope, make an existing location `autoGenerated`.
2022-09-02 08:56:38 +02:00
Erik Eckstein
f6e6b2ecf3 Swift SIL: add the possibility to pass a custom location to Builder initializers.
And add the static property `Location.autoGeneratedLocation`
2022-08-26 18:00:11 +02:00
Erik Eckstein
3b43da9637 Swift Optimizer: improve ergonomics of Builder and PassContext
* split the PassUtils.swift file into PassContext.swift and Passes.swift
* rework `Builder` bridging allowing more insertion point variations, e.g. inserting at the end of a block.
* add Builder.create functions for more instructions
* add `PassContext.splitBlock`
* move SIL modification functions from PassContext to extensions of the relevant types (e.g. instructions).
* rename `Location.bridgedLocation` -> `Location.bridged`
2022-05-12 21:48:37 +02:00
Erik Eckstein
4beb94c2f9 Rename the libswift directory to SwiftCompilerSources 2021-12-22 09:46:25 +01:00