Commit Graph

74 Commits

Author SHA1 Message Date
Ben Barham
f375e36cc8 [ClangImporter] Rename OMPArraySection to ArraySection 2024-07-02 16:13:49 -07:00
Ben Barham
701430f209 [ClangImporter] Add initial empty handling for UnresolvedTemplate 2024-07-02 16:13:49 -07:00
Ben Barham
a6cf31036a Add AMDGPU builtin handling 2024-07-01 14:52:51 -07:00
Ben Barham
0f52071c22 Fix up various references to renamed/moved enums
A bunch of enums were moved to enum classes and slightly renamed. Fix up
their references.
2024-04-08 08:58:58 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Pavel Yaskevich
269f30f119 [ClangImporter] Add a way to determine whether type is NSNotificationName 2024-02-06 10:51:13 -08:00
Egor Zhdan
be24236bea Revert "Revert "[cxx-interop] Look up NSNotificationName in C++ language mode properly""
This reverts commit 80448d2f1c.
2023-11-10 13:26:00 +00:00
swift-ci
812300d632 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-26 05:36:14 -07:00
Egor Zhdan
80448d2f1c Revert "[cxx-interop] Look up NSNotificationName in C++ language mode properly"
This reverts commit e956e8ac1d.
2023-09-25 20:14:00 +01:00
swift-ci
88ee4d5355 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-31 09:24:20 -07:00
Egor Zhdan
e956e8ac1d [cxx-interop] Look up NSNotificationName in C++ language mode properly
This change makes sure that `NSNotification.Name.NEVPNStatusDidChange` is imported correctly when C++ interop is enabled.

`importer::findSwiftNewtype` is called while writing Clang modules, at a point when the translation-unit scope does not exist (`clangSema.TUScope` is `nullptr`).

That prevents the Clang lookup from discovering `NSNotificationName` declaration.

Instead of trying to pass a translation-unit scope to Clang, let's use qualified name lookup which does not require a scope.

rdar://112199372
2023-08-30 19:37:44 +01:00
Evan Wilde
bc904880d0 Handle new builtin cases: AArch64SVcount, WASMRefType
Clang and LLVM added some new builtins.

LLVM added IITDescriptor::AArch64Svcount, which I set to not be
decodable since Swift can't represent those at the moment.

Also added handling for the WASM reference type builtins in the Clang
type converter.
2023-07-17 10:55:57 -07:00
Evan Wilde
8ce6ee8dd1 Updating API usages
LLVM deprecated, renamed, and removed a bunch of APIs. This patch
contains a lot of the changes needed to deal with that.

The SetVector type changed the template parameters.

APInt updated multiple names, countPopulation became popcount,
getAllOnesValue became getAllOnes, getNullValue became getZero, etc...

Clang type nullability check stopped taking a clang AST context.

The LLVM IRGen Function type stopped exposing basic block list directly,
but gained enough API surface that the translation isn't too bad.
(GenControl.cpp, LLVMMergeFunctions.cpp)

llvm::Optional had a transform function. That was being used in a couple
of places, so I've added a new implementation under STLExtras that
transforms valid optionals, otherwise it returns nullopt.
2023-07-17 10:53:42 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
zoecarver
7964918cb2 [cxx-interop] Fix sema lookup scope so we find NSNotification interface even in C++ mode. 2023-06-22 12:21:10 -07:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
zoecarver
965c7ca443 [cxx-interop] Allow anonymous enums to use the name of their base.
If an anonymous enum inherits from a typedef, it will have the typedef's name.
2022-04-18 11:05:58 -07:00
Ben Barham
4ad43d0770 [rebranch] Handle new BuiltinType::Ibm128 2021-11-13 17:04:29 +10:00
swift_jenkins
ea3059de78 Merge remote-tracking branch 'origin/main' into next 2021-03-14 00:04:10 -08:00
Dave Lee
c015c6dae0 [ClangImporter] Fix -Wcovered-switch-default warning 2021-03-10 17:11:01 -08:00
Robert Widmann
7e8cf9b2d3 [next] Adapt To RISC-V V Builtin Types
https://reviews.llvm.org/D92715 Adds new builtins for use with RISC-V
intrinsics. Match clang here and define stubs for these types.
2021-03-03 17:16:39 -08:00
Doug Gregor
e2893cf138 [Concurrency] Disable async imports for Apple APIs deprecated by ~2018.
Implements rdar://73620586.
2021-02-09 14:43:45 -08:00
Jonas Devlieghere
f7d8659f75 Adjust for upstream PowerPC builtin/instrinsic patch.
See 57d83c3a90c427ad0975803feb5b348d1ad34e29 for the changes to clang.
2020-12-16 09:51:52 -08:00
swift_jenkins
44e0f9813d Merge remote-tracking branch 'origin/main' into next 2020-12-09 13:10:54 -08:00
Doug Gregor
915afc3aa5 [Clang importer] Implement support for importing _Nullable_result.
`_Nullable_result` indicates that a parameter of a completion handler
should be imported as optional when the completion handler can fail by
throwing an error.

Implements rdar://70108088.
2020-12-08 14:49:54 -08:00
swift_jenkins
27ae700e38 Merge remote-tracking branch 'origin/main' into next 2020-12-08 13:58:46 -08:00
Doug Gregor
5b5384ab63 [Clang importer] Work around addition of _Nullable_result 2020-12-08 12:40:48 -08:00
David Zarzycki
55db26faf9 Partially unbreak the build
CfgTraits was reverted almost two weeks ago upstream but will presumably
come back. See: e025d09b216dc2239e1b502f4f277abb6fb4648a

The PPC MMA clang types were added nine days ago.

The stdlib is still crashing deep in LLVM:

```
swifterror value can only be loaded and stored from, or as a swifterror argument!
%swift.error** %2
  %7 = bitcast %swift.error** %2 to %swift.opaque*
in function $ss7DecoderP16unkeyedContainers015UnkeyedDecodingC0_pyKFTj
```

From a lldb session, the function in question:

```
define protected swiftcc void @"$ss7DecoderP16unkeyedContainers015UnkeyedDecodingC0_pyKFTj"(%Ts24UnkeyedDecodingContainerP* noalias nocapture sret %0, %swift.opaque* noalias nocapture swiftself %1, %swift.error** noalias nocapture swifterror dereferenceable(8) %2, %swift.type* %3, i8** %4) #0 {
  %6 = bitcast %Ts24UnkeyedDecodingContainerP* %0 to %swift.opaque*
  %7 = bitcast %swift.error** %2 to %swift.opaque*
  tail call swiftcc void @"$sSK5index6before5IndexQzAD_tFTj"(%swift.opaque* noalias nocapture sret %6, %swift.opaque* noalias nocapture %1, %swift.opaque* noalias nocapture swiftself %7, %swift.type* %3, i8** %4) #0
  ret void
}
```
2020-11-08 11:05:09 -05:00
Nathan Hawes
40b6798d35 Update usages of 'SwiftNewtypeAttr' for the new spelling 'SwiftNewTypeAttr' 2020-09-29 10:46:13 -07:00
Nathan Hawes
b49cd75770 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	lib/AST/ExtInfo.cpp
2020-08-31 10:54:27 -07:00
Nathan Hawes
9da1d89520 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	lib/AST/ExtInfo.cpp
2020-08-31 10:50:54 -07:00
Doug Gregor
16876fbf66 [Clang importer] Drop unused parameter from getParamOptionality().
This operation is not actually dependent on the version.
2020-08-27 17:06:42 -07:00
Nathan Hawes
4861f3174f Fix call for upstream llvm change of ClangDecl::isInLocalScope()
After f721e0582b158c60c56d2601235b6d60758f4d7a in llvm it's now called
isInLocalScopeForInstantiation() and returns false if the context is not
dependent on a template parameter, so doesn't have the desired behavior for the
single swift caller in the clang importer.

This pulls out the old logic into a new static isLocalScope() function in
ClangAdapter.cpp.
2020-07-13 14:33:09 -07:00
David Zarzycki
79df342146 Do not hardcode SVE type list 2020-06-15 06:00:20 -04:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
David Zarzycki
7525b63412 Unbreak after clang added BFloat16 builtin
In apple/llvm-project 9e7b7cbbbdb59d53136c0480f17cfe6ecef94163
(llvm/llvm-project ecd682bbf5e69e8690b7e3634258f05ae0a70448), BFloat16
was added to the clang builtins.
2020-06-06 07:27:51 -04:00
Martin Boehme
6e368aec13 Add new enum value clang::BuiltinType::IncompleteMatrixIdx to switch
statements.
2020-06-02 16:50:31 +02:00
Michael Forster
01096b6a61 Fix the master-next build 2020-04-24 06:43:53 +02:00
Nathan Lanza
a162bd5ea8 Add OMPIterator to a few switch cases
OMPIterator was recently added to upstream clang and thus a few
switch statements need to account for this addition.
2020-04-03 17:54:16 -04:00
Nathan Lanza
9f9668327c Add OMPArrayShaping to a few switch statements 2020-03-30 15:00:29 -04:00
Jordan Rose
0c785c07bd [ClangImporter] Don't use local scope decls to find a function's home (#27440)
In C, a function can be declared at local scope:

    void aFunctionInBase(void) {
      void theFunctionInQuestion(int);
    }

and then again in a different header at top-level scope:

    void theFunctionInQuestion(int);

If the first one appears first, it becomes what Clang considers the
"canonical" declaration, which (up until now) Swift has been using to
decide what module to import a function into. (Since a C function can
be redeclared arbitrarily many times, we have to pick one.) This is
important for diagnostics and anything else that might ask "where did
this Swift declaration come from". Instead of the very first
redeclaration, use the first non-local one to determine the "home"
module.

(The standard library wants a guarantee that forward declarations they
put in SwiftShims won't interfere with declarations found elsewhere. I
don't think Clang can /ever/ provide that, so if there's ever a
mismatch between the standard library's forward declarations and the
"real" declarations the standard library's might win out at the LLVM
level---say, in terms of attributes. But this at least removes a place
where that could be visible to users even when it isn't otherwise a
problem.)
2019-11-20 20:41:08 -08:00
Jordan Rose
42f72cb0d0 [ClangImporter] Compute initializer kinds up front (#27870)
Previously we only did this for factory methods, but there's no reason
why we can't do it for regular init methods too, and doing so
simplifies the signature of SwiftDeclConverter::importConstructor.

Also remove some indirection through helper functions in ClangAdapter.
These were more useful back when Swift looked directly at API notes
instead of relying on Clang turning them into attributes; now they're
just an extra hop for no reason.
2019-10-25 15:16:14 -07:00
swift-ci
2dbc10e7aa Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-25 15:43:41 -07:00
Jordan Rose
caa5be84d5 [ClangImporter] Use external_source_symbol to identify Swift decls (#27355)
...rather than replacing particular macros with an 'annotate'
attribute and then looking for that. This isn't /really/ any
particular win except maybe ever-so-slightly faster module imports
(with one fewer attribute being added to each declaration in a
mixed-source header).

This doesn't remove the SWIFT_CLASS_EXTRA, SWIFT_PROTOCOL_EXTRA, or
SWIFT_ENUM_EXTRA macros from PrintAsObjC (note that
SWIFT_EXTENSION_EXTRA was never used). They're not exactly needed
anymore, but they're not doing any harm if someone else is using them.
2019-09-25 15:30:03 -07:00
Alex Langford
986a036685 [ClangImporter][IRGen] Handle SVE builtin types
Clang r368413 introduced the SVE builtin types; update various switch
statements to handle them. This assumes that the types should not be
mapped into Swift, similar to the OpenCL types.

(cherry picked from commit 096e7ae96c)
2019-08-19 16:53:03 -07:00
Devin Coughlin
8b14600372 [ClangImporter] Refactor availability attribute importing logic. NFC.
Refactor the PlatformAvailability logic for determining
which Clang availability attributes are relevant when importing. The goal
is to separate the logic for attribute relevance for a given platform from
the logic to determine whether a deprecated attribute should be imported as
unavailable in Swift.

This also makes it possible for the "deprecated-as-unavailable" logic to
refer to the underlying Clang declaration, which is functionality that will
be used in a later commit.

This commit has no intended functional change.

Part of rdar://problem/48348822
2019-03-03 14:29:50 -08:00
Max Desiatov
37f8268ae7 Fix compatibility with upstream clang changes 2019-02-08 14:22:56 -08:00
Slava Pestov
ce521a2194 ClangImporter: Remove one last Swift 3 check 2018-10-30 16:46:08 -04:00