Commit Graph

2609 Commits

Author SHA1 Message Date
zoecarver
0605ef4c6c [verifier] [cxx-interop] Remove empty return result from constructors.
Set the synthesized constructor's return result to nullptr and add an ASTVerifier check that the constructor's return statement does not contain a result.
2020-07-07 10:04:09 -07:00
Michael Forster
26358c4588 Import member operator functions as static members (#32293)
This adds support to `ClangImporter` to import C++ member function operators as static methods into Swift, which is part of SR-12748.

The left-hand-side operand, which gets passed as the `this` pointer to the C++ function is represented as an additional first parameter in the Swift method. It gets mapped back in SILGen.

Two of the tests are disabled on Windows because we can't yet call member functions correctly on Windows (SR-13129).
2020-07-03 11:06:22 +02:00
swift_jenkins
afd634985a Merge remote-tracking branch 'origin/master' into master-next 2020-07-01 21:38:26 -07:00
Doug Gregor
1867e0d6de [Clang importer] Remove the OS_object objc_runtime_visible hack.
The Clang importer has an old hack that makes OS_object and its subclasses
implicitly "objc_runtime_visible" (which maps to the "runtime" foreign
class kind in Swift). Now that the headers in the SDK all use the
appropriate annotation, remove the hack.

Fixes rdar://problem/64778416.
2020-06-30 09:31:30 -07:00
Jonas Devlieghere
66bddd6e4c [ClangImporter] Adjust for LLVM API change 2020-06-29 15:29:16 -07:00
swift_jenkins
8dadaedfd9 Merge remote-tracking branch 'origin/master' into master-next 2020-06-26 16:38:38 -07:00
zoecarver
096777eda7 [cxx-interop] Do not give the default C++ constructor's return statement a result.
The default C++ object constructor assigns the newly created object out of the function so, it should not return a value. Returning a value will trigger SILGen assertions.
2020-06-24 14:02:02 -07:00
swift_jenkins
0831f9eaf1 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 10:19:55 -07:00
Argyrios Kyrtzidis
f89a385756 [ClangImporter] Follow-up for #32214, fix assertion hit due to missing check 2020-06-15 18:28:26 -07:00
swift_jenkins
abe81545ed Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 16:39:16 -07:00
Argyrios Kyrtzidis
a3ce4621a2 Merge pull request #32214 from akyrtzi/clang-include-inherited-convenience-inits-for-members
[ClangImporter] Make sure that inherited convenience constructors are included in members of `IterableDeclContext`
2020-06-10 16:29:41 -07:00
Argyrios Kyrtzidis
915e215a3d [ClangImporter] Make sure that inherited convenience constructors are included in members of IterableDeclContext
Previously inherited constructors would be skipped from added in member list, depending on the order of request evaluator calls.
This was a regression compared to swift 5.2
2020-06-10 13:23:12 -07:00
swift_jenkins
0b350f6562 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 11:38:51 -07:00
Robert Widmann
ca728917e1 Merge pull request #32138 from AnthonyLatsis/eliminate-typeloc
Sema: Remove TypeLoc from ExplicitCastExpr (via TypeExpr)
2020-06-10 11:28:50 -07:00
Martin Boehme
fc1cf3b203 Replace clang::Decl::isHidden() with clang::Sema::isVisible().
clang::Decl::isHidden() is misleadingly named (see the associated FIXME
comment) and doesn't do what we want when
`-fmodules-local-submodule-visibility` is turned on.

This change alone isn't unfortunately enough to make Swift work with
`-fmodules-local-submodule-visibility`. For one thing, Clang's
Objective-C component  doesn't work correctly with
`-fmodules-local-submodule-visibility`:

https://bugs.llvm.org/show_bug.cgi?id=46248

However, in the meantime, we should still clean up our use of
clang::Decl::isHidden().
2020-06-09 15:17:49 +02:00
Anthony Latsis
4b4634141f Sema: Remove TypeLoc from ExplicitCast 2020-06-09 15:20:25 +03:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07: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
Karoy Lorentey
1c9b0908e6 Merge remote-tracking branch 'origin/master-next'
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:43:40 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
swift_jenkins
102ab6c4d3 Merge remote-tracking branch 'origin/master' into master-next 2020-05-22 13:40:25 -07:00
Hamish Knight
bc618a9763 [ClangImporter] Avoid calling into ObjCSelector lookup
The ClangImporter currently calls into
`ObjCSelector`'s `lookupDirect` in a couple of
places, stashing the selector in a DenseMap to try
and avoid re-entrancy problems.

However this will become a problem once
`ObjCSelector`'s `lookupDirect` is both
requestified and starts pulling in members from
the main module, so migrate the ClangImporter off
calling it.

Fortunately most of its uses only care about decls
with associated Clang nodes. For those cases, we
can use the existing member table, making sure to
populate it with any method we import.

In one case, the ClangImporter needs to check to
see if there's a deserialized Swift method with a
matching selector. Instead of calling through to
`lookupDirect`, let's just query the Swift module
loaders directly.
2020-05-21 09:19:02 -07:00
swift_jenkins
4775ae99ec Merge remote-tracking branch 'origin/master' into master-next 2020-05-13 08:18:45 -07:00
Michael Forster
e69abeba53 Classify C++ structs as loadable or address-only (#31707)
* Classify C++ structs as loadable or address-only

C++ structs are only loadable if they are trivially copyable.

Resolves SR-12472.
2020-05-13 17:16:47 +02:00
swift_jenkins
64add03f2e Merge remote-tracking branch 'origin/master' into master-next 2020-05-08 11:45:03 -07:00
Arnold Schwaighofer
e12698d7a0 Merge remote-tracking branch 'origin/master' into master-next 2020-05-08 07:22:20 -07:00
Dmitri Gribenko
2842748442 Improved a comment 2020-05-08 15:41:10 +02:00
Michael Forster
07c9fdd9e6 Synthesize memberwise initializers despite member functions
Previously unimportable member functions inhibited the synthesis of
memberwise initializers.
2020-05-08 14:26:21 +02:00
Michael Forster
d611b4c4f5 Synthesize memberwise initializers despite AccessSpecDecl
Previously the mere presence of `public:` or `private:` inhibited the
synthesis of memberwise initializers.
2020-05-07 17:44:41 +02:00
Shoaib Meenai
b59ffe0edf [ClangImporter] Adjust for LLVM changes
https://github.com/llvm/llvm-project/commit/9721fbf85b83 refactors the
enum; adjust Swift accordingly.
2020-04-29 15:28:08 -07:00
swift_jenkins
71686f9984 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 12:58:09 -07:00
Joe Groff
b4c7a7e85d Merge pull request #31224 from AnthonyLatsis/rename-getfullname-2
AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
2020-04-24 12:51:28 -07:00
swift_jenkins
53eb83d930 Merge remote-tracking branch 'origin/master' into master-next 2020-04-23 09:38:25 -07:00
Marcel Hlopko
883262771b Expose C++ static members as Swift static properties 2020-04-23 15:33:43 +02:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Michael Forster
8e0bea9911 Call the new BinaryOperator factory function
The constructor is not public any more. This fixes the master-next build.
2020-04-20 11:46:27 +02:00
swift_jenkins
274e667696 Merge remote-tracking branch 'origin/master' into master-next 2020-04-03 08:00:12 -07:00
Michael Forster
98bbb81f82 [C++] Make const member variables read-only
This imports const members of C++ structs/classes stored properties with
an inaccessible setter.

Note that in C++ there are ways to change the values of const members,
so we don't use `WriteImplKind::Immutable` storage.

Resolves: [SR-12463](https://bugs.swift.org/browse/SR-12463)
2020-04-03 13:15:33 +02:00
swift_jenkins
14a14a232b Merge remote-tracking branch 'origin/master' into master-next 2020-04-01 09:00:36 -07:00
Anthony Latsis
c63b737e92 Collapse all indirect equivalents to ValueDecl::getBaseIdentifier 2020-03-29 00:36:01 +03:00
Alex Langford
dfcd6611af Handle clang::TargetInfo::HexagonBuiltinVaList 2020-03-27 15:21:16 -07:00
swift_jenkins
33ffd1f236 Merge remote-tracking branch 'origin/master' into master-next 2020-03-19 08:21:10 -07:00
martinboehme
fa7155073d Don't import C++ class members that are protected or private (#30233)
* Don't import C++ class members that are protected or private.

We omit protected members in addition to private members because Swift
structs can't inherit from C++ classes, so there's effectively no way to
access them.

* Check access specifiers centrally in importDeclImpl().

* Fix macOS build by using <stddef.h> instead of <cstddef>.

Apparently, the macOS toolchain doesn't provide <cstddef>.

<stddef.h> is used in test/Inputs/clang-importer-sdk/usr/include/macros.h,
so I'm assuming it will be OK. (I don't unfortunately have a macOS
machine to test on.)

* Add comment explaining why we skip private and protected C++ class
members.
2020-03-19 08:20:36 -07:00
swift_jenkins
90960293fc Merge remote-tracking branch 'origin/master' into master-next 2020-03-18 03:40:17 -07:00
Martin Boehme
490021fec6 Fix: Access NamedDecl::getName() only if the name is an identifier.
Non-identifier names aren't currently an issue, but it will become one
when we add more support for C++, e.g. for C++ constructors (which I
plan to tackle soon).
2020-03-18 09:04:36 +01:00
Ben Langmuir
332729aeee Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/ClangImporter/ImportDecl.cpp
	lib/IDE/Utils.cpp
2020-03-12 16:41:32 -07:00
Adrian Prantl
41f76322d2 Adapt to upstream header file reshuffling 2020-03-12 10:23:47 -07:00
Shoaib Meenai
b6301c256c Include TargetInfo.h explicitly
https://github.com/llvm/llvm-project/commit/d7c5037e6b9f removes
implicit transitive includes of TargetInfo.h, so we must include it
explicitly where it's needed.
2020-03-11 23:36:59 -07:00
Robert Widmann
de72824b04 [Gardening] Canonicalize usages of ASTContext::Stats 2020-02-27 17:12:58 -08:00
Xi Ge
3fe4b89dbf ClangImporter: import non-canonical ObjCCategoryDecl after recent clang changes
Recent clang side change merges ObjCCategoryDecl with the same name. All re-declarations
of a category points to the first category as the canonical one. This patch keeps these
non-canonical redeclarations as separate extensions in Swift.

rdar://problem/59744309
2020-02-26 13:41:09 -08:00