Commit Graph

53 Commits

Author SHA1 Message Date
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
Slava Pestov
30dae65226 AST: Add DeclBaseName::Kind::Constructor
Not used yet.
2018-03-16 00:25:54 -07:00
swift-ci
e506bb3134 Merge remote-tracking branch 'origin/master' into master-next 2017-08-01 08:08:52 -07:00
Alex Hoppen
2eb36e41f5 Introduce special name for destructors
This name is not used yet
2017-07-28 10:46:50 +02:00
Jordan Rose
beb4305986 [ClangImporter] Simplify the macro logic from the previous commit.
No functionality change.
2017-07-26 15:42:31 -07:00
Jordan Rose
5d053d95a4 [ClangImporter] Restore proper macro shadowing rules.
Last follow-up to c3d6be64ab. Already covered by
test/ClangImporter/macros_redef.swift.

rdar://problem/32199805
2017-07-26 15:42:31 -07:00
swift-ci
b4016dde18 Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 06:08:49 -07:00
Kosuke Ogawa
9ab7a450d1 [Gardening] Fix typo: idenifier -> identifier 2017-07-25 18:09:56 +09:00
swift-ci
e0782d0448 Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 13:29:16 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Jordan Rose
c3d6be64ab WIP Update to use clang::ModuleMacro instead of clang::MacroInfo.
Untested and still missing a few pieces.
2017-06-23 16:04:24 -07:00
Francis Ricci
5cdfcbba3e Remove unused ID encoding functions from SwiftLookupTable 2017-05-31 14:18:45 -04:00
Jordan Rose
94d9d6a33a [ClangImporter] Shrink EffectiveClangContext on 32-bit platforms.
No intended functionality change.
2017-05-13 14:53:18 -07:00
Jordan Rose
9a9d139320 [ClangImporter] Import Swift 3 and 4 names for enumerators. (#9523)
Also lays the groundwork for rdar://problem/16513537, which is about
being able to find an enum by its original top-level name so that we
can show a diagnostic for that. I'll file a public bug about that
later.

rdar://problem/31893305
2017-05-12 14:51:40 -07:00
jmgc
2615a3662d Correction of assert in case a 32bits architecture is used. 2017-01-16 16:44:27 +01:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Ilseman
01ee1eee61 [Clang Importer] Shave space off EffectiveClangContext/ImportedName
Shave off a pointer from the EffectiveClangContext, by re-arranging
some of its data. Down to 2 pointers from 3.

Inside of ImportName, factor out the does-it-have-a-value from
multiple stored Optionals so as to shave off a couple of
pointers. Present the same programming interface as before. Down to 8
pointers in size from 10, and still much further to go.
2016-12-12 13:22:36 -08:00
Michael Ilseman
15f5367409 [Clang Importer] Simplify and move more lookup table APIs 2016-12-01 18:18:12 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Michael Ilseman
0bf4ce8a87 [Clang Importer] Refactor lookup table code
Move SwiftLookupTableReader/Writer into .cpp file, as they are
irrelevant to the rest of the importer, and this allows us to make
them more ImportName aware in the future. Pull more code out of
ClangImporter.cpp.

NFC.
2016-10-01 16:34:43 -07:00
Jordan Rose
490aefafcd [ClangImporter] Preserve macros from all implicit submodules. (#3983)
...instead of picking one definition arbitrarily. This comes from the
new "lookup table" design in Swift 3---we no longer just look for any
"visible" (imported) macro definition, but instead need to know them
up front. This works fine when there's only one definition per module,
but for modules like 'OpenGL' on macOS, with mutually-exclusive
submodules 'GL' and 'GL3', the compiler was arbitrarily deciding that
all of the macros the submodules had in common belonged to 'GL'.

The new model tries to decide if it's possible for two modules to be
imported separately, and keeps both macro entries if possible, only
deduplicating equivalent definitions at the last minute (when
importing into Swift). This /still/ doesn't perfectly match the
behavior you'd get in C, where a submodule and its parent module could
theoretically have conflicting definitions and you'd be fine as long
as you only imported one of them, but hopefully (a) it's close enough,
and (b) nobody is doing that. (The Swift compiler will prefer the
definition in the parent module even if the submodule is the only one
imported.)

rdar://problem/26731529
2016-08-04 08:39:45 -07:00
Doug Gregor
55a3f5398c [Clang importer] Import Swift 2 "stubs" to improve errors in "Swift 2" code.
When attempting to compile Swift 2 code (or any Swift code using the
Swift 2 names) in Swift 3, the compiler diagnostics are often entirely
useless because the names have changed radically enough that one
generally gets "no member named 'foo'" errors rather than a helpful
"'foo' was renamed to 'bar'" error. This makes for a very poor user
experience when (e.g.) trying to move Swift 2 code forward to Swift 3.

To improve the experience, when the Swift 2 and Swift 3 names of an
API differ, the Clang importer will produce a "stub" declaration that
matches the Swift 2 API. That stub will be marked with a synthesized
attribute

  @available(unavailable, renamed: "the-swift-3-name")

that enables better diagnostics (e.g., "'foo' is unavailable: renamed
to 'bar') along with Fix-Its (courtesy of @jrose-apple's recent work)
that fix the Swift 2 code to compile in Swift 3.

This change addresses much of rdar://problem/25309323 (concerning QoI
of Swift 2 code compiled with a Swift 3 compiler), but some cleanup
remains.
2016-05-06 21:12:20 -07:00
Michael Ilseman
faceb558d7 [Clang Importer] Initial support for swift_newtype(struct)
This introduces support for swift_newtype(struct) attribute (also
known as swift_wrapper). The Clang importer will create a brand new
struct corresponding to the annotated typedefs, which has a backing
raw value. Globals of that type are imported as static members on the
struct.

Additionally, this interacts seamlessly with prior import-as-member
work, meaning that the newly created type can be imported onto. Tests
included.
2016-04-21 16:40:10 -07:00
Michael Ilseman
2b5b839686 [Import as member] Turn on CoreGraphics.
Introduces CoreGraphics.apinotes, in which we enable the
import-as-member inference system. Additionally, include some explicit
SwiftNames, for when inference doesn't produce the right result, and
to aid compatibility with the overlays.

Refactors many of the trivial overlays out, shrinking the
CoreGraphics.swift overlay by over half. Updates in-tree test
cases. The names we currently have will be highly in flux for a while,
and are likely to change frequently over the near term.

There are a few remaining known bugs that are worked around by
apinotes entries.
2016-04-06 11:03:18 -07:00
Doug Gregor
138bbe2167 [Clang importer] Delay resolution of import-as-member declarations when needed.
It's possible for swift_name to make a global declaration into a
member of another entity that has not been seen yet. In such cases,
delay resolution until the end of the translation unit (module). Fixes
the rest of rdar://problem/25502497.
2016-04-05 00:03:36 -07:00
Michael Ilseman
d7581d1b36 Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member 2016-03-23 13:05:57 -07:00
Michael Ilseman
d576abf1a7 [Clang importer] Allow ObjC categories as decl contexts.
ObjC containers and categories are valid effective Clang decl
contexts, but do not have a canonical declaration. Permit them
alongside translation units.
2016-03-11 10:35:35 -08:00
Doug Gregor
0e40128d1a [Clang importer] Use Clang swift_bridge attribute for bridging.
When an Objective-C class type is annotated with the swift_bridge
value type, bridge it to the named type. Use API notes on Foundation
rather than special cases.

For Objective-C classes where bridging was baked into the Clang
importer (NSString, NSArray, NSDictionary, NSSet), add API notes to
put the appropriate swift_bridge attribute on these Objective-C
classes.

Note: requires Clang update.
2016-03-10 23:10:28 -08:00
Michael Ilseman
03a16e0e07 [Import as member] Properly handled CF and attributed types.
Read through attributed types when determing effective Clang decl
context, use lower level CF type information, and const-ify
EffectiveClangContext.

This puts an end to known disappearing imported members.
2016-03-10 18:53:51 -08:00
Michael Ilseman
620207b693 [Import as member] Use canonical decls for EffectiveClangContext 2016-03-09 17:03:53 -08:00
Doug Gregor
d88f546f0a [Clang importer / Interface printing] Print extensions in the appropriate submodule.
When printing the interface for a (sub)module, make sure that we only
print those extensions that were created to hold that submodule's
globals that were imported as members.
2016-03-04 17:21:13 -08:00
Doug Gregor
f7ee0349ea [Clang importer] (De-)serialize globals-as-members for Swift name lookup tables.
Round-trip the globals-as-members table used by the Swift name lookup
tables. At present, there are no clients of this information except
the dumper.
2016-03-01 18:13:35 -08:00
Doug Gregor
8649fa440a [Clang importer] Record globals imported as members in Swift name lookup tables.
Whenever we add an entry that corresponds to a global Clang entity
that will be imported as a member, where that member structure isn't
inherently encoded in Clang, separately record it as being a member of
the context in a separate table. Verify that we're getting the entries
we expect in this table.
2016-03-01 17:01:30 -08:00
Doug Gregor
6c2bb84fea [Clang importer] Introduce StoredContext typedef; NFC 2016-03-01 16:09:57 -08:00
Doug Gregor
7265328e07 [Clang importer] Generalize name lookup tables for globals-as-members.
A swift_name attribute on a global declaration can specify a dotted
name (e.g., SomeStruct.member) to map that global into a member of the
(Swift-)named type. Handle this mapping in DeclName parsing, plumb it
through importFullName, and cope with it in the Swift name lookup
tables (tested via the dump) and importing into a Swift DeclContext
(as-yet-untested). Part of SE-0033.
2016-03-01 15:33:20 -08:00
Doug Gregor
940a65a994 [Clang importer] Make the "effective context" a core part of ImportedName.
Previously, the "effective context" parameter to importFullName was
used only during the construction of Swift name lookup tables, so we
can associate each declaration with a context. Expand the role of
"effective context" so it is always a part of ImportedName and is also
used by importDecl when actually importing the enum declaration.

This is partially a cleanup, and partially staging for SE-0033, which
will require this functionality more broadly.
2016-02-29 15:32:34 -08:00
Doug Gregor
78cb038cbb [Omit needless words] Don't prefix-strip when dumping APIs.
We're going to delay NS prefix stripping for a bit. Change the API
dump script accordingly, and bump the Swift name lookup table format
version number so this doesn't break everyone who has already run
swift-api-dump.py.
2016-02-22 14:24:20 -08:00
Doug Gregor
fa36a90d69 [Clang importer] Bump version number of Swift name lookup tables 2016-02-08 11:11:35 -08:00
Doug Gregor
03c1ac4593 [Omit needless words] Lowercase enum cases/option set members consistently. 2016-02-08 10:32:19 -08:00
Jordan Rose
69fbc5b77b Get some files off of PointerLikeTypeTraitsFwdDecl.h 2016-02-06 11:22:28 -08:00
Michael Gottesman
3556db7484 Add in explicit specializations for forward declared pointers that we use. All of the explicit specializations are in the new header "PointerLikeTypeTraitsFwdDecl.h" 2016-02-06 11:22:28 -08:00
Doug Gregor
319e2a7462 [Clang importer] Strip "NS" prefix from macro names, too 2016-02-03 21:03:09 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
f9f9d2db98 Clang importer: add a list of Objective-C categories/extensions to the Swift name lookup table.
We need to be able to query this when enumerating “all declarations”, which is coming soon.
2015-12-21 16:01:21 -08:00
Doug Gregor
f7fd6d4f59 Clang importer: use lookup table version number in the module file extension hash.
We were verifying the Swift full version information from the module
file extension metadata for the Swift name lookup tables, but not
actually putting it in the hash, which meant that having an older
module cache around would cause spurious failures when Swift name
lookup tables were enabled. Instead, use just the major/minor version
numbers of the lookup tables. When the lookup table format or contents
of the lookup table change, we'll bump the version number.
2015-12-17 10:27:13 -08:00
Doug Gregor
69940d166c Clang importer: use Swift name lookup tables for all dynamic lookup searches. 2015-12-15 14:09:44 -08:00
Doug Gregor
d421a4fc0a Clang importer: use Swift name lookup tables for AnyObject member lookup.
When we're building Swift name lookup tables, use them for AnyObject
member lookup rather than falling back to the Objective-C selector
table.
2015-12-14 22:05:04 -08:00
Doug Gregor
f8a76d10c0 Clang importer: add macros to the Swift name lookup tables.
Refactor the storage within the name lookup tables to handle
declarations and macros together. Start populating the tables with
macro information.
2015-12-08 22:56:28 -08:00
Doug Gregor
86701de88a Clang importer: (de-)serialize Swift name lookup tables via module file extensions.
The recently-introduced module file extensions functionality in Clang
allows us to piggy-back the Swift name lookup tables in Clang's module
files. When the Swift name lookup tables are enabled, introduce such a
module file extension, and wire it into the SwiftLookupTable.

The actual contents of the extension block are simple: a single
on-disk hash table mapping base names to "full entries", which store
the context (e.g., a class, protocol, tag, or TU) and the set of
declarations.

Allow lazy resolution of declaration IDs deserialized from the
extension block to Clang declarations, to try to minimize the set of
declarations we must deserialize. Name lookup itself is only used to
dump the Swift name lookup tables and ensure we're round-tripping
properly.
2015-12-08 17:34:04 -08:00
Doug Gregor
f40b195a73 Clang importer: simplify Swift name lookup tables a bit.
The base name -> full name mapping really isn't interesting; index
based on the base name and filter by context instead. This makes the
lookup table dumper less interesting for testing purposes
(unfortunately), but test coverage will improve greatly once we can
turn on these lookup tables.
2015-12-08 17:34:04 -08:00