Commit Graph

1871 Commits

Author SHA1 Message Date
swift-ci
a89502005f Merge remote-tracking branch 'origin/master' into master-next 2019-03-08 15:42:47 -08:00
Bob Wilson
64d0e6bbc5 master-next: Update call to setSuppressAfterFatalError for Clang r355586
This function was renamed to setFatalsAsError, with an inverted sense of
the argument value.
2019-03-07 14:23:31 -08:00
Gwen Mittertreiner
8a6d28c7d0 Fix the Rest of the Windows Driver Tests 2019-03-06 14:23:49 -08:00
Devin Coughlin
b3ff2d8816 [ClangImporter] Update diagnostic to refer to "macOS" instead of "OS X" 2019-03-03 16:42:17 -08: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
Adrian Prantl
761e9a0fb2 Cache clang ASTFile information in swift::Module (NFC from the outside).
The loading of additional modules by Sema may trigger an out-of-date
PCM rebuild in the Clang module dependencies of the additional
module. A PCM rebuild causes the ModuleManager to unload previously
loaded ASTFiles. For this reason we must use the cached ASTFile
information here instead of the potentially dangling pointer to the
ASTFile that is stored in the clang::Module object.

This fixes a crash in IRGenDebugInfo when generation DIModule context
chains.

rdar://problem/47600180
2019-02-01 17:34:10 -08:00
Saleem Abdulrasool
052c89d7fc ClangImporter: make bridging header more portable
`#import` on Windows is problematic at as the default behaviour in C/C++
mode is to be an import of a type library (COM feature).  This can be
adjusted by always enabling Objective-C interop on Windows, but the
runtime is not always built with ObjC interop.

Unfortunately, always using `#include` breaks semantics on Apple where
some places rely on the include-once semantics of `#import`.

For now, control the inclusion technique to be based on whether ObjC
interop is enabled or not.
2019-01-17 13:57:08 -08:00
Argyrios Kyrtzidis
e7c55789c5 [ClangImporter] Fix issue with source order comparisons of clang source locations when using a bridging PCH
Clang importer was picking the beginning of the main FileID as include location of its modules, which is the same location that the clang PCH mechanism is using as import location.
Make sure to use a different location otherwise we'll have problems with source order comparisons of clang source locations not being deterministic.

rdar://29137319
2019-01-17 11:10:44 -08:00
Saleem Abdulrasool
e012dc76f7 ClangImporter: setup macros for WinSDK import
Windows SDK requires that the platform target is identified.
Unfortunately, `cl` does not specify the value, so we cannot actually
specify the value in the clang frontend.  Specify this in the swift
frontend as this obscures the clang invocation.
2019-01-10 16:58:37 -08:00
Slava Pestov
81c5a67489 Merge pull request #21758 from pschuh/s-1
Rename NameAliasType to TypeAliasType.
2019-01-10 15:20:41 -05:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Jordan Rose
aea1ef8175 Move API notes out of the arch-specific subdirectories in lib/swift/ (#21690)
They're all the same anyway, and no longer even need to be compiled,
just copied in as text.

And drastically simplify how we "generate" them. Instead of attaching
their build jobs to the appropriate overlays, if present, "just" have
one job to copy them all and attach it to the Darwin overlay. That's
what we do for the overlay shim headers, and it's good enough.
(Eventually we want to get out of the business of shipping them
altogether.)

This does have the same flaw as the shim headers: if you /just/ change
API notes, the corresponding overlay does not get rebuilt. You have to
touch that too. But in practice that'll happen most of the time
anyway.

Part of rdar://problem/43545560
2019-01-09 14:06:21 -08:00
Jordan Rose
647dd402d5 [ClangImporter] NS_ERROR_ENUMs can be redefined in separate modules (#20527)
It's not something that /ought/ to happen, but when modules aren't
quite set up properly (often by accident, thanks to header maps), we
can get into basically this situation by having the definition end up
in a header that's textually included into two different modules, or
into a module and a bridging header. Handle that the same way we
handle other redeclarations: have it show up in both modules.

rdar://problem/45646620
2018-11-13 10:17:16 -08:00
Bruno Cardoso Lopes
f1dfdf6365 ClangImporter: Update Swift for changes in clang (PCH + Modules issues) (#20240)
This sets the NeededByPCHOrCompilationUsesPCH language option when
emitting a brigding PCH.

rdar://problem/35056912
rdar://problem/30384801
rdar://problem/45714111

Initial patch by Adrian Prantl

(cherry picked from commit 5d5f542fe4)
(cherry picked from commit fa2a5779b1)
2018-11-12 17:55:36 -08:00
Jordan Rose
ce0ca7ef3d [ClangImporter] Clean up top-level filtering logic for redeclarations
No functionality change.
2018-10-22 16:50:04 -07:00
Jordan Rose
f96ef9af03 [ClangImporter] Account for synthesized types when filtering by module
We treat redeclarable Clang declarations as present in every module
where they're declared, except for struct/enum/union declarations
where we only count full definitions. This logic requires going from
the imported Swift declaration back to the Clang declaration,
something that's not really possible for "synthesized declarations"
today. The only top-level synthesized declarations we have right now
are the structs we make to wrap error code enums.

The 100% correct thing to do would be to account for people defining
error code enums consistently across multiple modules. In practice,
though, error code enums are used with Objective-C (the importer's
treatment of them is tied to NSError), where redefining existing types
is very unusual. Therefore, this fix just ignores redeclarations of
error code enums, whether they're definitions or not.

rdar://problem/45414271
2018-10-22 16:32:56 -07:00
Saleem Abdulrasool
b124a8f7c3 ClangImporter: inline a single use macro
Inline the macro that was used at one site.  It did not have a guard so
it could not be overridden in any case.
2018-10-15 17:55:58 -07:00
Daniel Rodríguez Troitiño
60e2205663 [stdlib] Enable lgamma for Android.
Android Bionic offers lgammaf_r and lgamma_r only if _GNU_SOURCE is
provided. It also offers lgammal_r in API levels 23 and above, but
that one will not be available until 128 bit floats are supported.

The patch modifies the importer to use _GNU_SOURCE while importing
Android headers and slighly modify a check that was avoding the
function from being created for Android.

This fixes the compilation of the tgmath test in Android.
2018-10-12 14:42:52 -07:00
Graydon Hoare
14db5d2285 [AST] Add and use NominalTypeDecl::LookupDirectFlags rather than booleans. 2018-09-21 14:34:26 -07:00
Jordan Rose
ac4a92a968 Merge pull request #19292 from jrose-apple/get-out-the-map
Minor improvements to the use of StringMap/StringSet
2018-09-14 10:52:59 -07:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Jordan Rose
71760bcc4e Replace StringMap with DenseMap when the keys don't need to be owned
StringMap always copies its strings into its own storage. A DenseMap
of StringRefs has the same caveats as any other use of StringRef, but
in the cases I've changed the string has very clear ownership that
outlives the map.

No functionality change, but should reduce memory usage and malloc
traffic a little.
2018-09-13 15:15:27 -07:00
John McCall
88ee76df5b Imported modules only import the stdlib if it exists.
Any configuration where the stdlib doesn't exist is an atypical one,
but being more permissive here lets us successfully import many kinds
of declarations even without a stdlib.  That in turn makes it possible
to write IRGen tests that need foreign types and exercise a specific
target without restricting the test to only run when building that
target.
2018-09-11 18:07:32 -04:00
Jordan Rose
37ec248823 Add ModuleDecl::ReverseFullNameIterator
Package up the logic that generates a full Clang module name, so that
(a) we don't have to deal with clang::Module in quite as many places
in the /Swift/ compiler, and (b) we can avoid the cost of a temporary
string in a few places.

The main places where this is /not/ adopted is where we don't just
want to know the parent module name, but actually the module itself.
This is mostly indexing-related queries, which use the very similar
ModuleEntity class also defined in Module.h. I didn't quite see an
obvious way to unify these, but that might be where we want to go.

No functionality change.
2018-09-06 19:53:59 -07:00
Jordan Rose
537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07:00
swift-ci
fe2b1bbd3a Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 19:29:10 -07:00
swift-ci
ae0b5a0d8f Merge pull request #18328 from CodaFi/virtual-insanity 2018-07-31 19:21:40 -07:00
Robert Widmann
61203921f5 Diagnose clobbering clang's VFS with our own
There are three modes of concern here:

1) User provides -vfsoverlay but not -Xcc -ivfsoverlay

Recommended behavior.

2) User provides -Xcc -ivfsoverlay but not -vfsoverlay

Legacy behavior.  Clang will handle setup for the VFS.

3) User provides both -vfsoverlay and -Xcc -ivfsoverlay

Unsupported.  We will ignore the clang VFS overlays and substitute our
own.  We will also pop a warning about this.
2018-07-31 15:11:52 -07:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00
Robert Widmann
0e58b7fd14 Plumbing for a Virtual File System
Adds the -vfsoverlay frontend option that enables the user to pass
VFS overlay YAML files to Swift. These files define a (potentially
many-layered) virtual mapping on which we predicate a VFS.

Switch all input-based memory buffer reads in the Frontend to the new
FileSystem-based approach.
2018-07-31 13:16:14 -07:00
Doug Gregor
792d934e3e [Clang importer] Avoid recursion through isObjC more directly.
Also address some review comments related to the name lookup requests.
2018-07-31 10:20:15 -07:00
Doug Gregor
d07fa5ab69 Switch many callers of ClassDecl::getSuperclass() to ClassDecl::getSuperclassDecl().
ClassDecl::getSuperclass() produces a complete interface type describing the
superclass of a class, including any generic arguments (for a generic type).
Most callers only need the referenced ClassDecl, which is (now) cheaper
to compute: switch those callers over to ClassDecl::getSuperclassDecl().

Fixes an existing test for SR-5993.
2018-07-31 10:14:44 -07:00
swift-ci
9711455ad8 Merge remote-tracking branch 'origin/master' into master-next 2018-07-26 14:49:10 -07:00
Jordan Rose
97b152d71e Consistently get extensions from swift/Basic/FileTypes.h (part 2)
Remove the last few literal extension strings from Strings.h in favor
of the file_types APIs, and use those APIs in a few more places.
2018-07-25 22:23:01 -07:00
Jordan Rose
75052e8a0c [ClangImporter] Update for changes in module map searching in r337430 (#18062)
Patch by Bruno Lopes

rdar://problem/42128087
2018-07-23 10:45:14 -07:00
swift-ci
817e5e80e7 Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 16:49:18 -07:00
Robert Widmann
79b38ba6f3 Merge pull request #18083 from CodaFi/system-of-a-down
Add -track-system-dependencies Flag
2018-07-19 16:29:50 -07:00
Robert Widmann
d845112695 Add -track-system-dependencies Flag
Add a flag to configure the behavior of the Clang Importer's dependency tracker with respect to system dependencies.
2018-07-19 13:03:30 -07:00
swift-ci
e2acff2bbc Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 23:08:57 -07:00
Doug Gregor
b70466dc63 [Type Checker] Add a request kind for computing 'ValueDecl::isObjC()'.
Still a WIP
2018-07-18 14:50:39 -07:00
swift-ci
0f48bbe8d6 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 15:29:08 -07:00
Mark Lacey
f94d653530 Guard for null result from ClangModuleUnit::getClangModule().
The documentation for this method states that this can return null if
the module unit represents [the] imported headers.

We have a crash report on dereferencing the result of this function
farther down, and I suspect it's hitting exactly that
case. Unfortunately we only have a back trace and no test case.

Fixes: rdar://problem/41888568
2018-07-16 13:22:49 -07:00
swift-ci
504aa0a25a Merge remote-tracking branch 'origin/master' into master-next 2018-06-13 20:29:10 -07:00
Kuba (Brecka) Mracek
6c33cfa2b2 When loading Obj-C methods via a selector and the method is an accessor, import the property as well. (#17150) 2018-06-13 20:19:14 -07:00
swift-ci
ce158d0650 Merge remote-tracking branch 'origin/master' into master-next 2018-06-06 13:29:09 -07:00
Doug Gregor
bc0445d1f7 Narrow a few LazyResolver::resolveDeclSignature() calls to what they really need.
Specifically, introduce entrypoints for "resolve overridden decl" and "is @objc". These can
be computed cheaply in many more cases.
2018-06-04 18:15:39 -07:00
Doug Gregor
1b7c4917ba [Clang importer] Fix weird indentation 2018-06-04 17:36:24 -07:00
Doug Gregor
e1ce0a9f56 [AST/ClangImporter] Eliminate layering violation with isInOverlayModuleForImportedModule.
https://github.com/apple/swift/pull/16951 introduced a layering violation between the
AST and ClangImporter libraries; break the layering violation by moving the function
isInOverlayModuleForImportedModule() to ClangModuleLoader.
2018-06-04 16:40:45 -07:00
swift-ci
7fff7b3ddf Merge remote-tracking branch 'origin/master' into master-next 2018-05-21 21:49:25 -07:00
Rintaro Ishizaki
b3453c17fe [ClangImporter] Take isCompatibilityAlias() into account in interface printing (#16625)
If the Clang declrations are *types*, canonical declaration in Swift is
imported for newest version of Swift. In interface generation, if the
declaration is versioned and it's imported as a member in either or both
version of Swift, we have to take compatibility typealias into account.

* Fixed 'ClangModuleUnit::getTopLevelDecls' to take isCompatibilityAlias() into account
* Fixed bugs in ClangImporter where member-to-member versioned types aren't properly imported.
  * Fixed 'SwiftDeclConverter::importFullName' to check equality of getEffectiveContext()
  * Fixed 'importer::addEntryToLookupTable' to check equality of getEffectiveContext()
    (moved 'ClangImporter::Implementation::forEachDistinctName' to 'NameImporter')
2018-05-22 13:38:45 +09:00