Skip to content

Commit 9775e7e

Browse files
committed
---
yaml --- r: 341479 b: refs/heads/rxwei-patch-1 c: a1905aa h: refs/heads/master i: 341477: 8c9f225 341475: a9bae3e 341471: 6d89038
1 parent 5481728 commit 9775e7e

File tree

16 files changed

+140
-136
lines changed

16 files changed

+140
-136
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 7da25d7318730df2e9c843a0ce1fc299054f2195
1018+
refs/heads/rxwei-patch-1: a1905aa1dabe2fd782cc88a62a76075432975344
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ WARNING(implicit_bridging_header_imported_from_module,none,
9191
"is deprecated and will be removed in a later version of Swift",
9292
(StringRef, Identifier))
9393

94-
WARNING(clang_vfs_overlay_is_ignored,none,
95-
"ignoring '-ivfsoverlay' options provided to '-Xcc' in favor of "
96-
"'-vfsoverlay'", ())
97-
9894
#ifndef DIAG_NO_UNDEF
9995
# if defined(DIAG)
10096
# undef DIAG

branches/rxwei-patch-1/include/swift/AST/ProtocolConformanceRef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class ProtocolConformanceRef {
110110
LookupConformanceFn conformances,
111111
SubstOptions options = None) const;
112112

113+
/// Map contextual types to interface types in the conformance.
114+
ProtocolConformanceRef mapConformanceOutOfContext() const;
115+
113116
/// Given a dependent type (expressed in terms of this conformance's
114117
/// protocol), follow it from the conforming type.
115118
Type getAssociatedType(Type origType, Type dependentType,

branches/rxwei-patch-1/include/swift/Basic/SourceManager.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@
2323

2424
namespace swift {
2525

26+
static inline llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>
27+
getRealOverlayFileSystem() {
28+
return llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>(
29+
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
30+
}
31+
2632
/// This class manages and owns source buffers.
2733
class SourceManager {
2834
llvm::SourceMgr LLVMSourceMgr;
29-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem;
35+
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> FileSystem;
3036
unsigned CodeCompletionBufferID = 0U;
3137
unsigned CodeCompletionOffset;
3238

@@ -49,9 +55,9 @@ class SourceManager {
4955
mutable std::pair<const char *, const VirtualFile*> CachedVFile = {nullptr, nullptr};
5056

5157
public:
52-
SourceManager(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
53-
llvm::vfs::getRealFileSystem())
54-
: FileSystem(FS) {}
58+
SourceManager(llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> FS =
59+
getRealOverlayFileSystem())
60+
: FileSystem(FS) {}
5561

5662
llvm::SourceMgr &getLLVMSourceMgr() {
5763
return LLVMSourceMgr;
@@ -60,11 +66,12 @@ class SourceManager {
6066
return LLVMSourceMgr;
6167
}
6268

63-
void setFileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
69+
void
70+
setFileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> FS) {
6471
FileSystem = FS;
6572
}
6673

67-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() {
74+
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> getFileSystem() {
6875
return FileSystem;
6976
}
7077

@@ -254,4 +261,3 @@ class SourceManager {
254261
} // end namespace swift
255262

256263
#endif // SWIFT_BASIC_SOURCEMANAGER_H
257-

branches/rxwei-patch-1/lib/AST/ProtocolConformance.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ ProtocolConformanceRef::subst(Type origType,
141141
llvm_unreachable("Invalid conformance substitution");
142142
}
143143

144+
ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfContext() const {
145+
if (!isConcrete())
146+
return *this;
147+
148+
auto *concrete = getConcrete()->subst(
149+
[](SubstitutableType *type) -> Type {
150+
if (auto *archetypeType = type->getAs<ArchetypeType>())
151+
return archetypeType->getInterfaceType();
152+
return type;
153+
},
154+
MakeAbstractConformanceForGenericType());
155+
return ProtocolConformanceRef(concrete);
156+
}
157+
144158
Type
145159
ProtocolConformanceRef::getTypeWitnessByName(Type type, Identifier name) const {
146160
assert(!isInvalid());

branches/rxwei-patch-1/lib/ClangImporter/ClangImporter.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,14 +1012,35 @@ ClangImporter::create(ASTContext &ctx,
10121012

10131013
// Set up the file manager.
10141014
{
1015-
if (!ctx.SearchPathOpts.VFSOverlayFiles.empty()) {
1016-
// If the clang instance has overlays it means the user has provided
1017-
// -ivfsoverlay options and swift -vfsoverlay options. We're going to
1018-
// clobber their file system with our own, so warn about it.
1019-
if (!instance.getHeaderSearchOpts().VFSOverlayFiles.empty()) {
1020-
ctx.Diags.diagnose(SourceLoc(), diag::clang_vfs_overlay_is_ignored);
1021-
}
1015+
if (instance.getHeaderSearchOpts().VFSOverlayFiles.empty()) {
10221016
instance.setVirtualFileSystem(ctx.SourceMgr.getFileSystem());
1017+
} else {
1018+
// Initialize the clang VFS from its compiler invocation.
1019+
instance.createFileManager();
1020+
1021+
// Create a new overlay file system for the clang importer with the clang
1022+
// VFS as its root.
1023+
auto ClangImporterFS =
1024+
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>(
1025+
new llvm::vfs::OverlayFileSystem(
1026+
&instance.getVirtualFileSystem()));
1027+
1028+
auto SwiftFS = ctx.SourceMgr.getFileSystem();
1029+
auto it = SwiftFS->overlays_rbegin();
1030+
auto end = SwiftFS->overlays_rend();
1031+
1032+
// The Swift file system is an overlay file system with the real file
1033+
// system as its root. Skip the root so we query the other overlays
1034+
// before falling back to the real file system.
1035+
it++;
1036+
1037+
// Add all remaining Swift overlay file systems to the new file system.
1038+
while (it != end) {
1039+
ClangImporterFS->pushOverlay(*it);
1040+
it++;
1041+
}
1042+
1043+
instance.setVirtualFileSystem(ClangImporterFS);
10231044
}
10241045
instance.createFileManager();
10251046
}

branches/rxwei-patch-1/lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ static bool loadAndValidateVFSOverlay(
235235
const llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> &BaseFS,
236236
const llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> &OverlayFS,
237237
DiagnosticEngine &Diag) {
238-
// FIXME: It should be possible to allow chained lookup of later VFS overlays
239-
// through the mapping defined by earlier overlays.
240-
// See rdar://problem/39440687
241238
auto Buffer = BaseFS->getBufferForFile(File);
242239
if (!Buffer) {
243240
Diag.diagnose(SourceLoc(), diag::cannot_open_file, File,
@@ -264,14 +261,7 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
264261
hadAnyFailure |=
265262
loadAndValidateVFSOverlay(File, BaseFS, OverlayFS, Diagnostics);
266263
}
267-
268-
// If we successfully loaded all the overlays, let the source manager and
269-
// diagnostic engine take advantage of the overlay file system.
270-
if (!hadAnyFailure &&
271-
(OverlayFS->overlays_begin() != OverlayFS->overlays_end())) {
272-
SourceMgr.setFileSystem(OverlayFS);
273-
}
274-
264+
SourceMgr.setFileSystem(OverlayFS);
275265
return hadAnyFailure;
276266
}
277267

branches/rxwei-patch-1/lib/Frontend/ParseableInterfaceModuleLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static Optional<StringRef> getRelativeDepPath(StringRef DepPath,
273273
/// output path.
274274
/// \note Needs to be in the swift namespace so CompilerInvocation can see it.
275275
class swift::ParseableInterfaceBuilder {
276-
llvm::vfs::FileSystem &fs;
276+
llvm::vfs::OverlayFileSystem &fs;
277277
DiagnosticEngine &diags;
278278
const StringRef interfacePath;
279279
const StringRef moduleName;
@@ -765,7 +765,7 @@ class ParseableInterfaceModuleLoaderImpl {
765765
using AccessPathElem = std::pair<Identifier, SourceLoc>;
766766
friend class swift::ParseableInterfaceModuleLoader;
767767
ASTContext &ctx;
768-
llvm::vfs::FileSystem &fs;
768+
llvm::vfs::OverlayFileSystem &fs;
769769
DiagnosticEngine &diags;
770770
ModuleRebuildInfo rebuildInfo;
771771
const StringRef modulePath;

branches/rxwei-patch-1/lib/SIL/SILUndef.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
using namespace swift;
1717

1818
static ValueOwnershipKind getOwnershipKindForUndef(SILType type, const SILFunction &f) {
19-
if (type.isAddress() || type.isTrivial(f))
19+
if (type.isAddress()) {
20+
// If we have an address only type and we are supposed to use
21+
// lowered addresses, return Owned. Otherwise addresses are any.
22+
if (type.isAddressOnly(f) && f.getConventions().useLoweredAddresses()) {
23+
return ValueOwnershipKind::Owned;
24+
}
25+
return ValueOwnershipKind::Any;
26+
}
27+
28+
if (type.isTrivial(f))
2029
return ValueOwnershipKind::Any;
2130
return ValueOwnershipKind::Owned;
2231
}

branches/rxwei-patch-1/lib/Sema/CSSimplify.cpp

Lines changed: 36 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,75 +2078,40 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
20782078
}
20792079

20802080
static ConstraintFix *fixPropertyWrapperFailure(
2081-
ConstraintSystem &cs, Type baseTy, ConstraintLocator *locator,
2081+
ConstraintSystem &cs, Type baseTy, Expr *anchor, ConstraintLocator *locator,
20822082
llvm::function_ref<bool(ResolvedOverloadSetListItem *, VarDecl *, Type)>
20832083
attemptFix,
20842084
Optional<Type> toType = None) {
2085-
2086-
Expr *baseExpr = nullptr;
2087-
if (auto *anchor = locator->getAnchor()) {
2088-
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(anchor))
2089-
baseExpr = UDE->getBase();
2090-
else if (auto *SE = dyn_cast<SubscriptExpr>(anchor))
2091-
baseExpr = SE->getBase();
2092-
else if (auto *MRE = dyn_cast<MemberRefExpr>(anchor))
2093-
baseExpr = MRE->getBase();
2094-
else if (auto *anchor = simplifyLocatorToAnchor(cs, locator))
2095-
baseExpr = anchor;
2096-
}
2097-
2098-
if (!baseExpr)
2099-
return nullptr;
2100-
2101-
auto resolvedOverload = cs.findSelectedOverloadFor(baseExpr);
2085+
auto resolvedOverload = cs.findSelectedOverloadFor(anchor);
21022086
if (!resolvedOverload)
21032087
return nullptr;
21042088

2105-
enum class Fix : uint8_t {
2106-
StorageWrapper,
2107-
PropertyWrapper,
2108-
WrappedValue,
2109-
};
2110-
2111-
auto applyFix = [&](Fix fix, VarDecl *decl, Type type) -> ConstraintFix * {
2112-
if (!decl->hasValidSignature() || !type)
2113-
return nullptr;
2114-
2115-
if (!attemptFix(resolvedOverload, decl, type))
2116-
return nullptr;
2117-
2118-
switch (fix) {
2119-
case Fix::StorageWrapper:
2120-
case Fix::PropertyWrapper:
2121-
return UsePropertyWrapper::create(cs, decl, fix == Fix::StorageWrapper,
2122-
baseTy, toType.getValueOr(type),
2123-
locator);
2124-
2125-
case Fix::WrappedValue:
2126-
return UseWrappedValue::create(cs, decl, baseTy, toType.getValueOr(type),
2127-
locator);
2128-
}
2129-
};
2130-
2131-
if (auto storageWrapper = cs.getStorageWrapperInformation(resolvedOverload)) {
2132-
if (auto *fix = applyFix(Fix::StorageWrapper, storageWrapper->first,
2133-
storageWrapper->second))
2134-
return fix;
2089+
if (auto storageWrapper =
2090+
cs.getStorageWrapperInformation(resolvedOverload)) {
2091+
if (attemptFix(resolvedOverload, storageWrapper->first,
2092+
storageWrapper->second))
2093+
return UsePropertyWrapper::create(
2094+
cs, storageWrapper->first,
2095+
/*usingStorageWrapper=*/true, baseTy,
2096+
toType.getValueOr(storageWrapper->second), locator);
21352097
}
21362098

21372099
if (auto wrapper = cs.getPropertyWrapperInformation(resolvedOverload)) {
2138-
if (auto *fix =
2139-
applyFix(Fix::PropertyWrapper, wrapper->first, wrapper->second))
2140-
return fix;
2100+
if (attemptFix(resolvedOverload, wrapper->first, wrapper->second))
2101+
return UsePropertyWrapper::create(
2102+
cs, wrapper->first,
2103+
/*usingStorageWrappeer=*/false, baseTy,
2104+
toType.getValueOr(wrapper->second), locator);
21412105
}
21422106

21432107
if (auto wrappedProperty =
21442108
cs.getWrappedPropertyInformation(resolvedOverload)) {
2145-
if (auto *fix = applyFix(Fix::WrappedValue, wrappedProperty->first,
2146-
wrappedProperty->second))
2147-
return fix;
2109+
if (attemptFix(resolvedOverload, wrappedProperty->first,
2110+
wrappedProperty->second))
2111+
return UseWrappedValue::create(
2112+
cs, wrappedProperty->first, baseTy,
2113+
toType.getValueOr(wrappedProperty->second), locator);
21482114
}
2149-
21502115
return nullptr;
21512116
}
21522117

@@ -2270,8 +2235,10 @@ bool ConstraintSystem::repairFailures(
22702235
if (elt.getKind() != ConstraintLocator::ApplyArgToParam)
22712236
break;
22722237

2238+
auto anchor = simplifyLocatorToAnchor(*this, loc);
2239+
22732240
if (auto *fix = fixPropertyWrapperFailure(
2274-
*this, lhs, loc,
2241+
*this, lhs, anchor, loc,
22752242
[&](ResolvedOverloadSetListItem *overload, VarDecl *decl,
22762243
Type newBase) {
22772244
// FIXME: There is currently no easy way to avoid attempting
@@ -4940,15 +4907,19 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
49404907
// Check if any property wrappers on the base of the member lookup have
49414908
// matching members that we can fall back to, or if the type wraps any
49424909
// properties that have matching members.
4943-
if (auto *fix = fixPropertyWrapperFailure(
4944-
*this, baseTy, locator,
4945-
[&](ResolvedOverloadSetListItem *overload, VarDecl *decl,
4946-
Type newBase) {
4947-
return solveWithNewBaseOrName(newBase, member,
4948-
/*allowFixes=*/false) ==
4949-
SolutionKind::Solved;
4950-
})) {
4951-
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
4910+
if (auto dotExpr =
4911+
dyn_cast_or_null<UnresolvedDotExpr>(locator->getAnchor())) {
4912+
auto baseExpr = dotExpr->getBase();
4913+
if (auto *fix = fixPropertyWrapperFailure(
4914+
*this, baseTy, baseExpr, locator,
4915+
[&](ResolvedOverloadSetListItem *overload, VarDecl *decl,
4916+
Type newBase) {
4917+
return solveWithNewBaseOrName(newBase, member,
4918+
/*allowFixes=*/false) ==
4919+
SolutionKind::Solved;
4920+
})) {
4921+
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
4922+
}
49524923
}
49534924

49544925
if (auto *funcType = baseTy->getAs<FunctionType>()) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module VFSMappedModule {
22
header "VFSMappedModule.h"
33
}
4+
5+
module YetAnotherVFSMappedModule {
6+
header "YetAnotherVFSMappedModule.h"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define MAJOR_SUCCESS 1
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
'version': 0,
3+
'use-external-names': false,
4+
'roots': [
5+
{
6+
'name': 'OUT_DIR', 'type': 'directory',
7+
'contents': [
8+
{ 'name': 'YetAnotherVFSMappedModule.h', 'type': 'file',
9+
'external-contents': 'INPUT_DIR/vfs/b-header'
10+
},
11+
{ 'name': 'YetAnotherVFSMappedModule.framework/Headers/VFSMappedModule.h', 'type': 'file',
12+
'external-contents': 'INPUT_DIR/vfs/b-header'
13+
},
14+
]
15+
},
16+
]
17+
}

branches/rxwei-patch-1/test/Frontend/vfs.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: sed -e "s|INPUT_DIR|%/S/Inputs|g" -e "s|OUT_DIR|%/t|g" %S/Inputs/vfs/vfsoverlay.yaml > %t/overlay.yaml
33
// RUN: sed -e "s|INPUT_DIR|%/S/Inputs|g" -e "s|OUT_DIR|%/t|g" %S/Inputs/vfs/secondary-vfsoverlay.yaml > %t/secondary-overlay.yaml
44
// RUN: sed -e "s|INPUT_DIR|%/S/Inputs|g" -e "s|OUT_DIR|%/t|g" %S/Inputs/vfs/tertiary-vfsoverlay.yaml > %t/tertiary-overlay.yaml
5+
// RUN: sed -e "s|INPUT_DIR|%/S/Inputs|g" -e "s|OUT_DIR|%/t|g" %S/Inputs/vfs/quaternary-vfsoverlay.yaml > %t/quaternary-vfsoverlay.yaml
56

67
// RUN: not %target-swift-frontend -vfsoverlay %/t/overlay.yaml -typecheck %s %/t/mapped-file.swift -serialize-diagnostics-path %/t/basic.dia 2>&1 | %FileCheck -check-prefix=BASIC_MAPPING_ERROR %s
78
// RUN: c-index-test -read-diagnostics %/t/basic.dia 2>&1 | %FileCheck -check-prefix=BASIC_MAPPING_ERROR %s
@@ -20,10 +21,11 @@
2021
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %/t -DTEST_VFS_CLANG_IMPORTER -Xcc -ivfsoverlay -Xcc %/t/overlay.yaml -typecheck %/s
2122

2223
// If we see -ivfsoverlay and -vfsoverlay, we'll clobber Clang's VFS with our own.
23-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %/t -DTEST_VFS_CLANG_IMPORTER -vfsoverlay %/t/overlay.yaml -Xcc -ivfsoverlay -Xcc %/t/overlay.yaml -typecheck %/s 2>&1 | %FileCheck -check-prefix=WARN_VFS_CLOBBERED %s
24-
25-
// WARN_VFS_CLOBBERED: warning: ignoring '-ivfsoverlay' options provided to '-Xcc' in favor of '-vfsoverlay'
24+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %/t -DTEST_VFS_CLANG_IMPORTER -DTEST_VFS_CLANG_IMPORTER_MERGE -vfsoverlay %/t/overlay.yaml -Xcc -ivfsoverlay -Xcc %/t/quaternary-vfsoverlay.yaml -typecheck %/s 2>&1
2625

2726
#if TEST_VFS_CLANG_IMPORTER
2827
import VFSMappedModule
28+
#if TEST_VFS_CLANG_IMPORTER_MERGE
29+
import YetAnotherVFSMappedModule
30+
#endif
2931
#endif

0 commit comments

Comments
 (0)