Skip to content

Commit ba3ea73

Browse files
authored
---
yaml --- r: 314365 b: refs/heads/master c: 529d784 h: refs/heads/master i: 314363: d6e0eb2
1 parent 622c30f commit ba3ea73

File tree

8 files changed

+108
-157
lines changed

8 files changed

+108
-157
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5de7c6f33eaf3abffab97be2860bf9dee78c29a2
2+
refs/heads/master: 529d784329b56ab620bc36bf8465d54b1b4e17c2
33
refs/heads/master-next: 66a7e661ff8e88e2d4efab3e430197a7a941e352
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/Frontend/Frontend.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ class CompilerInvocation {
291291

292292
void setCodeCompletionFactory(CodeCompletionCallbacksFactory *Factory) {
293293
CodeCompletionFactory = Factory;
294+
disableASTScopeLookup();
295+
}
296+
297+
/// Called from lldb, see rdar://53971116
298+
void disableASTScopeLookup() {
299+
LangOpts.EnableASTScopeLookup = false;
294300
}
295301

296302
CodeCompletionCallbacksFactory *getCodeCompletionFactory() const {

trunk/include/swift/SIL/InstructionUtils.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -142,48 +142,6 @@ bool onlyUsedByAssignByWrapper(PartialApplyInst *PAI);
142142
void findClosuresForFunctionValue(SILValue V,
143143
TinyPtrVector<PartialApplyInst *> &results);
144144

145-
/// A utility class for evaluating whether a newly parsed or deserialized
146-
/// function has qualified or unqualified ownership.
147-
///
148-
/// The reason that we are using this is that we would like to avoid needing to
149-
/// add code to the SILParser or to the Serializer to support this temporary
150-
/// staging concept of a function having qualified or unqualified
151-
/// ownership. Once SemanticARC is complete, SILFunctions will always have
152-
/// qualified ownership, so the notion of an unqualified ownership function will
153-
/// no longer exist.
154-
///
155-
/// Thus we note that there are three sets of instructions in SIL from an
156-
/// ownership perspective:
157-
///
158-
/// a. ownership qualified instructions
159-
/// b. ownership unqualified instructions
160-
/// c. instructions that do not have ownership semantics (think literals,
161-
/// geps, etc).
162-
///
163-
/// The set of functions can be split into ownership qualified and ownership
164-
/// unqualified using the rules that:
165-
///
166-
/// a. a function can never contain both ownership qualified and ownership
167-
/// unqualified instructions.
168-
/// b. a function that contains only instructions without ownership semantics
169-
/// is considered ownership qualified.
170-
///
171-
/// Thus we can know when parsing/serializing what category of function we have
172-
/// and set the bit appropriately.
173-
class FunctionOwnershipEvaluator {
174-
NullablePtr<SILFunction> F;
175-
bool HasOwnershipQualifiedInstruction = false;
176-
177-
public:
178-
FunctionOwnershipEvaluator() {}
179-
FunctionOwnershipEvaluator(SILFunction *F) : F(F) {}
180-
void reset(SILFunction *NewF) {
181-
F = NewF;
182-
HasOwnershipQualifiedInstruction = false;
183-
}
184-
bool evaluate(SILInstruction *I);
185-
};
186-
187145
} // end namespace swift
188146

189147
#endif

trunk/lib/AST/ASTPrinter.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,22 +1344,21 @@ void PrintAST::printGenericSignature(const GenericSignature *genericSig,
13441344
// print everything
13451345
[&](const Requirement &) { return true; });
13461346
}
1347+
13471348
void PrintAST::printGenericSignature(
13481349
const GenericSignature *genericSig, unsigned flags,
13491350
llvm::function_ref<bool(const Requirement &)> filter) {
1351+
auto requirements = genericSig->getRequirements();
1352+
13501353
if (flags & InnermostOnly) {
13511354
auto genericParams = genericSig->getInnermostGenericParams();
1352-
unsigned depth = genericParams[0]->getDepth();
1353-
SmallVector<Requirement, 2> requirementsAtDepth;
1354-
getRequirementsAtDepth(genericSig, depth, requirementsAtDepth);
13551355

1356-
printSingleDepthOfGenericSignature(genericParams, requirementsAtDepth,
1357-
flags, filter);
1356+
printSingleDepthOfGenericSignature(genericParams, requirements, flags,
1357+
filter);
13581358
return;
13591359
}
13601360

13611361
auto genericParams = genericSig->getGenericParams();
1362-
auto requirements = genericSig->getRequirements();
13631362

13641363
if (!Options.PrintInSILBody) {
13651364
printSingleDepthOfGenericSignature(genericParams, requirements, flags,
@@ -1966,15 +1965,24 @@ void PrintAST::printMembers(ArrayRef<Decl *> members, bool needComma,
19661965
}
19671966

19681967
void PrintAST::printGenericDeclGenericParams(GenericContext *decl) {
1969-
if (decl->getGenericParams())
1968+
if (decl->isGeneric())
19701969
if (auto GenericSig = decl->getGenericSignature())
19711970
printGenericSignature(GenericSig, PrintParams | InnermostOnly);
19721971
}
19731972

19741973
void PrintAST::printGenericDeclGenericRequirements(GenericContext *decl) {
1975-
if (decl->getGenericParams())
1976-
if (auto GenericSig = decl->getGenericSignature())
1977-
printGenericSignature(GenericSig, PrintRequirements | InnermostOnly);
1974+
if (decl->isGeneric()) {
1975+
if (auto genericSig = decl->getGenericSignature()) {
1976+
auto *baseGenericSig = decl->getParent()
1977+
->getGenericSignatureOfContext();
1978+
printGenericSignature(genericSig, PrintRequirements,
1979+
[baseGenericSig](const Requirement &req) {
1980+
if (baseGenericSig)
1981+
return !baseGenericSig->isRequirementSatisfied(req);
1982+
return true;
1983+
});
1984+
}
1985+
}
19781986
}
19791987

19801988
void PrintAST::printInherited(const Decl *decl) {
@@ -2115,7 +2123,7 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
21152123
auto *baseGenericSig = decl->getExtendedNominal()->getGenericSignature();
21162124
assert(baseGenericSig &&
21172125
"an extension can't be generic if the base type isn't");
2118-
printGenericSignature(genericSig, PrintRequirements | InnermostOnly,
2126+
printGenericSignature(genericSig, PrintRequirements,
21192127
[baseGenericSig](const Requirement &req) -> bool {
21202128
// Only include constraints that are not satisfied by the base type.
21212129
return !baseGenericSig->isRequirementSatisfied(req);

trunk/lib/ParseSIL/ParseSIL.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ namespace {
229229
SILParserTUState &TUState;
230230
SILFunction *F = nullptr;
231231
GenericEnvironment *ContextGenericEnv = nullptr;
232-
FunctionOwnershipEvaluator OwnershipEvaluator;
233232

234233
private:
235234
/// HadError - Have we seen an error parsing this function?
@@ -5335,16 +5334,6 @@ bool SILParser::parseSILBasicBlock(SILBuilder &B) {
53355334
do {
53365335
if (parseSILInstruction(B))
53375336
return true;
5338-
// Evaluate how the just parsed instruction effects this functions Ownership
5339-
// Qualification. For more details, see the comment on the
5340-
// FunctionOwnershipEvaluator class.
5341-
SILInstruction *ParsedInst = &*BB->rbegin();
5342-
if (BB->getParent()->hasOwnership() &&
5343-
!OwnershipEvaluator.evaluate(ParsedInst)) {
5344-
P.diagnose(ParsedInst->getLoc().getSourceLoc(),
5345-
diag::found_unqualified_instruction_in_qualified_function,
5346-
F->getName());
5347-
}
53485337
} while (isStartOfSILInstruction());
53495338

53505339
return false;
@@ -5460,7 +5449,6 @@ bool SILParserTUState::parseDeclSIL(Parser &P) {
54605449
}
54615450

54625451
// Parse the basic block list.
5463-
FunctionState.OwnershipEvaluator.reset(FunctionState.F);
54645452
SILOpenedArchetypesTracker OpenedArchetypesTracker(FunctionState.F);
54655453
SILBuilder B(*FunctionState.F);
54665454
// Track the archetypes just like SILGen. This

trunk/lib/SIL/InstructionUtils.cpp

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -527,94 +527,3 @@ void swift::findClosuresForFunctionValue(
527527
// Ignore other unrecognized values that feed this applied argument.
528528
}
529529
}
530-
531-
namespace {
532-
533-
enum class OwnershipQualifiedKind {
534-
NotApplicable,
535-
Qualified,
536-
Unqualified,
537-
};
538-
539-
struct OwnershipQualifiedKindVisitor : SILInstructionVisitor<OwnershipQualifiedKindVisitor, OwnershipQualifiedKind> {
540-
541-
OwnershipQualifiedKind visitSILInstruction(SILInstruction *I) {
542-
return OwnershipQualifiedKind::NotApplicable;
543-
}
544-
545-
#define QUALIFIED_INST(CLASS) \
546-
OwnershipQualifiedKind visit ## CLASS(CLASS *I) { \
547-
return OwnershipQualifiedKind::Qualified; \
548-
}
549-
QUALIFIED_INST(EndBorrowInst)
550-
QUALIFIED_INST(LoadBorrowInst)
551-
QUALIFIED_INST(CopyValueInst)
552-
QUALIFIED_INST(DestroyValueInst)
553-
#define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE(Name, ...) \
554-
QUALIFIED_INST(Copy##Name##ValueInst)
555-
#include "swift/AST/ReferenceStorage.def"
556-
#undef QUALIFIED_INST
557-
558-
OwnershipQualifiedKind visitLoadInst(LoadInst *LI) {
559-
if (LI->getOwnershipQualifier() == LoadOwnershipQualifier::Unqualified)
560-
return OwnershipQualifiedKind::Unqualified;
561-
return OwnershipQualifiedKind::Qualified;
562-
}
563-
564-
OwnershipQualifiedKind visitStoreInst(StoreInst *SI) {
565-
if (SI->getOwnershipQualifier() == StoreOwnershipQualifier::Unqualified)
566-
return OwnershipQualifiedKind::Unqualified;
567-
return OwnershipQualifiedKind::Qualified;
568-
}
569-
};
570-
571-
} // end anonymous namespace
572-
573-
bool FunctionOwnershipEvaluator::evaluate(SILInstruction *I) {
574-
assert(I->getFunction() == F.get() && "Can not evaluate function ownership "
575-
"implications of an instruction that "
576-
"does not belong to the instruction "
577-
"that we are evaluating");
578-
579-
switch (OwnershipQualifiedKindVisitor().visit(I)) {
580-
case OwnershipQualifiedKind::Unqualified: {
581-
// If we already know that the function has unqualified ownership, just
582-
// return early.
583-
if (!F.get()->hasOwnership())
584-
return true;
585-
586-
// Ok, so we know at this point that we have qualified ownership. If we have
587-
// seen any instructions with qualified ownership, we have an error since
588-
// the function mixes qualified and unqualified instructions.
589-
if (HasOwnershipQualifiedInstruction)
590-
return false;
591-
592-
// Otherwise, set the function to have unqualified ownership. This will
593-
// ensure that no more Qualified instructions can be added to the given
594-
// function.
595-
F.get()->setOwnershipEliminated();
596-
return true;
597-
}
598-
case OwnershipQualifiedKind::Qualified: {
599-
// First check if our function has unqualified ownership. If we already do
600-
// have unqualified ownership, then we know that we have already seen an
601-
// unqualified ownership instruction. This means the function has both
602-
// qualified and unqualified instructions. =><=.
603-
if (!F.get()->hasOwnership())
604-
return false;
605-
606-
// Ok, at this point we know that we are still qualified. Since functions
607-
// start as qualified, we need to set the HasOwnershipQualifiedInstructions
608-
// so we do not need to look back through the function if we see an
609-
// unqualified instruction later on.
610-
HasOwnershipQualifiedInstruction = true;
611-
return true;
612-
}
613-
case OwnershipQualifiedKind::NotApplicable: {
614-
// Not Applicable instr
615-
return true;
616-
}
617-
}
618-
619-
llvm_unreachable("Unhandled OwnershipQualifiedKind in switch.");
620-
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -typecheck %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
4+
// RUN: %FileCheck %s < %t/main.swiftinterface
5+
6+
// RUN: %target-build-swift %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
7+
// RUN: %FileCheck %s < %t/main.swiftinterface
8+
9+
// RUN: %target-build-swift %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution -wmo
10+
// RUN: %FileCheck %s < %t/main.swiftinterface
11+
12+
// CHECK: import Swift
13+
14+
// CHECK: public struct Holder<Value> {
15+
public struct Holder<Value> {
16+
var value: Value
17+
18+
// CHECK-NEXT: public init(value: Value){{$}}
19+
public init(value: Value) {
20+
self.value = value
21+
}
22+
23+
// CHECK-NEXT: public init<T>(_ value: T) where Value == Swift.AnyHashable, T : Swift.Hashable{{$}}
24+
public init<T : Hashable>(_ value: T) where Value == AnyHashable {
25+
self.value = value
26+
}
27+
28+
// CHECK-NEXT: public struct Transform<Result> {
29+
public struct Transform<Result> {
30+
var fn: (Value) -> Result
31+
32+
// CHECK-NEXT: public init(fn: @escaping (Value) -> Result){{$}}
33+
public init(fn: @escaping (Value) -> Result) {
34+
self.fn = fn
35+
}
36+
37+
// CHECK-NEXT: func transform(_ holder: main.Holder<Value>) -> Result{{$}}
38+
public func transform(_ holder: Holder<Value>) -> Result {
39+
return fn(holder.value)
40+
}
41+
42+
// CHECK-NEXT: }
43+
}
44+
45+
// CHECK-NEXT: }
46+
}
47+
48+
// CHECK-NEXT: extension Holder.Transform where Value == Swift.Int {
49+
extension Holder.Transform where Value == Int {
50+
// CHECK-NEXT: public func negate(_ holder: main.Holder<Value>) -> Result{{$}}
51+
public func negate(_ holder: Holder<Value>) -> Result {
52+
return transform(Holder(value: -holder.value))
53+
}
54+
}

trunk/test/SILGen/synthesized_conformance_class.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ extension Nonfinal: Encodable where T: Encodable {}
6363
// CHECK-LABEL: // Nonfinal<A>.encode(to:)
6464
// CHECK-NEXT: sil hidden [ossa] @$s29synthesized_conformance_class8NonfinalCAASERzlE6encode2toys7Encoder_p_tKF : $@convention(method) <T where T : Encodable> (@in_guaranteed Encoder, @guaranteed Nonfinal<T>) -> @error Error {
6565

66+
final class FinalHashableClass : Hashable {
67+
static func ==(lhs: FinalHashableClass, rhs: FinalHashableClass) -> Bool {
68+
return false
69+
}
70+
71+
func hash(into: inout Hasher) {}
72+
}
73+
74+
// CHECK-LABEL: sil hidden [ossa] @$s29synthesized_conformance_class4doItySiAA18FinalHashableClassCF : $@convention(thin) (@guaranteed FinalHashableClass) -> Int {
75+
// CHECK: bb0(%0 : @guaranteed $FinalHashableClass):
76+
// CHECK: [[FN:%.*]] = function_ref @$s29synthesized_conformance_class18FinalHashableClassC9hashValueSivg : $@convention(method) (@guaranteed FinalHashableClass) -> Int
77+
// CHECK-NEXT: [[RESULT:%.*]] = apply [[FN]](%0) : $@convention(method) (@guaranteed FinalHashableClass) -> Int
78+
// CHECK-NEXT: return [[RESULT]] : $Int
79+
80+
func doIt(_ c: FinalHashableClass) -> Int {
81+
return c.hashValue
82+
}
83+
84+
// VTable for FinalHashableClass
85+
//
86+
// Note: we should not be emitting a vtable entry for the synthesized
87+
// FinalHashableClass.hashValue getter!
88+
89+
// CHECK: sil_vtable FinalHashableClass {
90+
// CHECK-NEXT: #FinalHashableClass.init!allocator.1: (FinalHashableClass.Type) -> () -> FinalHashableClass : @$s29synthesized_conformance_class18FinalHashableClassCACycfC
91+
// CHECK-NEXT: #FinalHashableClass.deinit!deallocator.1: @$s29synthesized_conformance_class18FinalHashableClassCfD
92+
// CHECK-NEXT: }
93+
6694
// Witness tables for Final
6795

6896
// CHECK-LABEL: sil_witness_table hidden <T where T : Encodable> Final<T>: Encodable module synthesized_conformance_class {

0 commit comments

Comments
 (0)