Commit Graph

495 Commits

Author SHA1 Message Date
Alexis Laferrière
c38d1773d2 [Serialization] Restrict loading swiftmodule files to the builder's SDK
Serialize the canonical name of the SDK used when building a swiftmodule
file and use it to ensure that the swiftmodule file is loaded only with
the same SDK. The SDK name must be passed down from the frontend.

This will report unsupported configurations like:

- Installing roots between incompatible SDKs without deleting the
swiftmodule files.
- Having multiple targets in the same project using different SDKs.
- Loading a swiftmodule created with a newer SDK (and stdlib) with an
older SDK.

All of these lead to hard to investigate deserialization failures and
this change should detect them early, before reaching a deserialization
failure.

rdar://78048939
2021-09-13 16:44:08 -07:00
Alexis Laferrière
4f0c57a2d3 [Serialization] Recover from failures in ModuleFile::lookupClassMembers
Access to a missing member on an AnyObject triggers a typo correction
that looks at all class members in imported modules. Make sure it
recovers from deserializing members referencing implementation-only
imported types.

rdar://79427805
2021-06-22 18:36:46 -07:00
Ben Barham
b9a97586c3 [Serialization] Cleanup allow module with errors references 2021-05-22 13:12:46 +10:00
Hamish Knight
ed104a8134 Merge pull request #37014 from hamishknight/entry-sign 2021-05-19 08:32:40 +01:00
Ben Barham
c763ab5d1e [Serialization] Store offset of decls in .swiftsourceinfo
The locations stored in .swiftsourceinfo included the presumed file,
line, and column. When a location is requested it would read these, open
the external file, create a line map, and find the offset corresponding
to that line/column.

The offset is known during serialization though, so output it as well to
avoid having to read the file and generate the line map.

Since the serialized location is returned from `Decl::getLoc()`, it
should not be the presumed location. Instead, also output the line
directives so that the presumed location can be built as per normal
locations.

Finally, move the cache out of `Decl` and into `ASTContext`, since very
few declarations will actually have their locations deserialized. Make
sure to actually write to that cache so it's used - the old cache was
never written to.
2021-04-29 12:33:05 +10:00
Hamish Knight
272090752b [AST] Upgrade MainDecl to a ValueDecl
This will make it easier to store in a SILDeclRef.
2021-04-26 11:42:31 +01:00
eeckstein
149446b0f0 Merge pull request #36858 from eeckstein/remove-oat-tracker
SIL: remove the SILOpenedArchetypesTracker
2021-04-14 12:17:54 +02:00
Erik Eckstein
6ec788ff09 SIL: remove the SILOpenedArchetypesTracker
Instead, put the archetype->instrution map into SIlModule.

SILOpenedArchetypesTracker tried to maintain and reconstruct the mapping locally, e.g. during a use of SILBuilder.
Having a "global" map in SILModule makes the whole logic _much_ simpler.

I'm wondering why we didn't do this in the first place.

This requires that opened archetypes must be unique in a module - which makes sense. This was the case anyway, except for keypath accessors (which I fixed in the previous commit) and in some sil test files.
2021-04-14 08:36:10 +02:00
Ben Barham
c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
Ben Barham
3ea9bed415 [SourceKit/CursorInfo] Add constructor to call results
Cursor info for a constructor would previously give the cursor info for
the containing type only. It now also adds cursor info for the
constructor itself in a "secondary_symbols" field.

Refactor `passCursorInfoForDecl` to use a single allocator rather than
keeping track of positions in a buffer and assigning everything at the
end of the function.

Refactor the various available refactoring gathering functions to take a
SmallVectorImpl and to not copy strings where they don't need to.

Resolves rdar://75385556
2021-03-30 13:23:59 +10:00
David Ungar
90ee114b4a add fingerprint excluding to basic source file info 2021-02-26 17:20:44 -08:00
Rintaro Ishizaki
bb45b2a822 [CodeCompletion] Lazily populate 'BasicSourceFileInfo' 2021-02-25 14:56:55 -08:00
David Ungar
6e034cac4e Revert "[NFC; Incremental] Rename BasicSourceFileInfo.InterfaceHash" 2021-02-25 09:06:53 -08:00
Ben Barham
f410958c9c [Serialization] Import incompatible targets when allowing errors
If allowing modules to be output with compile errors
(-experimental-allow-module-with-errors), import targets regardless of
whether they are compatible or not, and still output the module. The
error diagnostic will still be output (preventing SILGen), but the AST
will be available for various editor functionality.
2021-02-25 09:14:19 +10:00
David Ungar
cbd92e65ff Rename BasicSourceFileInfo.InterfaceHash 2021-02-24 09:13:22 -08:00
swift-ci
89c8005a80 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-27 15:52:25 -08:00
Egor Zhdan
cb5936688c SourceKit: do not print implementation-only imports
Implementation-only imports are unnecessary in generated module interfaces, since they aren't exported to the module's dependencies, and the module's public API cannot refer to symbols imported as implementation-only.
2021-01-24 20:09:19 +03:00
swift-ci
b5748f255b Merge remote-tracking branch 'origin/main' into rebranch 2021-01-16 14:52:22 -08:00
David Ungar
d913dfe9ac Check for fromString failure in ModuleFile.cpp 2021-01-15 13:57:17 -08:00
swift-ci
c49bdea2f1 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-15 10:12:20 -08:00
Rintaro Ishizaki
4e391119e0 [Serialization] Serialize mtime with nanosecond precision
There's no reason to lose accuracy here.
2021-01-14 09:52:35 -08:00
Rintaro Ishizaki
36cfd10041 Cosmetic changes 2021-01-13 13:29:57 -08:00
Rintaro Ishizaki
a9a044c6e3 [Serialization] Serialize fingerprint, mtime, size of the source files 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki
1b6e7857c2 [Serialization] Serialize/deserialize source file list 2021-01-13 11:49:52 -08:00
swift_jenkins
fc19ed94a0 Merge remote-tracking branch 'origin/main' into next 2020-12-15 13:25:19 -08:00
Arnold Schwaighofer
2b6ba2830c Serialize decls with _specialize(exported:true, target: somefunc(_:), ...) in a list for fast lookup
rdar://71430641
2020-12-11 09:58:32 -08:00
swift_jenkins
f3be04a4e2 Merge remote-tracking branch 'origin/main' into next 2020-11-18 22:00:44 -08:00
Robert Widmann
883902411b Migrate loadFingerprint onto ModuleDecl and Friends 2020-11-18 12:20:14 -08:00
Robert Widmann
27d29262b0 [NFC] Traffic in Fingerprints 2020-11-18 12:20:14 -08:00
Robert Widmann
9f79fd5df1 Serialize Fingerprints in Swift Modules 2020-11-17 16:23:07 -08:00
swift_jenkins
ab605d0f44 Merge remote-tracking branch 'origin/main' into next 2020-10-11 12:57:42 -07:00
Brent Royal-Gordon
b440ab7331 [NFC] Move several types/functions to Import.h
To help consolidate our various types describing imports, this commit moves the following types and methods to Import.h:

* ImplicitImports
* ImplicitStdlibKind
* ImplicitImportInfo
* ModuleDecl::ImportedModule
* ModuleDecl::OrderImportedModules (as ImportedModule::Order)
* ModuleDecl::removeDuplicateImports() (as ImportedModule::removeDuplicates())
* SourceFile::ImportFlags
* SourceFile::ImportOptions
* SourceFile::ImportedModuleDesc

This commit is large and intentionally kept mechanical—nothing interesting to see here.
2020-10-09 18:57:07 -07:00
swift_jenkins
b1fa15fe87 Merge remote-tracking branch 'origin/main' into next 2020-09-29 23:14:40 -07:00
Varun Gandhi
734b8a2533 Merge pull request #33986 from varungandhi-apple/vg-import-filter-cleanup
[NFC] Clarify import filtering logic and naming.
2020-09-23 18:23:11 -07:00
Varun Gandhi
d3369f7711 [NFC] Rename ImportFilterKind cases to be clearer. 2020-09-23 12:50:20 -07:00
swift_jenkins
7220ae3d2e Merge remote-tracking branch 'origin/master' into master-next 2020-09-21 13:26:46 -07:00
Robert Widmann
7bee5ffc0c Remove NLOptions::NL_Known* 2020-09-21 10:37:41 -06:00
swift_jenkins
b37089c76b Merge remote-tracking branch 'origin/master' into master-next 2020-09-10 22:30:58 -07:00
Brent Royal-Gordon
4be67a6be1 [NFC] Further simplify ModuleFile::associateWithFileContext 2020-09-10 19:08:29 -07:00
Brent Royal-Gordon
7bfeeebcb9 [NFC] Add helper to parse import paths in strings 2020-09-10 19:08:29 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
swift_jenkins
39a0bc2296 Merge remote-tracking branch 'origin/master' into master-next 2020-09-03 21:31:53 -07:00
Rintaro Ishizaki
6a0a448b01 [Serialization] Remove extInfo param from ModuleFileSharedCore::load()
Populated 'ExtendedValidationInfo' is not used at all.
2020-09-03 14:51:28 -07:00
Nathan Hawes
e882f15a1a Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	lib/Frontend/CompilerInvocation.cpp
	lib/Frontend/ModuleInterfaceLoader.cpp
	lib/Serialization/ModuleFile.cpp
2020-09-03 11:31:12 -07:00
Rintaro Ishizaki
b7c19656ab [Serialization] Minor ModuleFile/ModuleFileSharedCore improvements
* Add properties to ModuleFile which holds information from the control
  block.
* 'ExtendedValidationInfo' parameter for 'ModuleFileSharedCore::load()'
  cannot be 'nullptr'. Make it non-defaulted Rvalue reference.
2020-09-03 11:18:43 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Varun Gandhi
ee10198e9a Manually merge master into master-next.
Fixed merge conflicts in:
- lib/ClangImporter/ClangImporter.cpp
- lib/ClangImporter/ImportType.cpp
- lib/Frontend/CompilerInvocation.cpp
- lib/Serialization/ModuleFile.cpp
- lib/TBDGen/TBDGen.cpp
2020-07-15 21:36:13 -07:00
Argyrios Kyrtzidis
99c29145b2 [Serialization] Refactor subset of ModuleFile into ModuleFileSharedCore
The difference with `ModuleFile` is that `ModuleFileSharedCore` provides immutable data and is independent of a particular ASTContext.
It is designed to be able to be shared across multiple `ModuleFile`s of different `ASTContext`s in a thread-safe manner.
2020-07-06 00:44:36 -07:00
swift_jenkins
48530ac212 Merge remote-tracking branch 'origin/master' into master-next 2020-06-10 10:39:00 -07:00
Arnold Schwaighofer
825a2a259b Mark non-foreign entry points of @objc dynamic methods in generic classes dynamically_replaceable
```
class Generic<T> {
  @objc dynamic func method() {}
}

extension Generic {
  @_dynamicReplacement(for:method())
  func replacement() {}
}
```

The standard mechanism of using Objective-C categories for dynamically
replacing @objc methods in generic classes does not work.

Instead we mark the native entry point as replaceable.

Because this affects all @objc methods in generic classes (whether there
is a replacement or not) by making the native entry point
`[dynamically_replaceable]` (regardless of optimization mode) we guard this by
the -enable-implicit-dynamic flag because we are late in the release cycle.

* Replace isNativeDynamic and isObjcDynamic by calls to shouldUse*Dispatch and
  shouldUse*Replacement
  This disambiguates between which dispatch method we should use at call
  sites and how these methods should  implement dynamic function
  replacement.

* Don't emit the method entry for @_dynamicReplacement(for:) of generic class
  methods
  There is not way to call this entry point since we can't generate an
  objective-c category for generic classes.

rdar://63679357
2020-06-09 09:23:29 -07:00