Commit Graph

6196 Commits

Author SHA1 Message Date
swift-ci
255d7372cb Merge pull request #68549 from artemcm/NoErrorOnMissingOptionalTranstiveDep
[ClangImporter] On failing a module lookup, reset Clang's DiagnosticEngine, in addition to filtering out the "module not found" diagnostic
2023-09-21 15:21:02 -07:00
Artem Chikin
4e5b0548fb Update lib/ClangImporter/ClangDiagnosticConsumer.h
Co-authored-by: Allan Shortlidge <tshortli@gmail.com>
2023-09-21 12:46:03 -07:00
swift-ci
094988051f Merge remote-tracking branch 'origin/main' into rebranch 2023-09-19 08:55:18 -07:00
Egor Zhdan
6a2f10a388 [cxx-interop] Refactor: do not rely on Clang module importer being available
This makes sure that we can emit a pch from a C++ header that uses `CF_OPTIONS`.

rdar://112225263
2023-09-18 21:54:11 +01:00
Egor Zhdan
f0be52accd [cxx-interop] Add conversion to Bool for types that define operator bool()
C++ `operator bool()` is currently imported into Swift as `__convertToBool()`, which shouldn't be used by clients directly.

This adds a new protocol into the C++ stdlib overlay: `CxxConvertibleToBool`, along with an intitializer for `Swift.Bool` taking an instance of `CxxConvertibleToBool`.

rdar://115074954
2023-09-18 14:54:45 +01:00
Egor Zhdan
f7c2257f51 Revert "Revert "[cxx-interop] Import custom NS_OPTIONS correctly""
This reverts commit e1d70f06e7.
2023-09-15 13:57:59 +01:00
Artem Chikin
d840b88e14 [ClangImporter] On failing a module lookup, reset Clang's DiagnosticEngine, in addition to filtering out the "module not found" diagnostic
Even though 'ClangDiagnosticConsumer' filters out 'clang::diag::err_module_not_found' from being emitted by the Swift compiler, delegating to Swift's module-loading logic for error-handling, we must also ensure that we reset Clang's 'DiagnosticEngine''s error count. Otherwise, if we do not, final stages of IRGen will query Clang's code-gen to finalize its 'Module', which Clang will not do if its internal DiagnosticEngine contains errors. This will cause Swift's IRGen to fail, even though the only error emitted was one Swift intended to suppress.
2023-09-14 15:33:05 -07:00
swift-ci
1b4375ff33 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 17:00:25 -07:00
Alex Lorenz
90cfbd6c1f Merge pull request #68383 from hyp/eng/109417079
[interop] do not synthesize special members for C++ records with inco…
2023-09-12 16:40:38 -07:00
swift-ci
280d3986c7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 08:39:38 -07:00
zoecarver
e1d70f06e7 Revert "[cxx-interop] Import custom NS_OPTIONS correctly"
This reverts commit 46f86f0870.
2023-09-11 11:46:43 -07:00
Alex Lorenz
786c78a895 [interop] do not synthesize special members for C++ records with incomplete fields
The incomplete fields will trigger different assertions when clang is sythensizing constructors/destructors

rdar://109417079
2023-09-11 11:01:51 -07:00
Ben Barham
9bbae2b63c Merge pull request #68077 from bnbarham/add-separate-incremental-option
[rebranch] Use enableIncrementalProcessing again
2023-09-07 17:55:09 -07:00
swift-ci
0407c3d3b2 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 13:34:53 -07:00
Allan Shortlidge
0dd8f4c492 AST: Introduce abstraction for extension/type decl inheritance clauses.
Wrap the `InheritedEntry` array available on both `ExtensionDecl` and
`TypeDecl` in a new `InheritedTypes` class. This class will provide shared
conveniences for working with inherited type clauses. NFC.
2023-09-06 10:41:57 -07:00
Sophia Poirier
86d368f364 Merge remote-tracking branch 'upstream/main' into fix-rebranch-automerger 2023-08-31 14:10:52 -07:00
Doug Gregor
235764beb3 Merge pull request #68213 from DougGregor/custom-ref-count-ops-compiled-pch 2023-08-31 12:49:09 -07:00
swift-ci
88ee4d5355 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-31 09:24:20 -07:00
Egor Zhdan
d4d0478a9b Merge pull request #68217 from apple/egorzhdan/nsnotification
[cxx-interop] Look up `NSNotificationName` in C++ language mode properly
2023-08-31 17:12:47 +01: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
Doug Gregor
8b0b1bfb72 [Clang importer] Fix lookup of custom ref-counting ops in bridging headers
Lookup for custom reference counting operators into a precompiled bridging
header was causing a crash because there is no "underlying module" in which
to perform the lookup. Handle the lookup at the level of the main Swift
module for such cases, filtering out declarations not coming from Clang.

Fixes rdar://114495840.
2023-08-30 09:53:46 -07:00
swift-ci
632da182bd Merge remote-tracking branch 'origin/main' into rebranch 2023-08-30 08:36:11 -07:00
Egor Zhdan
9b7dbf2599 [cxx-interop] Introduce APINotes file for C++ stdlib
This adds an `std.apinotes` file that is installed into `lib/swift/apinotes` along with existing Darwin apinotes. This new file is installed on all platforms. It replaces a few special cases in the compiler for `cmath` and `cstring` functions.

This does not require the upcoming APINotes support for namespaces, however, this does require https://github.com/apple/llvm-project/pull/7309.

rdar://107572302
2023-08-29 23:34:36 +01:00
Ben Barham
cea351352e [rebranch] Use enableIncrementalProcessing again
The `incremental-extensions` is used for incremental parsing in the REPL
(which also changes how parsing runs). We only want "incremental
processing" in so far as it doesn't teardown the lexer or run the end of
translation unit action. This was joined into `incremental-extensions`,
but is now split apart again.

Resolves rdar://113406310.
2023-08-28 09:20:32 -07:00
swift-ci
ba5dbf8cd0 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-21 09:53:51 -07:00
Egor Zhdan
46f86f0870 [cxx-interop] Import custom NS_OPTIONS correctly
This changes the heuristic that we use to detect `CF_OPTIONS`/`NS_OPTIONS` instantiations in C++ language mode.

Since libraries sometimes declare custom option types that break the assumptions about the names of such types, this lifts the requirements on the type name.

rdar://113524090
rdar://113279214
2023-08-18 15:41:50 +01:00
swift-ci
0a607cead8 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-14 13:16:19 -07:00
Egor Zhdan
41e4a50126 Merge pull request #67873 from apple/egorzhdan/pthread_mutexattr_t
[cxx-interop] Make sure to create empty initializers for C++ structs
2023-08-14 21:09:14 +01:00
Egor Zhdan
4eb9c3be37 [cxx-interop] Make sure to create empty initializers for C++ structs
The existing synthesis mechanism had a bug: `cxxRecordDecl->hasDefaultConstructor()` returns true for C++ types with an implicit default constructor, for instance, `pthread_mutexattr_t`.

rdar://113708880
2023-08-14 17:46:57 +01:00
swift-ci
525350af1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 22:14:25 -07:00
Ben Barham
89ad4904ce [rebranch] Re-apply [Dependency Scanning] Add Clang modules from scan-deps queries to the set of
This reverts commit cf7cd9ef16.
2023-08-10 21:41:10 -07:00
swift-ci
fbfeb4fbfc Merge pull request #67750 from artemcm/SeparateClangScannerCachePath
[Dependency Scanning] Separate module output path from Clang scanner's module cache
2023-08-10 16:41:15 -07:00
swift-ci
7d6771cf8e Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 15:37:51 -07:00
Evan Wilde
cf7cd9ef16 Revert "[Dependency Scanning] Add Clang modules from scan-deps queries to the set of"
This reverts commit 0c6f212cd5.

Commit doesn't build. Reverting until it does.
2023-08-10 14:52:06 -07:00
Egor Zhdan
3723ff1401 [cxx-interop] Add UnsafeCxxMutableRandomAccessIterator protocol
This will be used to provide a safe overload of `std::vector::erase` in Swift.

`std::vector::erase` is not currently imported into Swift because it returns a C++ iterator.

rdar://113704853
2023-08-10 19:58:51 +01:00
Artem Chikin
6ef79c4ba0 [Dependency Scanning] Specify Explicit Module output path to the scanner explicitly
Instead of the code querying the compiler's built-in Clang instance, refactor the
dependency scanner to explicitly keep track of module output path. It is still
set according to '-module-cache-path' as it has been prior to this change, but
now the scanner can use a different module cache for scanning PCMs, as specified
with '-clang-scanner-module-cache-path', without affecting module output path.

Resolves rdar://113222853
2023-08-10 11:11:05 -07:00
Artem Chikin
8501f99cb2 [Dependency Scanning] Add option to specify a separate Clang Dependency scanner module cache.
Clang dependency scanning produces scanner PCMs which we may want to live in a
different filesystem location than the main build module cache.

Resolves rdar://113222853
2023-08-10 11:10:18 -07:00
swift-ci
7f8d1226e8 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 10:14:29 -07:00
Artem Chikin
f905b28a24 Merge pull request #67577 from artemcm/ConfigureClangScanDepsWithAlreadySeen
[Dependency Scanning] Add Clang modules from scan-deps queries to theset of "already seen" modules, to pass down to subsequent queries.
2023-08-10 10:09:55 -07:00
swift-ci
b87613bace Merge remote-tracking branch 'origin/main' into rebranch 2023-08-10 04:34:00 -07:00
Slava Pestov
50afb006ee ClangImporter: Remove unnecessary setGenericSignature() call 2023-08-09 17:42:58 -04:00
Slava Pestov
7f9a71cd15 AST: Rename ASTContext::getConformance() to getNormalConformance() 2023-08-09 17:42:25 -04:00
Artem Chikin
0c6f212cd5 [Dependency Scanning] Add Clang modules from scan-deps queries to the set of
"already seen" modules, to pass down to subsequent queries.
2023-08-09 09:16:46 -07:00
swift-ci
c4cad12873 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 06:14:01 -07:00
Egor Zhdan
aecc10e90b Merge pull request #67775 from apple/egorzhdan/clang-stmt-iterator
[cxx-interop] Fix SwiftCompilerSources hosttools build
2023-08-08 14:11:15 +01:00
Egor Zhdan
c621d13711 [cxx-interop] Fix SwiftCompilerSources hosttools build
This fixes a compiler error when building SwiftCompilerSources in hosttools mode with a recent Xcode.

```
<unknown>:0: error: calling a private constructor of class 'clang::StmtIterator'
swift/llvm-project/clang/include/clang/AST/StmtIterator.h:137:3: note: declared private here
  StmtIterator(const StmtIteratorBase &RHS)
  ^
```

rdar://113514872
2023-08-07 20:11:29 +01:00
swift-ci
01bb951b0e Merge remote-tracking branch 'origin/main' into rebranch 2023-08-07 11:33:36 -07:00
Egor Zhdan
4acf9c8cf4 [cxx-interop] Add CxxVector protocol
This makes it possible to initialize `std::vector` from a Swift Sequence. This also conforms C++ vectors to `ExpressibleByArrayLiteral`, making it possible, for instance, to pass a Swift array to a C++ function that takes a vector of strings as a parameter.

rdar://104826995
2023-08-07 17:12:12 +01:00
swift-ci
ae4b70bf28 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-04 18:59:37 -07:00
Slava Pestov
6ae2a1deee Merge pull request #67739 from slavapestov/var-decl-type-in-context
AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
2023-08-04 21:44:22 -04:00