Skip to content

[swift-3.0-preview-1] stdlib: test improvements #4009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6160971
[utils] Add support for swift-3.0-branch
shahmishal Aug 3, 2016
9cf4f04
[noescape-by-default] Better diagnostics for parameters
milseman Aug 2, 2016
224613a
[noescape-by-default] Expand useful diagnostics to more cases
milseman Aug 2, 2016
cc98458
[noescape-by-default] incorporate Doug's feedback
milseman Aug 3, 2016
03415be
Merge pull request #3948 from milseman/3_0_noescape_by_default
tkremenek Aug 3, 2016
adfb6ec
Count tail-padding in the size of imported C types.
rjmccall Aug 2, 2016
daca860
[Driver] Make sure to rebuild dependents when a dirty file fails. (#3…
jrose-apple Aug 3, 2016
b8304d5
Fix test case for 32-bit systems.
rjmccall Aug 3, 2016
01eb46e
[Driver] Remove debugging code from 848b3eb.
jrose-apple Aug 3, 2016
fda6d4e
Add fast path for queue.async(flags: .barrier)
lilyball Aug 1, 2016
73b25c5
Use shims for all calls to Dispatch APIs that take blocks
lilyball Aug 1, 2016
ce0083a
Merge pull request #3962 from harlanhaskins/aristotelianism
tkremenek Aug 3, 2016
50068d8
This test is known to fail on a debug stdlib
aschwaighofer Aug 3, 2016
682b5e2
Merge pull request #3970 from aschwaighofer/swift-3.0-branch
tkremenek Aug 3, 2016
ad4e777
Eliminate race in swift_bridgeErrorToNSError.
DougGregor Aug 1, 2016
07e731d
Merge pull request #3955 from rjmccall/count-c-tail-padding-3.0
rjmccall Aug 3, 2016
122ad91
[sil-cloner] Always call doPreProcess when visiting SILInstructions.
swiftix Aug 3, 2016
f395524
[PrintAsObjC] Hack: Assume all option sets have typedefs. (#3961)
jrose-apple Aug 3, 2016
9ad7cbd
SpriteKit overlay: add a better variant of the SKWarpGeometryGrid() i…
gribozavr Aug 3, 2016
7878fed
SpriteKit overlay: fix a typo
gribozavr Aug 3, 2016
5738e1f
Merge pull request #3978 from swiftix/swift-3.0-branch
tkremenek Aug 4, 2016
fc5b4fe
Merge pull request #3975 from DougGregor/rdar-27541751-error-bridging…
DougGregor Aug 4, 2016
04b9f0d
Merge pull request #3957 from jrose-apple/swift-3.0-we-can-rebuild-them
tkremenek Aug 4, 2016
0fd1993
Merge pull request #3966 from apple/swift3-dispatch-overlay-blocks
tkremenek Aug 4, 2016
141c0f9
[SILGen] Use the 'Class' existential representation for NSError subcl…
DougGregor Aug 2, 2016
fe2f9ce
[NSError bridging] Use embedded NSError when erasing types to Error e…
DougGregor Aug 3, 2016
a0128f9
[NSError bridging] Extract embedded NSError from an Error consistently.
DougGregor Aug 3, 2016
60d0f47
[NSError bridging] Rename runtime entry points for _getErrorEmbeddedN…
DougGregor Aug 3, 2016
171a18c
[Runtime] Extract an embedded NSError when dynamic casting to an Erro…
DougGregor Aug 4, 2016
a1e2d4e
stdlib/Foundation: optimize the NSDictionary and NSSet copy-constructors
eeckstein Aug 3, 2016
b38dce8
Merge pull request #3984 from apple/swift3-spritekit-fixes
tkremenek Aug 4, 2016
7d2ee67
rdar://problem/27541751: Temporarily disable test.
DougGregor Aug 4, 2016
553c804
[Preset] SR-2232 Update preset to use build-swift-static-sdk-overlay
shahmishal Aug 3, 2016
967a1d4
Merge pull request #3976 from DougGregor/swift-3-nserror-wrapping
DougGregor Aug 4, 2016
e860c44
Merge pull request #3994 from apple/fix-SR-2232-swift-3.0-branch
shahmishal Aug 4, 2016
c8f3901
Merge pull request #3992 from apple/swift3-nsdictionary-nsset-optimiz…
tkremenek Aug 4, 2016
89a414d
Remove redundant tests for SpriteKit
gribozavr Aug 4, 2016
610dc14
stdlib: add tests for Stride types on integers
gribozavr Aug 4, 2016
593915a
StdlibCollectionUnittest: reduce boilerplate
gribozavr Aug 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class ASTContext {
PrecedenceGroupDecl *right) const;

/// Retrieve the declaration of Swift.Error.
NominalTypeDecl *getErrorDecl() const;
ProtocolDecl *getErrorDecl() const;
CanType getExceptionType() const;

/// Retrieve the declaration of Swift.Bool.
Expand Down
9 changes: 9 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,15 @@ ERROR(closure_noescape_use,none,
ERROR(decl_closure_noescape_use,none,
"declaration closing over non-escaping parameter %0 may allow it to escape",
(Identifier))
ERROR(passing_noescape_to_escaping,none,
"passing non-escaping parameter %0 to function expecting an @escaping closure",
(Identifier))
ERROR(assigning_noescape_to_escaping,none,
"assigning non-escaping parameter %0 to an @escaping closure",
(Identifier))
ERROR(general_noescape_to_escaping,none,
"using non-escaping parameter %0 in a context expecting an @escaping closure",
(Identifier))

ERROR(capture_across_type_decl,none,
"%0 declaration cannot close over value %1 defined in outer scope",
Expand Down
2 changes: 2 additions & 0 deletions include/swift/AST/KnownDecls.def
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ FUNC_DECL(BridgeAnythingToObjectiveC,
FUNC_DECL(DidEnterMain, "_stdlib_didEnterMain")
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")

FUNC_DECL(GetErrorEmbeddedNSError, "_stdlib_getErrorEmbeddedNSError")

#undef FUNC_DECL
11 changes: 8 additions & 3 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ class SILCloner : protected SILVisitor<ImplClass> {
SILBuilder &getBuilder() { return Builder; }

protected:
void beforeVisit(ValueBase *V) {
if (auto I = dyn_cast<SILInstruction>(V)) {
// Update the set of available opened archetypes with the opened
// archetypes used by the current instruction.
doPreProcess(I);
}
}

#define VALUE(CLASS, PARENT) \
void visit##CLASS(CLASS *I) { \
llvm_unreachable("SILCloner visiting non-instruction?"); \
Expand Down Expand Up @@ -380,9 +388,6 @@ SILCloner<ImplClass>::visitSILBasicBlock(SILBasicBlock* BB) {
SILFunction &F = getBuilder().getFunction();
// Iterate over and visit all instructions other than the terminator to clone.
for (auto I = BB->begin(), E = --BB->end(); I != E; ++I) {
// Update the set of available opened archetypes with the opened archetypes
// used by the current instruction.
doPreProcess(&*I);
asImpl().visit(&*I);
}
// Iterate over successors to do the depth-first search.
Expand Down
8 changes: 8 additions & 0 deletions include/swift/SIL/SILVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ class SILVisitor {
public:
ImplClass &asImpl() { return static_cast<ImplClass &>(*this); }

// Peform any required pre-processing before visiting.
// Sub-classes can override it to provide their custom
// pre-processing steps.
void beforeVisit(ValueBase *V) {
}

ValueRetTy visit(ValueBase *V) {
asImpl().beforeVisit(V);

switch (V->getKind()) {
#define VALUE(CLASS, PARENT) \
case ValueKind::CLASS: \
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ CanType ASTContext::getExceptionType() const {
}
}

NominalTypeDecl *ASTContext::getErrorDecl() const {
ProtocolDecl *ASTContext::getErrorDecl() const {
return getProtocol(KnownProtocolKind::Error);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,10 @@ namespace {
if (!result)
return nullptr;

// HACK: Make sure PrintAsObjC always omits the 'enum' tag for
// option set enums.
Impl.DeclsWithSuperfluousTypedefs.insert(decl);

enumeratorContext = result;
break;
}
Expand Down
100 changes: 67 additions & 33 deletions lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,69 @@ int Compilation::performJobsImpl() {
llvm::errs() << Output;
}

// In order to handle both old dependencies that have disappeared and new
// dependencies that have arisen, we need to reload the dependency file.
// Do this whether or not the build succeeded.
SmallVector<const Job *, 16> Dependents;
if (getIncrementalBuildEnabled()) {
const CommandOutput &Output = FinishedCmd->getOutput();
StringRef DependenciesFile =
Output.getAdditionalOutputForType(types::TY_SwiftDeps);
if (!DependenciesFile.empty() &&
(ReturnCode == EXIT_SUCCESS || ReturnCode == EXIT_FAILURE)) {
bool wasCascading = DepGraph.isMarked(FinishedCmd);

switch (DepGraph.loadFromPath(FinishedCmd, DependenciesFile)) {
case DependencyGraphImpl::LoadResult::HadError:
if (ReturnCode == EXIT_SUCCESS) {
disableIncrementalBuild();
for (const Job *Cmd : DeferredCommands)
scheduleCommandIfNecessaryAndPossible(Cmd);
DeferredCommands.clear();
Dependents.clear();
} // else, let the next build handle it.
break;
case DependencyGraphImpl::LoadResult::UpToDate:
if (!wasCascading)
break;
SWIFT_FALLTHROUGH;
case DependencyGraphImpl::LoadResult::AffectsDownstream:
DepGraph.markTransitive(Dependents, FinishedCmd);
break;
}
} else {
// If there's a crash, assume the worst.
switch (FinishedCmd->getCondition()) {
case Job::Condition::NewlyAdded:
// The job won't be treated as newly added next time. Conservatively
// mark it as affecting other jobs, because some of them may have
// completed already.
DepGraph.markTransitive(Dependents, FinishedCmd);
break;
case Job::Condition::Always:
// This applies to non-incremental tasks as well, but any incremental
// task that shows up here has already been marked.
break;
case Job::Condition::RunWithoutCascading:
// If this file changed, it might have been a non-cascading change and
// it might not. Unfortunately, the interface hash has been updated or
// compromised, so we don't actually know anymore; we have to
// conservatively assume the changes could affect other files.
DepGraph.markTransitive(Dependents, FinishedCmd);
break;
case Job::Condition::CheckDependencies:
// If the only reason we're running this is because something else
// changed, then we can trust the dependency graph as to whether it's
// a cascading or non-cascading change. That is, if whatever /caused/
// the error isn't supposed to affect other files, and whatever
// /fixes/ the error isn't supposed to affect other files, then
// there's no need to recompile any other inputs. If either of those
// are false, we /do/ need to recompile other inputs.
break;
}
}
}

if (ReturnCode != EXIT_SUCCESS) {
// The task failed, so return true without performing any further
// dependency analysis.
Expand All @@ -481,39 +544,10 @@ int Compilation::performJobsImpl() {
// might have been blocked.
markFinished(FinishedCmd);

// In order to handle both old dependencies that have disappeared and new
// dependencies that have arisen, we need to reload the dependency file.
if (getIncrementalBuildEnabled()) {
const CommandOutput &Output = FinishedCmd->getOutput();
StringRef DependenciesFile =
Output.getAdditionalOutputForType(types::TY_SwiftDeps);
if (!DependenciesFile.empty()) {
SmallVector<const Job *, 16> Dependents;
bool wasCascading = DepGraph.isMarked(FinishedCmd);

switch (DepGraph.loadFromPath(FinishedCmd, DependenciesFile)) {
case DependencyGraphImpl::LoadResult::HadError:
disableIncrementalBuild();
for (const Job *Cmd : DeferredCommands)
scheduleCommandIfNecessaryAndPossible(Cmd);
DeferredCommands.clear();
Dependents.clear();
break;
case DependencyGraphImpl::LoadResult::UpToDate:
if (!wasCascading)
break;
SWIFT_FALLTHROUGH;
case DependencyGraphImpl::LoadResult::AffectsDownstream:
DepGraph.markTransitive(Dependents, FinishedCmd);
break;
}

for (const Job *Cmd : Dependents) {
DeferredCommands.erase(Cmd);
noteBuilding(Cmd, "because of dependencies discovered later");
scheduleCommandIfNecessaryAndPossible(Cmd);
}
}
for (const Job *Cmd : Dependents) {
DeferredCommands.erase(Cmd);
noteBuilding(Cmd, "because of dependencies discovered later");
scheduleCommandIfNecessaryAndPossible(Cmd);
}

return TaskFinishedResponse::ContinueExecution;
Expand Down
54 changes: 29 additions & 25 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,36 +1604,40 @@ handleCompileJobCondition(Job *J, CompileJobAction::InputInfo inputInfo,
return;
}

if (!alwaysRebuildDependents) {
// Default all non-newly added files to being rebuilt without cascading.
J->setCondition(Job::Condition::RunWithoutCascading);
}

bool hasValidModTime = false;
llvm::sys::fs::file_status inputStatus;
if (llvm::sys::fs::status(input, inputStatus))
return;

J->setInputModTime(inputStatus.getLastModificationTime());
if (J->getInputModTime() != inputInfo.previousModTime)
return;
if (!llvm::sys::fs::status(input, inputStatus)) {
J->setInputModTime(inputStatus.getLastModificationTime());
hasValidModTime = true;
}

Job::Condition condition;
switch (inputInfo.status) {
case CompileJobAction::InputInfo::UpToDate:
if (!llvm::sys::fs::exists(J->getOutput().getPrimaryOutputFilename()))
if (!hasValidModTime || J->getInputModTime() != inputInfo.previousModTime) {
if (alwaysRebuildDependents ||
inputInfo.status == CompileJobAction::InputInfo::NeedsCascadingBuild) {
condition = Job::Condition::Always;
} else {
condition = Job::Condition::RunWithoutCascading;
else
condition = Job::Condition::CheckDependencies;
break;
case CompileJobAction::InputInfo::NeedsCascadingBuild:
condition = Job::Condition::Always;
break;
case CompileJobAction::InputInfo::NeedsNonCascadingBuild:
condition = Job::Condition::RunWithoutCascading;
break;
case CompileJobAction::InputInfo::NewlyAdded:
llvm_unreachable("handled above");
}
} else {
switch (inputInfo.status) {
case CompileJobAction::InputInfo::UpToDate:
if (!llvm::sys::fs::exists(J->getOutput().getPrimaryOutputFilename()))
condition = Job::Condition::RunWithoutCascading;
else
condition = Job::Condition::CheckDependencies;
break;
case CompileJobAction::InputInfo::NeedsCascadingBuild:
condition = Job::Condition::Always;
break;
case CompileJobAction::InputInfo::NeedsNonCascadingBuild:
condition = Job::Condition::RunWithoutCascading;
break;
case CompileJobAction::InputInfo::NewlyAdded:
llvm_unreachable("handled above");
}
}

J->setCondition(condition);
}

Expand Down
23 changes: 11 additions & 12 deletions lib/IRGen/GenStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ class ClangRecordLowering {
const clang::ASTContext &ClangContext;
const clang::ASTRecordLayout &ClangLayout;
const Size TotalStride;
Size TotalSize;
const Alignment TotalAlignment;
SpareBitVector SpareBits;

Expand All @@ -595,9 +594,8 @@ class ClangRecordLowering {
ClangDecl(clangDecl), ClangContext(clangDecl->getASTContext()),
ClangLayout(ClangContext.getASTRecordLayout(clangDecl)),
TotalStride(Size(ClangLayout.getSize().getQuantity())),
TotalSize(TotalStride),
TotalAlignment(Alignment(ClangLayout.getAlignment().getQuantity())) {
SpareBits.reserve(TotalSize.getValue() * 8);
SpareBits.reserve(TotalStride.getValue() * 8);
}

void collectRecordFields() {
Expand All @@ -606,25 +604,20 @@ class ClangRecordLowering {
} else {
collectStructFields();
}

// Lots of layout will get screwed up if our structure claims more
// storage than we allocated to it.
assert(NextOffset == TotalSize && NextOffset <= TotalStride);
assert(TotalSize.roundUpToAlignment(TotalAlignment) == TotalStride);
}

const TypeInfo *createTypeInfo(llvm::StructType *llvmType) {
llvmType->setBody(LLVMFields, /*packed*/ true);
return ClangRecordTypeInfo::create(FieldInfos, NextExplosionIndex,
llvmType, TotalSize,
llvmType, TotalStride,
std::move(SpareBits), TotalAlignment,
ClangDecl);
}

private:
/// Collect all the fields of a union.
void collectUnionFields() {
addOpaqueField(Size(0), TotalSize);
addOpaqueField(Size(0), TotalStride);
}

static bool isImportOfClangField(VarDecl *swiftField,
Expand Down Expand Up @@ -689,8 +682,14 @@ class ClangRecordLowering {

assert(sfi == sfe && "more Swift fields than there were Clang fields?");

// Treat this as the end of the value size.
TotalSize = NextOffset;
// We never take advantage of tail padding, because that would prevent
// us from passing the address of the object off to C, which is a pretty
// likely scenario for imported C types.
assert(NextOffset <= TotalStride);
assert(SpareBits.size() <= TotalStride.getValueInBits());
if (NextOffset < TotalStride) {
addPaddingField(TotalStride);
}
}

/// Place the next struct field at its appropriate offset.
Expand Down
6 changes: 5 additions & 1 deletion lib/PrintAsObjC/PrintAsObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ static StringRef getNameForObjC(const ValueDecl *VD,
if (customNamesOnly)
return StringRef();

if (auto clangDecl = dyn_cast_or_null<clang::NamedDecl>(VD->getClangDecl()))
if (auto clangDecl = dyn_cast_or_null<clang::NamedDecl>(VD->getClangDecl())) {
if (const clang::IdentifierInfo *II = clangDecl->getIdentifier())
return II->getName();
if (auto *anonDecl = dyn_cast<clang::TagDecl>(clangDecl))
if (auto *anonTypedef = anonDecl->getTypedefNameForAnonDecl())
return anonTypedef->getIdentifier()->getName();
}

return VD->getName().str();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/SIL/SILType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ static bool isBridgedErrorClass(SILModule &M,
t = archetypeType->getSuperclass();

// NSError (TODO: and CFError) can be bridged.
auto errorType = M.Types.getNSErrorType();
if (t && errorType && t->isEqual(errorType)) {
auto nsErrorType = M.Types.getNSErrorType();
if (t && nsErrorType && nsErrorType->isExactSuperclassOf(t, nullptr)) {
return true;
}

Expand Down
Loading