Skip to content

Commit 7be312c

Browse files
authored
Merge pull request #1797 from swiftwasm/master
[pull] swiftwasm from master
2 parents c89e502 + ec72db1 commit 7be312c

File tree

4 files changed

+89
-49
lines changed

4 files changed

+89
-49
lines changed

include/swift/AST/Expr.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4568,16 +4568,10 @@ class DotSyntaxCallExpr : public SelfApplyExpr {
45684568

45694569
SourceLoc getDotLoc() const { return DotLoc; }
45704570

4571-
SourceLoc getLoc() const {
4572-
return isImplicit() ? getBase()->getStartLoc() : getFn()->getLoc();
4573-
}
4574-
SourceLoc getStartLoc() const {
4575-
return getBase()->getStartLoc();
4576-
}
4577-
SourceLoc getEndLoc() const {
4578-
return isImplicit() ? getBase()->getEndLoc() : getFn()->getEndLoc();
4579-
}
4580-
4571+
SourceLoc getLoc() const;
4572+
SourceLoc getStartLoc() const;
4573+
SourceLoc getEndLoc() const;
4574+
45814575
static bool classof(const Expr *E) {
45824576
return E->getKind() == ExprKind::DotSyntaxCall;
45834577
}

lib/AST/Expr.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,12 @@ CallExpr::CallExpr(Expr *fn, Expr *arg, bool Implicit,
16781678
Bits.CallExpr.HasArgLabelLocs = !argLabelLocs.empty();
16791679
Bits.CallExpr.HasTrailingClosure = hasTrailingClosure;
16801680
initializeCallArguments(argLabels, argLabelLocs);
1681+
1682+
#ifndef NDEBUG
1683+
Expr *calleeFn = fn->getSemanticsProvidingExpr();
1684+
if (auto *calleeDRE = dyn_cast<DeclRefExpr>(calleeFn))
1685+
assert(!calleeDRE->getDecl()->isInstanceMember());
1686+
#endif
16811687
}
16821688

16831689
CallExpr *CallExpr::create(ASTContext &ctx, Expr *fn, Expr *arg,
@@ -1751,6 +1757,33 @@ Expr *CallExpr::getDirectCallee() const {
17511757
}
17521758
}
17531759

1760+
SourceLoc DotSyntaxCallExpr::getLoc() const {
1761+
if (isImplicit()) {
1762+
SourceLoc baseLoc = getBase()->getLoc();
1763+
return baseLoc.isValid() ? baseLoc : getFn()->getLoc();
1764+
}
1765+
1766+
return getFn()->getLoc();
1767+
}
1768+
1769+
SourceLoc DotSyntaxCallExpr::getStartLoc() const {
1770+
if (isImplicit()) {
1771+
SourceLoc baseLoc = getBase()->getStartLoc();
1772+
return baseLoc.isValid() ? baseLoc : getFn()->getStartLoc();
1773+
}
1774+
1775+
return getBase()->getStartLoc();
1776+
}
1777+
1778+
SourceLoc DotSyntaxCallExpr::getEndLoc() const {
1779+
if (isImplicit()) {
1780+
SourceLoc fnLoc = getFn()->getEndLoc();
1781+
return fnLoc.isValid() ? fnLoc : getBase()->getEndLoc();
1782+
}
1783+
1784+
return getFn()->getEndLoc();
1785+
}
1786+
17541787
void ExplicitCastExpr::setCastType(Type type) {
17551788
CastTy->setType(MetatypeType::get(type));
17561789
}

lib/Sema/CSApply.cpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,24 @@ namespace {
916916

917917
Expr *selfOpenedRef = selfParamRef;
918918

919+
// If the 'self' parameter has non-trivial ownership, adjust the
920+
// argument accordingly.
921+
switch (selfParam.getValueOwnership()) {
922+
case ValueOwnership::Default:
923+
case ValueOwnership::InOut:
924+
break;
925+
926+
case ValueOwnership::Owned:
927+
case ValueOwnership::Shared:
928+
// Ensure that the argument type matches up exactly.
929+
auto selfArgTy = ParenType::get(context,
930+
selfParam.getPlainType(),
931+
selfParam.getParameterFlags());
932+
selfOpenedRef->setType(selfArgTy);
933+
cs.cacheType(selfOpenedRef);
934+
break;
935+
}
936+
919937
if (selfParamTy->hasOpenedExistential()) {
920938
// If we're opening an existential:
921939
// - the type of 'ref' inside the closure is written in terms of the
@@ -931,31 +949,10 @@ namespace {
931949
}
932950

933951
// (Self) -> ...
934-
ApplyExpr *selfCall;
935-
936-
// We build either a CallExpr or a DotSyntaxCallExpr depending on whether
937-
// the base is implicit or not. This helps maintain some invariants around
938-
// source ranges.
939-
if (selfParamRef->isImplicit()) {
940-
selfCall =
941-
CallExpr::createImplicit(context, ref, selfOpenedRef, {},
942-
[&](Expr *E) { return cs.getType(E); });
943-
selfCall->setType(refTy->getResult());
944-
cs.cacheType(selfCall);
945-
946-
// FIXME: This is a holdover from the old tuple-based function call
947-
// representation.
948-
auto selfArgTy = ParenType::get(context,
949-
selfParam.getPlainType(),
950-
selfParam.getParameterFlags());
951-
selfCall->getArg()->setType(selfArgTy);
952-
cs.cacheType(selfCall->getArg());
953-
} else {
954-
selfCall = new (context) DotSyntaxCallExpr(ref, SourceLoc(), selfOpenedRef);
955-
selfCall->setImplicit(false);
956-
selfCall->setType(refTy->getResult());
957-
cs.cacheType(selfCall);
958-
}
952+
ApplyExpr *selfCall = new (context) DotSyntaxCallExpr(
953+
ref, SourceLoc(), selfOpenedRef);
954+
selfCall->setType(refTy->getResult());
955+
cs.cacheType(selfCall);
959956

960957
if (selfParamRef->isSuperExpr())
961958
selfCall->setIsSuper(true);
@@ -7132,7 +7129,7 @@ ExprRewriter::buildDynamicCallable(ApplyExpr *apply, SelectedOverload selected,
71327129

71337130
// Construct expression referencing the `dynamicallyCall` method.
71347131
auto member = buildMemberRef(fn, SourceLoc(), selected,
7135-
DeclNameLoc(method->getNameLoc()), loc, loc,
7132+
DeclNameLoc(), loc, loc,
71367133
/*implicit=*/true, AccessSemantics::Ordinary);
71377134

71387135
// Construct argument to the method (either an array or dictionary

utils/build-windows.bat

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
:: Additionally, it needs the following variables:
1515
:: - CMAKE_BUILD_TYPE: Kind of build: Release, RelWithDebInfo, Debug.
1616
:: - PYTHON_HOME: The Python installation directory.
17+
:: - REPO_SCHEME: Optional. The scheme name to checkout.
1718

1819
:: REQUIRED PERMISSIONS
1920
:: Practically, it is easier to be in the Adminstrators group to run the
@@ -25,6 +26,8 @@
2526

2627
setlocal enableextensions enabledelayedexpansion
2728

29+
PATH=%PATH%;%PYTHON_HOME%
30+
2831
set icu_version_major=64
2932
set icu_version_minor=2
3033
set icu_version=%icu_version_major%_%icu_version_minor%
@@ -53,7 +56,7 @@ set install_directory=%build_root%\Library\Developer\Toolchains\unknown-Asserts-
5356
md %build_root%\tmp
5457
set TMPDIR=%build_root%\tmp
5558

56-
md %build_root%\tmp\org.llvm.clang
59+
md %build_root%\tmp\org.llvm.clang.9999
5760
set CUSTOM_CLANG_MODULE_CACHE=%build_root%\tmp\org.llvm.clang.9999
5861

5962
md %build_root%\tmp\org.swift.package-manager
@@ -89,20 +92,33 @@ endlocal
8992
:: It supposes the %CD% is the source root.
9093
setlocal enableextensions enabledelayedexpansion
9194

95+
if defined REPO_SCHEME SET "scheme_arg=--scheme %REPO_SCHEME%"
96+
9297
git -C "%source_root%\swift" config --local core.autocrlf input
9398
git -C "%source_root%\swift" config --local core.symlink true
9499
git -C "%source_root%\swift" checkout-index --force --all
95100

96-
git clone --depth 1 --single-branch https://github.com/apple/swift-cmark cmark %exitOnError%
97-
git clone --depth 1 --single-branch --branch swift/master https://github.com/apple/llvm-project llvm-project %exitOnError%
98-
mklink /D "%source_root%\clang" "%source_root%\llvm-project\clang"
99-
mklink /D "%source_root%\llvm" "%source_root%\llvm-project\llvm"
100-
mklink /D "%source_root%\lld" "%source_root%\llvm-project\lld"
101-
mklink /D "%source_root%\lldb" "%source_root%\llvm-project\lldb"
102-
mklink /D "%source_root%\compiler-rt" "%source_root%\llvm-project\compiler-rt"
103-
mklink /D "%source_root%\libcxx" "%source_root%\llvm-project\libcxx"
104-
mklink /D "%source_root%\clang-tools-extra" "%source_root%\llvm-project\clang-tools-extra"
105-
git clone --depth 1 --single-branch https://github.com/apple/swift-corelibs-libdispatch %exitOnError%
101+
:: Always skip Swift, since it is checked out by Jenkins
102+
@set "skip_repositories_arg=--skip-repository swift"
103+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository llbuild"
104+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository indexstore-db"
105+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository ninja"
106+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository sourcekit-lsp"
107+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-argument-parser"
108+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-corelibs-foundation"
109+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-corelibs-xctest"
110+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-driver"
111+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-format"
112+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-integration-tests"
113+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swiftpm"
114+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-stress-tester"
115+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-syntax"
116+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-tools-support-core"
117+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository swift-xcode-playground-support"
118+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository tensorflow-swift-apis"
119+
@set "skip_repositories_arg=%skip_repositories_arg% --skip-repository yams"
120+
121+
call "%source_root%\swift\utils\update-checkout.cmd" %scheme_arg% %skip_repositories_arg% --clone --skip-history --github-comment "%ghprbCommentBody%" >NUL 2>NUL
106122

107123
goto :eof
108124
endlocal
@@ -185,7 +201,7 @@ cmake^
185201
-DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
186202
-DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
187203
-DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
188-
-S "%source_root%\llvm" %exitOnError%
204+
-S "%source_root%\llvm-project\llvm" %exitOnError%
189205

190206
cmake --build "%build_root%\llvm" %exitOnError%
191207
cmake --build "%build_root%\llvm" --target install %exitOnError%
@@ -294,7 +310,7 @@ cmake^
294310
-DLLDB_DISABLE_PYTHON=YES^
295311
-DLLDB_INCLUDE_TESTS:BOOL=NO^
296312
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON^
297-
-S "%source_root%\lldb" %exitOnError%
313+
-S "%source_root%\llvm-project\lldb" %exitOnError%
298314

299315
cmake --build "%build_root%\lldb" %exitOnError%
300316
cmake --build "%build_root%\lldb" --target install %exitOnError%

0 commit comments

Comments
 (0)