Skip to content

Commit c7588a9

Browse files
authored
---
yaml --- r: 341823 b: refs/heads/rxwei-patch-1 c: 5969aca h: refs/heads/master i: 341821: cc9ba5c 341819: 38add50 341815: 7db2dda 341807: 7b33332 341791: ca6d2b8 341759: cf9612b
1 parent b606291 commit c7588a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+692
-690
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: e16eb86bc0a880332afce996f7739aec9a516f18
1018+
refs/heads/rxwei-patch-1: 5969aca6b117f4e0d72344927ae8a74e30f8e300
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/Decl.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5773,6 +5773,11 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57735773
setBodyKind(BodyKind::Unparsed);
57745774
}
57755775

5776+
/// Provide the parsed body for the function.
5777+
void setBodyParsed(BraceStmt *S) {
5778+
setBody(S, BodyKind::Parsed);
5779+
}
5780+
57765781
/// Note that parsing for the body was delayed.
57775782
///
57785783
/// The function should return the body statement and a flag indicating
@@ -5793,14 +5798,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57935798
setBodyKind(BodyKind::MemberwiseInitializer);
57945799
}
57955800

5796-
/// If a body has been loaded, flag that it's been type-checked.
5797-
/// This is kindof a hacky operation, but it avoids some unnecessary
5798-
/// duplication of work.
5799-
void setBodyTypeCheckedIfPresent() {
5800-
if (getBodyKind() == BodyKind::Parsed)
5801-
setBodyKind(BodyKind::TypeChecked);
5802-
}
5803-
58045801
/// Gets the body of this function, stripping the unused portions of #if
58055802
/// configs inside the body. If this function was not deserialized from a
58065803
/// .swiftmodule, this body is reconstructed from the original

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ WARNING(warn_use_filelists_deprecated, none,
166166
ERROR(cannot_find_migration_script, none,
167167
"missing migration script from path '%0'", (StringRef))
168168

169+
ERROR(error_darwin_static_stdlib_not_supported, none,
170+
"-static-stdlib is no longer supported on Apple platforms", ())
171+
169172
#ifndef DIAG_NO_UNDEF
170173
# if defined(DIAG)
171174
# undef DIAG

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

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,14 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
954954
/// would not work for \c stringLiteral->getEndLoc().
955955
SourceLoc TrailingQuoteLoc;
956956
TapExpr *AppendingExpr;
957-
Expr *SemanticExpr;
958-
957+
958+
// Set by Sema:
959+
OpaqueValueExpr *interpolationExpr = nullptr;
960+
ConcreteDeclRef builderInit;
961+
ConcreteDeclRef resultInit;
962+
Expr *interpolationCountExpr = nullptr;
963+
Expr *literalCapacityExpr = nullptr;
964+
959965
public:
960966
InterpolatedStringLiteralExpr(SourceLoc Loc,
961967
SourceLoc TrailingQuoteLoc,
@@ -965,11 +971,35 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
965971
: LiteralExpr(ExprKind::InterpolatedStringLiteral, /*Implicit=*/false),
966972
Loc(Loc),
967973
TrailingQuoteLoc(TrailingQuoteLoc),
968-
AppendingExpr(AppendingExpr), SemanticExpr() {
974+
AppendingExpr(AppendingExpr) {
969975
Bits.InterpolatedStringLiteralExpr.InterpolationCount = InterpolationCount;
970976
Bits.InterpolatedStringLiteralExpr.LiteralCapacity = LiteralCapacity;
971977
}
972978

979+
// Sets the constructor for the interpolation type.
980+
void setBuilderInit(ConcreteDeclRef decl) { builderInit = decl; }
981+
ConcreteDeclRef getBuilderInit() const { return builderInit; }
982+
983+
/// Sets the decl that constructs the final result type after the
984+
/// AppendingExpr has been evaluated.
985+
void setResultInit(ConcreteDeclRef decl) { resultInit = decl; }
986+
ConcreteDeclRef getResultInit() const { return resultInit; }
987+
988+
/// Sets the OpaqueValueExpr that is passed into AppendingExpr as the SubExpr
989+
/// that the tap operates on.
990+
void setInterpolationExpr(OpaqueValueExpr *expr) { interpolationExpr = expr; }
991+
OpaqueValueExpr *getInterpolationExpr() const { return interpolationExpr; }
992+
993+
/// Store a builtin integer literal expr wrapping getInterpolationCount().
994+
/// This is an arg to builderInit.
995+
void setInterpolationCountExpr(Expr *expr) { interpolationCountExpr = expr; }
996+
Expr *getInterpolationCountExpr() const { return interpolationCountExpr; }
997+
998+
/// Store a builtin integer literal expr wrapping getLiteralCapacity().
999+
/// This is an arg to builderInit.
1000+
void setLiteralCapacityExpr(Expr *expr) { literalCapacityExpr = expr; }
1001+
Expr *getLiteralCapacityExpr() const { return literalCapacityExpr; }
1002+
9731003
/// Retrieve the value of the literalCapacity parameter to the
9741004
/// initializer.
9751005
unsigned getLiteralCapacity() const {
@@ -989,11 +1019,6 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
9891019
TapExpr * getAppendingExpr() const { return AppendingExpr; }
9901020
void setAppendingExpr(TapExpr * AE) { AppendingExpr = AE; }
9911021

992-
/// Retrieve the expression that actually evaluates the resulting
993-
/// string, typically with a series of '+' operations.
994-
Expr *getSemanticExpr() const { return SemanticExpr; }
995-
void setSemanticExpr(Expr *SE) { SemanticExpr = SE; }
996-
9971022
SourceLoc getStartLoc() const {
9981023
return Loc;
9991024
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ namespace detail {
113113

114114
/// Extract the first, nearest source location from a tuple.
115115
template<unsigned Index, typename ...Types,
116-
typename = typename std::enable_if<sizeof...(Types) - Index
117-
? true
118-
: false>::type>
116+
typename = typename std::enable_if<(Index < sizeof...(Types))>::type>
119117
SourceLoc extractNearestSourceLocTuple(const std::tuple<Types...> &value) {
120118
SourceLoc loc = maybeExtractNearestSourceLoc(std::get<Index>(value));
121119
if (loc.isValid())

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,13 +689,14 @@ class LazyStoragePropertyRequest :
689689
bool isCached() const { return true; }
690690
};
691691

692-
/// Request to type check the body of the given function.
692+
/// Request to type check the body of the given function up to the given
693+
/// source location.
693694
///
694695
/// Produces true if an error occurred, false otherwise.
695696
/// FIXME: it would be far better to return the type-checked body.
696-
class TypeCheckFunctionBodyRequest :
697-
public SimpleRequest<TypeCheckFunctionBodyRequest,
698-
bool(AbstractFunctionDecl *),
697+
class TypeCheckFunctionBodyUntilRequest :
698+
public SimpleRequest<TypeCheckFunctionBodyUntilRequest,
699+
bool(AbstractFunctionDecl *, SourceLoc),
699700
CacheKind::Cached> {
700701
public:
701702
using SimpleRequest::SimpleRequest;
@@ -705,7 +706,8 @@ class TypeCheckFunctionBodyRequest :
705706

706707
// Evaluation.
707708
llvm::Expected<bool>
708-
evaluate(Evaluator &evaluator, AbstractFunctionDecl *func) const;
709+
evaluate(Evaluator &evaluator, AbstractFunctionDecl *func,
710+
SourceLoc endTypeCheckLoc) const;
709711

710712
public:
711713
bool isCached() const { return true; }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ SWIFT_TYPEID(IsGetterMutatingRequest)
4040
SWIFT_TYPEID(IsSetterMutatingRequest)
4141
SWIFT_TYPEID(OpaqueReadOwnershipRequest)
4242
SWIFT_TYPEID(LazyStoragePropertyRequest)
43-
SWIFT_TYPEID(TypeCheckFunctionBodyRequest)
43+
SWIFT_TYPEID(TypeCheckFunctionBodyUntilRequest)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ class SourceLoc {
7878
}
7979

8080
void dump(const SourceManager &SM) const;
81+
82+
friend size_t hash_value(SourceLoc loc) {
83+
return reinterpret_cast<uintptr_t>(loc.getOpaquePointerValue());
84+
}
85+
86+
friend void simple_display(raw_ostream &OS, const SourceLoc &loc) {
87+
// Nothing meaningful to print.
88+
}
8189
};
8290

8391
/// SourceRange in swift is a pair of locations. However, note that the end

branches/rxwei-patch-1/include/swift/Driver/ToolChain.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <memory>
2525

2626
namespace swift {
27+
class DiagnosticEngine;
28+
2729
namespace driver {
2830
class CommandOutput;
2931
class Compilation;
@@ -302,6 +304,13 @@ class ToolChain {
302304
void addLinkRuntimeLib(const llvm::opt::ArgList &Args,
303305
llvm::opt::ArgStringList &Arguments,
304306
StringRef LibName) const;
307+
308+
/// Validates arguments passed to the toolchain.
309+
///
310+
/// An override point for platform-specific subclasses to customize the
311+
/// validations that should be performed.
312+
virtual void validateArguments(DiagnosticEngine &diags,
313+
const llvm::opt::ArgList &args) const {}
305314
};
306315
} // end namespace driver
307316
} // end namespace swift

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,9 +1949,13 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
19491949
PrintWithColorRAII(OS, LiteralValueColor)
19501950
<< " literal_capacity="
19511951
<< E->getLiteralCapacity() << " interpolation_count="
1952-
<< E->getInterpolationCount() << '\n';
1952+
<< E->getInterpolationCount();
1953+
PrintWithColorRAII(OS, LiteralValueColor) << " builder_init=";
1954+
E->getBuilderInit().dump(PrintWithColorRAII(OS, LiteralValueColor).getOS());
1955+
PrintWithColorRAII(OS, LiteralValueColor) << " result_init=";
1956+
E->getResultInit().dump(PrintWithColorRAII(OS, LiteralValueColor).getOS());
1957+
OS << "\n";
19531958
printRec(E->getAppendingExpr());
1954-
printSemanticExpr(E->getSemanticExpr());
19551959
PrintWithColorRAII(OS, ParenthesisColor) << ')';
19561960
}
19571961
void visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E) {
@@ -3772,4 +3776,4 @@ StringRef swift::getAccessorKindString(AccessorKind value) {
37723776
}
37733777

37743778
llvm_unreachable("Unhandled AccessorKind in switch.");
3775-
}
3779+
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,26 @@ class Verifier : public ASTWalker {
804804
OpaqueValues.erase(S->getElementExpr());
805805
}
806806

807+
bool shouldVerify(InterpolatedStringLiteralExpr *expr) {
808+
if (!shouldVerify(cast<Expr>(expr)))
809+
return false;
810+
811+
if (!expr->getInterpolationExpr())
812+
return true;
813+
814+
assert(!OpaqueValues.count(expr->getInterpolationExpr()));
815+
OpaqueValues[expr->getInterpolationExpr()] = 0;
816+
return true;
817+
}
818+
819+
void cleanup(InterpolatedStringLiteralExpr *expr) {
820+
if (!expr->getInterpolationExpr())
821+
return;
822+
823+
assert(OpaqueValues.count(expr->getInterpolationExpr()));
824+
OpaqueValues.erase(expr->getInterpolationExpr());
825+
}
826+
807827
bool shouldVerify(OpenExistentialExpr *expr) {
808828
if (!shouldVerify(cast<Expr>(expr)))
809829
return false;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
472472
}
473473

474474
Expr *visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E) {
475-
HANDLE_SEMANTIC_EXPR(E);
476-
477475
if (auto oldAppendingExpr = E->getAppendingExpr()) {
478476
if (auto appendingExpr = doIt(oldAppendingExpr))
479477
E->setAppendingExpr(dyn_cast<TapExpr>(appendingExpr));

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,6 +3775,14 @@ DestructorDecl *ClassDecl::getDestructor() {
37753775
return cast<DestructorDecl>(results.front());
37763776
}
37773777

3778+
/// Synthesizer callback for an empty implicit function body.
3779+
static std::pair<BraceStmt *, bool>
3780+
synthesizeEmptyFunctionBody(AbstractFunctionDecl *afd, void *context) {
3781+
ASTContext &ctx = afd->getASTContext();
3782+
return { BraceStmt::create(ctx, afd->getLoc(), { }, afd->getLoc(), true),
3783+
/*isTypeChecked=*/true };
3784+
}
3785+
37783786
void ClassDecl::addImplicitDestructor() {
37793787
if (hasDestructor() || isInvalid())
37803788
return;
@@ -3785,8 +3793,8 @@ void ClassDecl::addImplicitDestructor() {
37853793
DD->setImplicit();
37863794
DD->setValidationToChecked();
37873795

3788-
// Create an empty body for the destructor.
3789-
DD->setBody(BraceStmt::create(ctx, getLoc(), { }, getLoc(), true));
3796+
// Synthesize an empty body for the destructor as needed.
3797+
DD->setBodySynthesizer(synthesizeEmptyFunctionBody);
37903798
addMember(DD);
37913799

37923800
// Propagate access control and versioned-ness.

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,16 +2191,6 @@ void KeyPathExpr::Component::setSubscriptIndexHashableConformances(
21912191
void InterpolatedStringLiteralExpr::forEachSegment(ASTContext &Ctx,
21922192
llvm::function_ref<void(bool, CallExpr *)> callback) {
21932193
auto appendingExpr = getAppendingExpr();
2194-
if (SemanticExpr) {
2195-
SemanticExpr->forEachChildExpr([&](Expr *subExpr) -> Expr * {
2196-
if (auto tap = dyn_cast_or_null<TapExpr>(subExpr)) {
2197-
appendingExpr = tap;
2198-
return nullptr;
2199-
}
2200-
return subExpr;
2201-
});
2202-
}
2203-
22042194
for (auto stmt : appendingExpr->getBody()->getElements()) {
22052195
if (auto expr = stmt.dyn_cast<Expr*>()) {
22062196
if (auto call = dyn_cast<CallExpr>(expr)) {

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,14 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
17291729

17301730
/// Returns true if it is expected that the macro is ignored.
17311731
static bool shouldIgnoreMacro(StringRef name, const clang::MacroInfo *macro) {
1732-
// Ignore include guards.
1733-
if (macro->isUsedForHeaderGuard())
1734-
return true;
1732+
// Ignore include guards. Try not to ignore definitions of useful constants,
1733+
// which may end up looking like include guards.
1734+
if (macro->isUsedForHeaderGuard() && macro->getNumTokens() == 1) {
1735+
auto tok = macro->tokens()[0];
1736+
if (tok.isLiteral()
1737+
&& StringRef(tok.getLiteralData(), tok.getLength()) == "1")
1738+
return true;
1739+
}
17351740

17361741
// If there are no tokens, there is nothing to convert.
17371742
if (macro->tokens_empty())

branches/rxwei-patch-1/lib/Driver/DarwinToolChains.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "ToolChains.h"
1414

15+
#include "swift/AST/DiagnosticsDriver.h"
1516
#include "swift/Basic/Dwarf.h"
1617
#include "swift/Basic/LLVM.h"
1718
#include "swift/Basic/Platform.h"
@@ -442,13 +443,9 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
442443
}
443444
}
444445

445-
bool wantsStaticStdlib =
446-
context.Args.hasFlag(options::OPT_static_stdlib,
447-
options::OPT_no_static_stdlib, false);
448-
449446
SmallVector<std::string, 4> RuntimeLibPaths;
450447
getRuntimeLibraryPaths(RuntimeLibPaths, context.Args,
451-
context.OI.SDKPath, /*Shared=*/!wantsStaticStdlib);
448+
context.OI.SDKPath, /*Shared=*/true);
452449

453450
// Add the runtime library link path, which is platform-specific and found
454451
// relative to the compiler.
@@ -457,19 +454,11 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
457454
Arguments.push_back(context.Args.MakeArgString(path));
458455
}
459456

460-
// Link the standard library.
461-
if (wantsStaticStdlib) {
462-
Arguments.push_back("-lc++");
463-
Arguments.push_back("-framework");
464-
Arguments.push_back("Foundation");
465-
Arguments.push_back("-force_load_swift_libs");
466-
} else {
467-
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
468-
// of time the standard library won't be copied. SR-1967
469-
for (auto path : RuntimeLibPaths) {
470-
Arguments.push_back("-rpath");
471-
Arguments.push_back(context.Args.MakeArgString(path));
472-
}
457+
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
458+
// of time the standard library won't be copied. SR-1967
459+
for (auto path : RuntimeLibPaths) {
460+
Arguments.push_back("-rpath");
461+
Arguments.push_back(context.Args.MakeArgString(path));
473462
}
474463

475464
if (context.Args.hasArg(options::OPT_profile_generate)) {
@@ -595,3 +584,12 @@ bool toolchains::Darwin::shouldStoreInvocationInDebugInfo() const {
595584
return S[0] != '\0';
596585
return false;
597586
}
587+
588+
void
589+
toolchains::Darwin::validateArguments(DiagnosticEngine &diags,
590+
const llvm::opt::ArgList &args) const {
591+
// Validating darwin unsupported -static-stdlib argument.
592+
if (args.hasArg(options::OPT_static_stdlib)) {
593+
diags.diagnose(SourceLoc(), diag::error_darwin_static_stdlib_not_supported);
594+
}
595+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,11 @@ Driver::buildCompilation(const ToolChain &TC,
820820
std::unique_ptr<DerivedArgList> TranslatedArgList(
821821
translateInputAndPathArgs(*ArgList, workingDirectory));
822822

823+
// TODO: We should check which validations could be moved to toolchain specific classes.
823824
validateArgs(Diags, *TranslatedArgList);
825+
826+
// Perform toolchain specific args validation.
827+
TC.validateArguments(Diags, *TranslatedArgList);
824828

825829
if (Diags.hadAnyError())
826830
return nullptr;

0 commit comments

Comments
 (0)