Commit Graph

1905 Commits

Author SHA1 Message Date
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
Slava Pestov
b903382866 ClangImporter: Fix importEnumCaseAlias() when the original is itself an alias
This comes up when an imported error enum has duplicate cases.
The FooError.Code enum has an alias for the duplicate case, and
the wrapper type FooError defines aliases for every member of
FooError.Code.

The implementation of importEnumCaseAlias() assumed that 'original'
was an EnumElementDecl, and built AST accordingly; however if it
is a 'VarDecl', we have to build a MemberRefExpr instead.

This regression was introduced in https://github.com/apple/swift/pull/25009.

Fixes <rdar://problem/58552618>.
2020-02-06 19:47:05 -05:00
Robert Widmann
e825ca1d32 [ClangImporter] Reject *all* attempts to redeclare properties
Add an algorithm to go search the override tables *and* the existing
loaded members of a class for a redeclaration point.  The idea is that
both mirrored protocol members and categories offer a way to convince
the Clang Importer to import a property twice. We support a limited form
of this multiple-imports behavior today by allowing the redeclared
property to refine a readonly property into a readwrite property.

To maintain both the refinement behavior and to disambiguate any
remaining cases of ambiguity caused by extensions, attempt to identify
a redeclaration point if we can't identify an override point. Then,
decline to import the redeclared member if we're successful.

Note that the algorithm as presented is subject to import ordering. That
is, if a framework declares both an overlay and a clang module unit, if
the overlay is not loaded or members from the overlay are not installed
in the class by the time we see the declaration we may fail to identify
an redeclaration point.

The regression tests are for rdar://59044692, rdar://59075988, and
rdar://59125907.
2020-02-04 13:15:32 -08:00
Slava Pestov
d76a8ce920 ClangImporter: Lazily load mirrored protocol members in classes 2020-02-04 09:54:06 -05:00
Slava Pestov
7e7b6e8b27 ClangImporter: Fix up importSubscript() to not depend on import order
Once lazy loading supports mirrored protocol members, we can end up
calling importSubscript() for a setter method before we've mirrored
the getter. In this case, we call findCounterpart() with the setter,
which finds the imported getter from the ProtocolDecl itself.

Stop processing the potential subscript in this case, since when we
later mirror the protocol member, we'll go and build it again.

This should be NFC without the next change I'm working on.
2020-02-04 09:54:06 -05:00