Commit Graph

1896 Commits

Author SHA1 Message Date
swift_jenkins
24eb03c663 Merge remote-tracking branch 'origin/master' into master-next 2020-01-08 23:17:22 -08:00
Robert Widmann
b05a6223da Merge pull request #29090 from CodaFi/globe-up
[NFC] Unblock Lazy Member Loading For Import-As-Member
2020-01-08 23:09:56 -08:00
Robert Widmann
518ab9f22f [NFC] Unblock Lazy Member Loading For Import-As-Member
Lazy member loading had an antagonistic relationship with the import-as-member facilities. The member tables were stored in a hash map that is keyed by serialized declaration context.  While this was good for importing the entire member set of a given extension, it's in the complete wrong order for lazy member loading, which wants the same data keyed by base name.

Given that it is annoying to redo the globals-as-member tables to support one use case or the other, coupled with the fact that optimizing for one use-case automatically pessimizes the other, just take a page from rdar://18696086 and store the same information twice in two separate formats each optimized for the task at hand.

Preliminary benchmarks indicate that this leads to a 5% reduction in Clang-Imported entities which will drastically speed up most apps that use Dispatch and CoreGraphics.
2020-01-08 21:25:00 -08:00
swift_jenkins
8a3c5c753b Merge remote-tracking branch 'origin/master' into master-next 2020-01-08 09:57:24 -08:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Varun Gandhi
afc6ccdeb5 Re-land parsing and printing for Clang function types.
This reverts commit e805fe486e, which reverted
the change earlier. The problem was caused due to a simultaneous change to some
code by the PR with parsing and printing for Clang function types (#28737)
and the PR which introduced Located<T> (#28643).

This commit also includes a small change to make sure the intersecting region
is fixed: the change is limited to using the fields of Located<T> in the
`tryParseClangType` lambda.
2020-01-07 15:58:32 -08:00
Saleem Abdulrasool
e805fe486e Revert "Clang function types v2: Electric Boogaloo (parsing + printing)" 2020-01-06 16:26:08 -08:00
Varun Gandhi
4a1a17d029 Merge pull request #28737 from varungandhi-apple/vg-v3-clang-types-in-swiftinterface
Clang function types v2: Electric Boogaloo (parsing + printing)
2020-01-06 15:42:30 -08:00
Varun Gandhi
96604470ae [AST] Add printing for Clang function types in the AST. 2020-01-06 13:00:04 -08:00
Varun Gandhi
afc6332289 [Sema] Parse a Clang function type from the cType argument. 2020-01-06 13:00:04 -08:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
swift_jenkins
0b31e5b803 Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 18:19:52 -08:00
Robert Widmann
a1b451470e Teach loadNamedMembers to import inherited constructors 2019-12-18 16:17:10 -08:00
swift_jenkins
eee69d9bfa Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 11:19:50 -08:00
Bruno Cardoso Lopes
6eb6bbefd2 Revert "[ClangImporter] Hash content for validation when using clang modules"
This reverts commit c362e925af.

This might be causing hard to reproduce issues. Taking it out until
we have further investigation.

rdar://problem/57964637
2019-12-17 18:25:13 -08:00
swift_jenkins
b8c178351f Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 08:59:51 -08:00
Adrian Prantl
046c849949 Add an option to disable ClangImporter imports form source.
This is primarily meant to used for testing LLDB's DWARFImporterDelegate,
however, this could become the default option for LLDB once
DWARFImporterDelegate is sufficiently mature.

<rdar://problem/57880844>
2019-12-16 13:40:21 -08:00
swift_jenkins
572384f1d2 Merge remote-tracking branch 'origin/master' into master-next 2019-12-13 15:00:26 -08:00
swift-ci
7cdb285791 Merge pull request #28776 from DougGregor/clang-diag-consumer-bridging-pch 2019-12-13 14:41:14 -08:00
Doug Gregor
e40a275e05 [Clang importer] Ensure that we check a bridging PCH in a source file context.
When checking whether we can load a bridging precompiled header (PCH), we end
up parsing module maps. If Clang emits a warning or error while parsing the
module maps we encounter, the Swift compiler would crash because we have not
properly established the invariants of Clang's diagnostic engine. Perform a
pairsed set of BeginSourceFile/EndSourceFile calls on the Clang diagnostic
consumer to set up the appropriate state.

Fixes rdar://problem/57626886.
2019-12-13 11:09:00 -08:00
swift_jenkins
c97c524c80 Merge remote-tracking branch 'origin/master' into master-next 2019-12-13 00:00:34 -08:00
Robert Widmann
dc6858b9e1 Force the entire member table for superclasses
Note that this can be an optimization in many cases since we only have
to scrounge around in the PCMs once.
2019-12-12 21:59:17 -08:00
Robert Widmann
fdb73797cd Don't re-force member loading in already-forced class hierarchies
When deserializing a the (named) members of a class hierarchy, we
needn't walk all the way up the hierarchy, just into our superclass.
This will, in turn, walk to its superclass, etc.  This is as opposed to
this work being repeated at each level of the recursive hierarchy.
Should be a small perf win over the last patch.
2019-12-12 10:59:02 -08:00
swift_jenkins
9193112dbe Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 20:59:55 -08:00
Robert Widmann
4a3bb30337 Force the entire inheritance hierarchy to load class members
An unfortunate pessimization that is needed in order to properly build the member table to run override checking.  Considering this was happening anyways thanks to re-entrant lookups, there shouldn't actually be a perf hit here.
2019-12-11 17:05:07 -08:00
Robert Widmann
af6e9b95ad Work around extension installation order
Bridging headers are weird.

A general principle in the Clang Importer is that when it comes to the
notion of "overrides" or "redeclarations", it's always better to prefer
a declaration in the same translation unit, module, header, etc. over
a declaration outside of that thing.

This behavior, unfortunately, occurred as an emergent property of the
re-entrant lookup that was being performed when importing properties.
The behavior of the visible categories list is in "deserialization
order" - that is, a category defined in a header that imports a module
can potentially appear before the module has had its declarations fully
deserialized and installed.  We were assuming this order was instead
"source order", in which modules would be recursively expanded and their
declarations installed sequentially. If this assumption were to hold,
then the visible categories list would respect the principle above, and
we would see categories in defining modules and headers before we saw
categories in extant translation units.

This is not the case. Delayed deserialization of modules means
the first category that gets parsed actually wins. We were not noticing
this, however, because the few places where it actually mattered were
performing re-entrant lookup and were accidentally deserializing modules
and installing decls in this fictitious "source order".  Since we've
untangled this behavior, we now have to emulate the order the Importer
expects.

Introduce the notion of a "delayed category" - a category that is
defined outside of a module, usually by us. As the name implies, we'll
try to load the categories defined in modules first, then go after the
delayed categories defined in extant translation units.  This gives us
a stable "source order", preserves the Principle of Closest Definition,
and undoes the behavior change for overriden property declarations in
the previous commit.
2019-12-11 12:30:59 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Vedant Kumar
f67b9cbbdd Rename CompilerInstance::ModuleManager to match D70583 (#28625)
See: https://reviews.llvm.org/D70583
2019-12-06 14:33:05 -08:00
Robert Widmann
4043d43d43 Drop the requirement that nested types be clang::TypeDecls
The nested types table contains more than just nested typedefs and aggregate decls, it also contains classes that we've imported under nested names.  We were previously falling back to direct lookup to resolve (cross) references to these entities.  Instead, relax the preconditions for searching the table.

This breaks a few cycles involving re-entrant calls to lookupDirect/lookupQualified through the ClangImporter.
2019-11-21 11:53:43 -08:00
swift_jenkins
626f712ce0 Merge remote-tracking branch 'origin/master' into master-next 2019-11-20 20:20:15 -08:00
Bruno Cardoso Lopes
c362e925af [ClangImporter] Hash content for validation when using clang modules
Set it up as part of configuring the modules build. Should help diminish
the amount of clang modules rebuilds due to mtime invalidation.

rdar://problem/57309954
2019-11-20 09:18:35 -08:00
Jonas Devlieghere
2ab36e22f9 Adjust for upstream LLVM changes 2019-11-15 17:08:49 -08:00
swift_jenkins
b9f998ffa4 Merge remote-tracking branch 'origin/master' into master-next 2019-11-15 15:56:48 -08:00
Tony Allevato
3c45041b17 Add driver modes to emit and dump Clang precompiled modules. 2019-11-11 15:00:51 -08:00
swift-ci
8f128e0e19 Merge remote-tracking branch 'origin/master' into master-next 2019-11-07 12:49:07 -08:00
Duncan P. N. Exon Smith
178d209072 ClangImporter: Use a separate CompilerInstance for canReadPCH
ClangImporter::canReadPCH has been trying to reset the main
CompilerInstance back to as if it hadn't run, but there's a long tail of
potential memory corruption here.  One example is that it's reusing
HeaderSearch, but HeaderSearch contains a ModuleMap whose
SourceLocations will point into the soon-to-be-released ASTContext on
the stack.  Instead, just use a separate CompilerInstnace, like the rest
of the ClangImporter does when it needs a different ASTContext.

This fixes a few potential memory corruption bugs, and it *may* be
related to the persistent "missing submodule X" problems hitting Linux
bots.
2019-11-07 10:47:01 -08:00
Duncan P. N. Exon Smith
0a1d270d50 ClangImporter: Remove redundant temporary copy of CompilerInvocation 2019-11-07 10:47:01 -08:00
swift-ci
0b41d02a4d Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 20:49:50 -07:00
Brent Royal-Gordon
17169fc1fe Merge pull request #27950 from brentdax/dumpster-fire
[NFC] Standardize dump() methods in frontend
2019-10-31 20:36:26 -07:00
Brent Royal-Gordon
99faa033fc [NFC] Standardize dump() methods in frontend
By convention, most structs and classes in the Swift compiler include a `dump()` method which prints debugging information. This method is meant to be called only from the debugger, but this means they’re often unused and may be eliminated from optimized binaries. On the other hand, some parts of the compiler call `dump()` methods directly despite them being intended as a pure debugging aid. clang supports attributes which can be used to avoid these problems, but they’re used very inconsistently across the compiler.

This commit adds `SWIFT_DEBUG_DUMP` and `SWIFT_DEBUG_DUMPER(<name>(<params>))` macros to declare `dump()` methods with the appropriate set of attributes and adopts this macro throughout the frontend. It does not pervasively adopt this macro in SILGen, SILOptimizer, or IRGen; these components use `dump()` methods in a different way where they’re frequently called from debugging code. Nor does it adopt it in runtime components like swiftRuntime and swiftReflection, because I’m a bit worried about size.

Despite the large number of files and lines affected, this change is NFC.
2019-10-31 18:37:42 -07:00
swift-ci
89318956f7 Merge remote-tracking branch 'origin/master' into master-next 2019-10-30 09:10:41 -07:00
Jordan Rose
37bb356ced Merge pull request #27924 from jrose-apple/attribute-attribution
[ClangImporter] Diagnose bad swift_name attributes better
2019-10-30 09:02:12 -07:00
swift-ci
ec9c7e39b3 Merge remote-tracking branch 'origin/master' into master-next 2019-10-29 10:10:11 -07:00
Jordan Rose
b00bc829f8 [ClangImporter] Fall back to Swift class names when resolving @class (#27921)
Christopher Rogers' (good) work in 49fd5acbb2 caught places where
the Swift compiler was allowing a @class to resolve to a Swift class
even if that class had a conflicting Objective-C name, or wasn't
intended to be exposed to Objective-C at all. Unfortunately, this
broke source compatibility in projects where people were relying on
this. Restore that functionality, but only as a fallback; matching the
Objective-C name is better than matching the Swift name.

rdar://problem/56681046
2019-10-29 09:50:49 -07:00
Jordan Rose
8168669a27 [ClangImporter] Diagnose bad swift_name attributes better
1. Set the diagnostic location to where the attribute was written (or
   to the Clang decl's source, if the attribute came from API notes)

2. Add a note to contact the owners of the framework to make it clear
   that the client of the framework didn't do anything wrong.

rdar://problem/52736145
2019-10-28 22:08:26 -07:00
Jordan Rose
e364552876 [ClangImporter] Pull buffer importing out of ClangDiagnosticConsumer
Emitting Swift diagnostics in Clang buffers requires making those
buffers valid places to put Swift SourceLocs, which means making a
mirror of those buffers in the Swift SourceManager. This isn't a copy;
instead, any Clang SourceManagers that are involved are kept alive
until the importer is torn down. (There might be more than one because
of diagnostics emitted during module building.)

For a long time we only emitted diagnostics in Clang buffers if the
diagnostics came from Clang, but then we added another case for custom
Swift names that fail to import. I'm about to add another such
diagnostic, so let's formalize this buffer mapping first.

No intended functionality change.
2019-10-28 22:08:26 -07:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Christopher Rogers
1dbf3c784c Comment gardening 2019-10-23 10:40:33 +09:00
Christopher Rogers
e81db0af76 Use the Obj-C name here 2019-10-23 10:40:33 +09:00