Commit Graph

1745 Commits

Author SHA1 Message Date
Anthony Latsis
e7b2bc0d08 Basic: Adjust condition for include after macro removal in upstream LLVM
`HAVE_SYS_RESOURCE_H` was removed in
https://github.com/llvm/llvm-project/pull/123288, so this header is no
longer included at this particular location on rebranch, which breaks
the Linux build, where it is not transitively included either.

Use the same condition as in the use site
(`getChildrenMaxResidentSetSize`) instead.

Also, don't wrap `HAVE_GETRUSAGE` in `defined()` in case it does get
defined to 0.
2025-05-28 23:02:15 +01:00
Doug Gregor
32267f4971 Finish comment 2025-05-22 12:15:53 +01:00
Doug Gregor
414adb55ca Add optional language features to the supported features output
Optional language features don't have a specific "-enable-*" flag, because
they're rare and don't fit the same upcoming/experimental distinction. Add
a flag_name field to provide the flag name as well.
2025-05-22 11:07:13 +01:00
Doug Gregor
7f2649ff33 Add the set of diagnostic categories to each migratable feature
The name of a migratable feature might differ from the names of the
diagnostic groups containing the diagnostics that are used to drive
migration for that feature. Provide the set of diagnostic categories
that are associated with each migratable feature as part of the
supported features list.
2025-05-22 11:07:13 +01:00
Doug Gregor
abad2fae0f Make the optional feature StrictMemorySafety migratable
This feature is essentially self-migrating, but fit it into the
migration flow by marking it as migratable, adding
`-strict-memory-safety:migrate`, and introducing a test.
2025-05-22 11:07:13 +01:00
Hamish Knight
be8604959e [Basic] Switch ASSERT and friends to _abortWithMessage
Ensure the message gets printed to the pretty stack trace, allowing
it to be picked up by CrashReporter.
2025-05-19 20:55:01 +01:00
Hamish Knight
a6e94ab0bd [Basic] Fallback to dumping to stderr when backtracing is disabled
Make sure we still output the error message when pretty backtracing
is disabled.
2025-05-19 20:55:01 +01:00
Hamish Knight
d672f750e7 [Basic] Rename abortWithPrettyStackTraceMessage to ABORT
Turn it into a wrapping macro that includes the file location, and
move into `Assertions.h`.
2025-05-19 20:55:01 +01:00
Hamish Knight
92641253f7 [Basic] NFC: Remove ASSERT_help from header
It's not clear this is a useful utility to expose since it will only
print the message once.
2025-05-19 20:55:01 +01:00
Hamish Knight
d46aec9f00 [Basic] Handle multiline strings in abortWithPrettyStackTraceMessage
Improve the formatting by indenting to match the rest of the
pretty stack trace.
2025-05-19 20:55:01 +01:00
Rintaro Ishizaki
a0aad5c0b0 Merge pull request #81517 from rintaro/macros-wait-rdar150474701
[Macros] Mitigate plugin process 'wait' failure
2025-05-15 11:06:18 -07:00
Rintaro Ishizaki
05948bcb93 [Macros] 'close' unnecessary file descriptors in plugin process
Close all the pipe file descriptors in the child process after duping
them to the standard I/O. This is not necessary but it's a good thing to
do anyway.
2025-05-14 12:54:26 -07:00
Hamish Knight
691b8c874c [Basic] Upgrade assert in findBufferContainingLocInternal
Almost all clients would crash for an invalid location, let's
always assert.
2025-05-14 11:15:42 +01:00
Pavel Yaskevich
085078dd8a [Feature] Rename Feature APIs from adoption to migration 2025-04-28 11:52:46 -07:00
Pavel Yaskevich
2a479acf9e [Feature] NFC: Rename ADOPTABLE_ with MIGRATABLE_ to match the proposal 2025-04-28 10:42:22 -07:00
Pavel Yaskevich
92184584eb Merge pull request #80981 from xedin/supported-features-enabled-in-tweak
[Frontend] SupportedFeatures: print "enabled_in" as a string
2025-04-23 00:18:10 -07:00
Pavel Yaskevich
4909b9baed [Frontend] SupportedFeatures: print "enabled_in" as a string
This is future-proofing the version part of the upcoming
feature. There currently no features that require that
but it's possible that they'd be added in the future.
2025-04-22 00:09:28 -07:00
3405691582
d54e67cae1 Use LLVM-default spellings for amd64 on OpenBSD.
OpenBSD spells the common 64-bit x86 architecture as amd64, while LLVM
defaults it to x86_64. A while back we tried to stick with the amd64
spelling, but this was difficult to make the change properly and
consistently. A while back we decided to just stick with LLVM spellings,
but there are a few minor cases missing.

This change is necessary for properly finding swiftrt.o.
2025-04-18 15:57:02 -04:00
Hamish Knight
3c302349ee Merge pull request #80853 from hamishknight/macro-async-warning 2025-04-18 16:22:28 +01:00
Pavel Yaskevich
18703d64d6 [Frontend] Rework -emit-supported-features mode into -emit-supported-arguments
The "featues" part was never actually implemented and Swift Driver
is replying on information about arguments, so instead of removing
this mode, let's scope it down to "arguments" to be deprecated in
the future.
2025-04-17 12:33:23 -07:00
Pavel Yaskevich
55bd906906 [Frontend] Add -print-supported-features option
This is a replacement for `-emit-supported-features` that prints
all of the upcoming/experimental features supported by the compiler
with some additional meta information in JSON format to stdout.
2025-04-16 16:34:47 -07:00
Hamish Knight
14bd41159e NFC: Abstract away the use of '7' to represent the next language mode
Introduce `Version::getFutureMajorLanguageVersion` to make it easier
to find clients that will need to be updated once we have a new
language mode.
2025-04-16 19:22:52 +01:00
Steven Wu
56778b7209 [BlockList] Fix a crash if block is empty
Check if the root node is a mapping node before iterating. This fixes a
crash when the YAML file is not the expected format.
2025-04-10 12:46:09 -07:00
Michael Gottesman
77a86a525b Merge pull request #79891 from gottesmm/pr-9df6772bb44656cbd85cad72ee5c3637caab8956
Make Feature a struct enum so we can put methods on it.
2025-04-07 10:32:23 -07:00
Hamish Knight
8834f6c4c7 Merge pull request #80496 from hamishknight/message-in-a-crash-log
[Mangler] Include verification errors in the crash log
2025-04-07 17:03:18 +01:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Doug Gregor
e49afc8797 Merge pull request #80389 from 3405691582/nobtcfi
Add a build flavor to opt-out of BTCFI on OpenBSD.
2025-04-03 13:29:04 -07:00
Hamish Knight
abf8a81a18 [Mangler] Use abortWithPrettyStackTraceMessage for verification errors
Make sure we include the verification error in the crash log.
2025-04-03 16:03:55 +01:00
Hamish Knight
54023f85e7 [Basic] Introduce abortWithPrettyStackTraceMessage
Introduce a convenience for aborting while printing a given message
to a frame of the pretty stack trace. Use this in the existing places
where we're currently doing this.
2025-04-03 15:59:48 +01:00
3405691582
a341ce5570 Add a build flavor to opt-out of BTCFI on OpenBSD.
To work-around #80059, we need to stop return address signing and
opt-out of BTCFI enforcement via enabling a platform linker option.

We don't want to completely undo the BTCFI work in the rare case that
we later figure out how to properly address the above issue, or allow
users who might want to benefit from BTCFI enforcement and won't use
Concurrency. To do this, condition the existing BTCFI flag enforcement
into a configuration option that defaults to off for now.

Because the new swift-driver needs to "know" whether the frontend is
configured to opt-out or not, and since the new driver communicates with
the frontend via the target info JSON to begin with, we add a field
that emits the build flavor to signal the right behavior.
2025-03-29 10:47:23 -04:00
Hamish Knight
b63ed2bf01 Merge pull request #80339 from hamishknight/macroscope
[ASTScope] Re-enable `checkSourceRangeBeforeAddingChild`
2025-03-29 00:36:50 +00:00
Hamish Knight
a0c3632f95 [Basic] Bail in isBeforeInSource if root source files mismatch
This case is currently being hit for code completion, possibly due
to an invalid ASTScope node range. Let's bail in non-asserts builds
rather than crashing when attempting to access the generated source
info.

rdar://134522702
2025-03-27 21:22:02 +00:00
Hamish Knight
801079bd94 [Basic] Use start loc for original source range in isBeforeInSource
Given we're working with CharSourceRanges, the end location is past
the end of the actual range, so when checking if e.g a function body
macro is contained within the function decl, we fail since the end
location is past the closing `}`. Check the start location instead,
which is part of the range.
2025-03-27 11:31:24 +00:00
Michael Gottesman
13c9e9c994 [gardening] Remove this-> from LangOpts that was added by mistake. 2025-03-17 15:37:15 -07:00
Tony Allevato
68876a6d4a Merge pull request #76636 from allevato/rich-identifiers
Support raw identifiers (backtick-delimited identifiers containing non-identifier characters).
2025-03-12 14:56:14 -04:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
Gabor Horvath
22e2276c4f [cxx-interop] Do not require the LifetimeDependence feature in _SwiftifyImport
We use experimental features to let people know that the construct is
subject to change and users should not rely on this unless they are
willing to rewrite the uses of this feature later. However, in compiler
generated code everything should be fair game, we will update the
compiler when these features change. This is a requirement to be able to
turn safe wrapper generation on by default.
2025-03-11 17:38:53 +00:00
Anthony Latsis
ae70d384e0 [NFC] Basic: Restrict adoption mode to upcoming and experimental features 2025-03-11 01:15:33 +00:00
Anthony Latsis
b3df0dcd08 [NFC] Basic: Do not return true in LangOptions::hasFeature if adoption mode
This check is used to enact features, whereas adoption mode should not
change behavior.
2025-03-11 01:14:39 +00:00
Anthony Latsis
b102c986aa [NFC] Basic: Use scoped enum for feature states
To prevent unexpected implicit conversions to integral types.
2025-03-11 01:14:39 +00:00
Anthony Latsis
6a3903bb53 Revert "Revert "Introduce adoption mode for Swift features""
This reverts commit 393c59c078.
2025-03-05 15:21:01 +00:00
Rintaro Ishizaki
393c59c078 Revert "Introduce adoption mode for Swift features" 2025-03-04 19:13:05 -08:00
Anthony Latsis
2771f36ced LangOptions: Refactor feature state and API to account for adoption mode 2025-03-04 13:43:28 +00:00
Anthony Latsis
8dab67bcee Basic: Adjust feature macros for adoption mode 2025-03-04 13:43:28 +00:00
Anthony Latsis
0210872916 [NFC] Basic: Extract feature API definitions into their own file 2025-02-27 20:45:07 +00:00
Doug Gregor
b7b5a2a19d [SE-0458] Enable unsafe expressions / attributes / for..in effects by default
With the acceptance of SE-0458, allow the use of unsafe expressions, the
@safe and @unsafe attributes, and the `unsafe` effect on the for..in loop
in all Swift code.

Introduce the `-strict-memory-safety` flag detailed in the proposal to
enable strict memory safety checking. This enables a new class of
feature, an optional feature (that is *not* upcoming or experimental),
and which can be detected via `hasFeature(StrictMemorySafety)`.
2025-02-26 12:30:07 -08:00
Pavel Yaskevich
bc2a640ce7 [Basic] Limit version::getCompilerversion to major + minor only
At the moment the only user of this method is `-interface-compiler-version`
and it's checked against major + minor only, so this is not going
to affect functionality.

In the future we should switch from `llvm::VersionTuple` to `swift::Version`
because swift tags have five components.

Resolves: rdar://140006577
2025-02-17 08:20:06 -08:00
Saleem Abdulrasool
45032fd4b3 Merge pull request #79223 from compnerd/sizeof-void-star
Basic: query the target pointer width from clang
2025-02-10 16:08:44 -08:00
Saleem Abdulrasool
a04c75a43a Basic: query the target pointer width from clang
Use the `clang::TargetInfo` to query the target pointer size for the
given triple. This is meant to enable us to properly determine
`CMAKE_SIZEOF_VOID_P`.
2025-02-10 09:20:02 -08:00
Qiongsi Wu
f24a1325d3 Ignore -ffile-compilation-dir when processing swift modules. 2025-02-06 15:13:42 -08:00