Skip to content

[Sema] Fix errors due to implicitly deleted copy constructor. #292

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 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f4e946c
[Sema] Fix errors due to implicitly deleted copy constructor.
dcci Dec 7, 2015
9211c7c
Better diagnose error coming from unwrapping optional before initiali…
gregomni Dec 11, 2015
e799d3e
Fix typos
jutaz Dec 11, 2015
37840db
cmark c flags should derive from cmark build type
halfnelson Dec 11, 2015
7730b49
Update README.md
djwbrown Dec 11, 2015
4dad7c7
Update getting started instructions
garriguv Dec 11, 2015
43e4f17
Merge pull request #427 from djwbrown/djwbrown-swift-readme
gribozavr Dec 11, 2015
dfe1544
Merge pull request #433 from nuts23/patch-1
gribozavr Dec 11, 2015
c15e2a3
Merge pull request #429 from garriguv/readme-clone-typo
gribozavr Dec 11, 2015
3a9c52b
Merge pull request #422 from halfnelson/patch-1
gribozavr Dec 11, 2015
2adabe5
IRGen: Fix incorrect conditional in multi-payload destructiveInjectEn…
slavapestov Dec 11, 2015
0269e02
Sema: Fix assertion failure if EnumElementPattern is re-typechecked
slavapestov Dec 11, 2015
c31b209
Interpreter tests for resilient enums
slavapestov Dec 11, 2015
832a637
SIL: Start cleaning up getMethodDispatch() / requiresObjCDispatch()
slavapestov Dec 11, 2015
f6e4355
Sema: Fix monthly TypeNullifier bug
slavapestov Dec 11, 2015
3e94baa
Merge pull request #380 from jutaz/bugfix/typos-take-3
benlangmuir Dec 11, 2015
2a34a62
Fix some compiler_crashers that regressed recently
slavapestov Dec 11, 2015
fb9f564
[StackPromotion] fix the declaration of swift_buffer[De]AllocateOnStack.
eeckstein Dec 11, 2015
94d2c2f
Remove a wrong TODO comment.
eeckstein Dec 11, 2015
cdaff82
Merge pull request #418 from gregomni/sr-184
slavapestov Dec 11, 2015
689db17
Resurrect call-graph dot viewing.
eeckstein Dec 11, 2015
8bd49d6
Merge branch 'master' of https://github.com/dcci/swift
dcci Dec 11, 2015
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
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ Latest
@_silgen_name("foo") @objc
```

The `,` was vestigial when the attribute syntax consisted of bracked lists.
The `,` was vestigial when the attribute syntax consisted of bracket lists.

* `switch` now always requires a statement after a `case` or `default`.

Expand Down Expand Up @@ -3190,7 +3190,7 @@ Latest
```

* The compiler now warns about cases where a variable is inferred to have
`AnyObject`, `AnyClass`, or `()` type, since type inferrence can turn a simple
`AnyObject`, `AnyClass`, or `()` type, since type inference can turn a simple
mistake (e.g. failing to cast an `AnyObject` when you meant to) into something
with ripple effects. Here is a simple example:

Expand Down Expand Up @@ -3386,7 +3386,7 @@ Latest
`#if` block.

Target configurations are tested against their values via a pseudo-function
invocation expression, taking a single argument expressed as an identitifer.
invocation expression, taking a single argument expressed as an identifier.
The argument represents certain static build-time information.

There are currently two supported target configurations:
Expand Down Expand Up @@ -4830,7 +4830,7 @@ Latest
```

checks whether `object` has a value and, if so, asks for the length of
its title. `titleLength` wil have type `Int?`, and if `object` was
its title. `titleLength` will have type `Int?`, and if `object` was
missing, the variable will be initialized to None.

* Objects with type `id` can now be used as the receiver of property
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ uploading SSH keys to GitHub):

git clone [email protected]:apple/swift.git
cd swift
./utils/update-checkout --clone-via-ssh
./utils/update-checkout --clone-with-ssh

[CMake](http://cmake.org) is the core infrastructure used to configure builds of
Swift and its companion projects; at least version 2.8.12.2 is required. Your
Expand Down
4 changes: 2 additions & 2 deletions docs/doxygen.css
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ HR { height: 1px;

/*
* LLVM Modifications.
* Note: Everything above here is generated with "doxygen -w htlm" command. See
* "doxygen --help" for details. What follows are CSS overrides for LLVM
* Note: Everything above here is generated with "doxygen -w html" command. See
* "doxygen --help" for details. What follows are CSS overrides for LLVM
* specific formatting. We want to keep the above so it can be replaced with
* subsequent doxygen upgrades.
*/
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ class EnumElementPattern : public Pattern {
}
SourceRange getSourceRange() const { return {getStartLoc(), getEndLoc()}; }

TypeLoc &getParentType() { return ParentType; }
TypeLoc getParentType() const { return ParentType; }

static bool classof(const Pattern *P) {
Expand Down
17 changes: 17 additions & 0 deletions include/swift/SIL/SILDeclRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ namespace swift {
class SILLocation;
class AnyFunctionRef;

/// How a method is dispatched.
enum class MethodDispatch {
// The method implementation can be referenced statically.
Static,
// The method implementation uses class_method dispatch.
Class,
};

/// Get the method dispatch mechanism for a method.
MethodDispatch getMethodDispatch(AbstractFunctionDecl *method);

/// True if calling the given method or property should use ObjC dispatch.
bool requiresObjCDispatch(ValueDecl *vd);

/// True if the entry point is natively foreign.
bool requiresForeignToNativeThunk(ValueDecl *vd);

enum ForDefinition_t : bool {
NotForDefinition = false,
ForDefinition = true
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ class ApplyInst : public ApplyInstBase<ApplyInst, SILInstruction> {
return V->getKind() == ValueKind::ApplyInst;
}

/// Returns true if the called function has an error result but is not actully
/// Returns true if the called function has an error result but is not actually
/// throwing an error.
bool isNonThrowing() const {
return isNonThrowingApply();
Expand Down
5 changes: 5 additions & 0 deletions include/swift/SILPasses/PassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ class SILPassManager {
/// if the pass manager requested to stop the execution
/// of the optimization cycle (this is a debug feature).
bool runFunctionPasses(PassList FuncTransforms);

/// Displays the call graph in an external dot-viewer.
/// This function is meant for use from the debugger.
/// When asserts are disabled, this is a NoOp.
void viewCallGraph();
};

} // end namespace swift
Expand Down
1 change: 1 addition & 0 deletions include/swift/Sema/TypeCheckRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TypeCheckRequest {
/// The payload of the request, which differs based on the request kind.
union PayloadType {
PayloadType() { }
PayloadType(const PayloadType &) {}

#define TYPE_CHECK_REQUEST_PAYLOAD(PayloadName,...) \
__VA_ARGS__ PayloadName;
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ArchetypeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ bool ArchetypeBuilder::addSameTypeRequirementBetweenArchetypes(
T1 = T1->getRepresentative();
T2 = T2->getRepresentative();

// If the representives are already the same, we're done.
// If the representatives are already the same, we're done.
if (T1 == T2)
return false;

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ConformanceLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ ConformanceLookupTable::Ordering ConformanceLookupTable::compareConformances(
bool &diagnoseSuperseded) {
// If one entry is fixed and the other is not, we have our answer.
if (lhs->isFixed() != rhs->isFixed()) {
// If the non-fixed conformance is not replacable, we have a failure to
// If the non-fixed conformance is not replaceable, we have a failure to
// diagnose.
diagnoseSuperseded = (lhs->isFixed() &&
!isReplaceable(rhs->getRankingKind())) ||
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ struct ASTNodeBase {};
return false;

// We should know about archetypes corresponding to opened
// existerntial archetypes.
// existential archetypes.
if (archetype->getOpenedExistentialType()) {
if (OpenedExistentialArchetypes.count(archetype) == 0) {
Out << "Found opened existential archetype "
Expand Down
25 changes: 13 additions & 12 deletions lib/IRGen/GenEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4068,29 +4068,30 @@ namespace {
return storeDynamicTag(IGF, enumAddr, tag, T);
}

auto &C = IGF.IGM.getLLVMContext();
auto payloadBB = llvm::BasicBlock::Create(C);
auto noPayloadBB = llvm::BasicBlock::Create(C);
auto endBB = llvm::BasicBlock::Create(C);

// If there are no empty cases, don't need a conditional.
if (ElementsWithNoPayload.empty()) {
storePayloadTag(IGF, enumAddr, tag, T);
return;
}

auto &C = IGF.IGM.getLLVMContext();
auto noPayloadBB = llvm::BasicBlock::Create(C);
auto payloadBB = llvm::BasicBlock::Create(C);
auto endBB = llvm::BasicBlock::Create(C);

llvm::Value *numPayloadCases =
llvm::ConstantInt::get(IGF.IGM.Int32Ty,
ElementsWithPayload.size());
llvm::Value *cond = IGF.Builder.CreateICmpULE(tag, numPayloadCases);
IGF.Builder.CreateCondBr(cond, payloadBB, noPayloadBB);
llvm::Value *cond = IGF.Builder.CreateICmpUGE(tag, numPayloadCases);
IGF.Builder.CreateCondBr(cond, noPayloadBB, payloadBB);

IGF.Builder.emitBlock(payloadBB);
storePayloadTag(IGF, enumAddr, tag, T);
IGF.Builder.emitBlock(noPayloadBB);
llvm::Value *noPayloadTag = IGF.Builder.CreateSub(tag, numPayloadCases);
storeNoPayloadTag(IGF, enumAddr, noPayloadTag, T);
IGF.Builder.CreateBr(endBB);

IGF.Builder.emitBlock(noPayloadBB);
tag = IGF.Builder.CreateSub(tag, numPayloadCases);
storeNoPayloadTag(IGF, enumAddr, tag, T);
IGF.Builder.emitBlock(payloadBB);
storePayloadTag(IGF, enumAddr, tag, T);
IGF.Builder.CreateBr(endBB);

IGF.Builder.emitBlock(endBB);
Expand Down
87 changes: 80 additions & 7 deletions lib/SIL/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,85 @@
#include "clang/AST/DeclObjC.h"
using namespace swift;

/// Get the method dispatch mechanism for a method.
MethodDispatch
swift::getMethodDispatch(AbstractFunctionDecl *method) {
// Final methods can be statically referenced.
if (method->isFinal())
return MethodDispatch::Static;
// Some methods are forced to be statically dispatched.
if (method->hasForcedStaticDispatch())
return MethodDispatch::Static;

// If this declaration is in a class but not marked final, then it is
// always dynamically dispatched.
auto dc = method->getDeclContext();
if (isa<ClassDecl>(dc))
return MethodDispatch::Class;

// Class extension methods are only dynamically dispatched if they're
// dispatched by objc_msgSend, which happens if they're foreign or dynamic.
if (dc->isClassOrClassExtensionContext()) {
if (method->hasClangNode())
return MethodDispatch::Class;
if (auto fd = dyn_cast<FuncDecl>(method)) {
if (fd->isAccessor() && fd->getAccessorStorageDecl()->hasClangNode())
return MethodDispatch::Class;
}
if (method->getAttrs().hasAttribute<DynamicAttr>())
return MethodDispatch::Class;
}

// Otherwise, it can be referenced statically.
return MethodDispatch::Static;
}

bool swift::requiresForeignToNativeThunk(ValueDecl *vd) {
// Functions imported from C, Objective-C methods imported from Objective-C,
// as well as methods in @objc protocols (even protocols defined in Swift)
// require a foreign to native thunk.
auto dc = vd->getDeclContext();
if (auto proto = dyn_cast<ProtocolDecl>(dc))
if (proto->isObjC())
return true;

if (auto fd = dyn_cast<FuncDecl>(vd))
return fd->hasClangNode();

return false;
}

/// FIXME: merge requiresObjCDispatch() into getMethodDispatch() and add
/// an ObjectiveC case to the MethodDispatch enum.
bool swift::requiresObjCDispatch(ValueDecl *vd) {
// Final functions never require ObjC dispatch.
if (vd->isFinal())
return false;

if (requiresForeignToNativeThunk(vd))
return true;

if (auto *fd = dyn_cast<FuncDecl>(vd)) {
// Property accessors should be generated alongside the property.
if (fd->isGetterOrSetter())
return requiresObjCDispatch(fd->getAccessorStorageDecl());

return fd->getAttrs().hasAttribute<DynamicAttr>();
}

if (auto *cd = dyn_cast<ConstructorDecl>(vd)) {
if (cd->hasClangNode())
return true;

return cd->getAttrs().hasAttribute<DynamicAttr>();
}

if (auto *asd = dyn_cast<AbstractStorageDecl>(vd))
return asd->requiresObjCGetterAndSetter();

return vd->getAttrs().hasAttribute<DynamicAttr>();
}

static unsigned getFuncNaturalUncurryLevel(AnyFunctionRef AFR) {
assert(AFR.getBodyParamPatterns().size() >= 1 && "no arguments for func?!");
unsigned Level = AFR.getBodyParamPatterns().size() - 1;
Expand Down Expand Up @@ -338,14 +417,8 @@ bool SILDeclRef::isForeignToNativeThunk() const {
// have a foreign-to-native thunk.
if (!hasDecl())
return false;
// Otherwise, match whether we have a clang node with whether we're foreign.
if (isa<FuncDecl>(getDecl()) && getDecl()->hasClangNode())
if (requiresForeignToNativeThunk(getDecl()))
return !isForeign;
// Objective-C protocol methods also require a foreign to native thunk.
auto dc = getDecl()->getDeclContext();
if (auto proto = dyn_cast<ProtocolDecl>(dc))
if (proto->isObjC())
return !isForeign;
// ObjC initializing constructors and factories are foreign.
// We emit a special native allocating constructor though.
if (isa<ConstructorDecl>(getDecl())
Expand Down
7 changes: 0 additions & 7 deletions lib/SILGen/SILGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
/// True if the given constructor requires an entry point for ObjC method
/// dispatch.
bool requiresObjCMethodEntryPoint(ConstructorDecl *constructor);

/// True if calling the given method or property should use ObjC dispatch.
bool requiresObjCDispatch(ValueDecl *vd);

/// True if super-calling the given method from a subclass should use ObjC
/// dispatch.
bool requiresObjCSuperDispatch(ValueDecl *vd);

/// Emit a global initialization.
void emitGlobalInitialization(PatternBindingDecl *initializer, unsigned elt);
Expand Down
Loading