Skip to content

Commit d62669b

Browse files
authored
---
yaml --- r: 341485 b: refs/heads/rxwei-patch-1 c: 8ac2d65 h: refs/heads/master i: 341483: 31689e3
1 parent a8f9d17 commit d62669b

File tree

14 files changed

+136
-123
lines changed

14 files changed

+136
-123
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: 4c499fd4acccc3a9437d0580bcecd530f6d00031
1018+
refs/heads/rxwei-patch-1: 8ac2d65a52707d6452be3e36d34c2063f28bfa12
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ 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+
9498
#ifndef DIAG_NO_UNDEF
9599
# if defined(DIAG)
96100
# undef DIAG

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@
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-
3226
/// This class manages and owns source buffers.
3327
class SourceManager {
3428
llvm::SourceMgr LLVMSourceMgr;
35-
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> FileSystem;
29+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem;
3630
unsigned CodeCompletionBufferID = 0U;
3731
unsigned CodeCompletionOffset;
3832

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

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

6256
llvm::SourceMgr &getLLVMSourceMgr() {
6357
return LLVMSourceMgr;
@@ -66,12 +60,11 @@ class SourceManager {
6660
return LLVMSourceMgr;
6761
}
6862

69-
void
70-
setFileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> FS) {
63+
void setFileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
7164
FileSystem = FS;
7265
}
7366

74-
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> getFileSystem() {
67+
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() {
7568
return FileSystem;
7669
}
7770

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

263256
#endif // SWIFT_BASIC_SOURCEMANAGER_H
257+

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

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

10131013
// Set up the file manager.
10141014
{
1015-
if (instance.getHeaderSearchOpts().VFSOverlayFiles.empty()) {
1016-
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++;
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);
10411021
}
1042-
1043-
instance.setVirtualFileSystem(ClangImporterFS);
1022+
instance.setVirtualFileSystem(ctx.SourceMgr.getFileSystem());
10441023
}
10451024
instance.createFileManager();
10461025
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ 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
238241
auto Buffer = BaseFS->getBufferForFile(File);
239242
if (!Buffer) {
240243
Diag.diagnose(SourceLoc(), diag::cannot_open_file, File,
@@ -261,7 +264,14 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
261264
hadAnyFailure |=
262265
loadAndValidateVFSOverlay(File, BaseFS, OverlayFS, Diagnostics);
263266
}
264-
SourceMgr.setFileSystem(OverlayFS);
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+
265275
return hadAnyFailure;
266276
}
267277

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::OverlayFileSystem &fs;
276+
llvm::vfs::FileSystem &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::OverlayFileSystem &fs;
768+
llvm::vfs::FileSystem &fs;
769769
DiagnosticEngine &diags;
770770
ModuleRebuildInfo rebuildInfo;
771771
const StringRef modulePath;

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

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

1818
static ValueOwnershipKind getOwnershipKindForUndef(SILType type, const SILFunction &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))
19+
if (type.isAddress() || type.isTrivial(f))
2920
return ValueOwnershipKind::Any;
3021
return ValueOwnershipKind::Owned;
3122
}

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

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

20802080
static ConstraintFix *fixPropertyWrapperFailure(
2081-
ConstraintSystem &cs, Type baseTy, Expr *anchor, ConstraintLocator *locator,
2081+
ConstraintSystem &cs, Type baseTy, ConstraintLocator *locator,
20822082
llvm::function_ref<bool(ResolvedOverloadSetListItem *, VarDecl *, Type)>
20832083
attemptFix,
20842084
Optional<Type> toType = None) {
2085-
auto resolvedOverload = cs.findSelectedOverloadFor(anchor);
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);
20862102
if (!resolvedOverload)
20872103
return nullptr;
20882104

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);
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;
20972135
}
20982136

20992137
if (auto wrapper = cs.getPropertyWrapperInformation(resolvedOverload)) {
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);
2138+
if (auto *fix =
2139+
applyFix(Fix::PropertyWrapper, wrapper->first, wrapper->second))
2140+
return fix;
21052141
}
21062142

21072143
if (auto wrappedProperty =
21082144
cs.getWrappedPropertyInformation(resolvedOverload)) {
2109-
if (attemptFix(resolvedOverload, wrappedProperty->first,
2110-
wrappedProperty->second))
2111-
return UseWrappedValue::create(
2112-
cs, wrappedProperty->first, baseTy,
2113-
toType.getValueOr(wrappedProperty->second), locator);
2145+
if (auto *fix = applyFix(Fix::WrappedValue, wrappedProperty->first,
2146+
wrappedProperty->second))
2147+
return fix;
21142148
}
2149+
21152150
return nullptr;
21162151
}
21172152

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

2238-
auto anchor = simplifyLocatorToAnchor(*this, loc);
2239-
22402273
if (auto *fix = fixPropertyWrapperFailure(
2241-
*this, lhs, anchor, loc,
2274+
*this, lhs, loc,
22422275
[&](ResolvedOverloadSetListItem *overload, VarDecl *decl,
22432276
Type newBase) {
22442277
// FIXME: There is currently no easy way to avoid attempting
@@ -4907,19 +4940,15 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
49074940
// Check if any property wrappers on the base of the member lookup have
49084941
// matching members that we can fall back to, or if the type wraps any
49094942
// properties that have matching members.
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-
}
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;
49234952
}
49244953

49254954
if (auto *funcType = baseTy->getAs<FunctionType>()) {
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module VFSMappedModule {
22
header "VFSMappedModule.h"
33
}
4-
5-
module YetAnotherVFSMappedModule {
6-
header "YetAnotherVFSMappedModule.h"
7-
}

branches/rxwei-patch-1/test/Frontend/Inputs/vfs/b-header

Lines changed: 0 additions & 1 deletion
This file was deleted.

branches/rxwei-patch-1/test/Frontend/Inputs/vfs/quaternary-vfsoverlay.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
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
65

76
// 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
87
// RUN: c-index-test -read-diagnostics %/t/basic.dia 2>&1 | %FileCheck -check-prefix=BASIC_MAPPING_ERROR %s
@@ -21,11 +20,10 @@
2120
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %/t -DTEST_VFS_CLANG_IMPORTER -Xcc -ivfsoverlay -Xcc %/t/overlay.yaml -typecheck %/s
2221

2322
// If we see -ivfsoverlay and -vfsoverlay, we'll clobber Clang's VFS with our own.
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
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'
2526

2627
#if TEST_VFS_CLANG_IMPORTER
2728
import VFSMappedModule
28-
#if TEST_VFS_CLANG_IMPORTER_MERGE
29-
import YetAnotherVFSMappedModule
30-
#endif
3129
#endif

0 commit comments

Comments
 (0)