Skip to content

Commit afef236

Browse files
authored
---
yaml --- r: 349308 b: refs/heads/master-next c: 75670c1 h: refs/heads/master
1 parent ad99acf commit afef236

34 files changed

+739
-340
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 5a8d0744c3284f934f5d8797e149ec24745ee42c
3+
refs/heads/master-next: 75670c17272a993ed798cee7e31c20590e94118b
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/AST/Decl.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,11 @@ class ExtensionDecl final : public GenericContext, public Decl,
16781678
TypeRepr *ExtendedTypeRepr;
16791679

16801680
/// The nominal type being extended.
1681-
NominalTypeDecl *ExtendedNominal = nullptr;
1681+
///
1682+
/// The bit indicates whether binding has been attempted. The pointer can be
1683+
/// null if either no binding was attempted or if binding could not find the
1684+
/// extended nominal.
1685+
llvm::PointerIntPair<NominalTypeDecl *, 1, bool> ExtendedNominal;
16821686

16831687
MutableArrayRef<TypeLoc> Inherited;
16841688

@@ -1738,6 +1742,12 @@ class ExtensionDecl final : public GenericContext, public Decl,
17381742
SourceRange getBraces() const { return Braces; }
17391743
void setBraces(SourceRange braces) { Braces = braces; }
17401744

1745+
bool hasBeenBound() const { return ExtendedNominal.getInt(); }
1746+
1747+
void setExtendedNominal(NominalTypeDecl *n) {
1748+
ExtendedNominal.setPointerAndInt(n, true);
1749+
}
1750+
17411751
/// Retrieve the type being extended.
17421752
///
17431753
/// Only use this entry point when the complete type, as spelled in the source,
@@ -1746,8 +1756,21 @@ class ExtensionDecl final : public GenericContext, public Decl,
17461756
Type getExtendedType() const;
17471757

17481758
/// Retrieve the nominal type declaration that is being extended.
1759+
/// Will trip an assertion if the declaration has not already been computed.
1760+
/// In order to fail fast when type checking work is attempted
1761+
/// before extension binding has taken place.
1762+
17491763
NominalTypeDecl *getExtendedNominal() const;
17501764

1765+
/// Compute the nominal type declaration that is being extended.
1766+
NominalTypeDecl *computeExtendedNominal() const;
1767+
1768+
/// \c hasBeenBound means nothing if this extension can never been bound
1769+
/// because it is not at the top level.
1770+
bool canNeverBeBound() const;
1771+
1772+
bool hasValidParent() const;
1773+
17511774
/// Determine whether this extension has already been bound to a nominal
17521775
/// type declaration.
17531776
bool alreadyBoundToNominal() const { return NextExtension.getInt(); }

branches/master-next/include/swift/AST/DeclContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
470470
/// AnyObject dynamic lookup.
471471
bool mayContainMembersAccessedByDynamicLookup() const;
472472

473+
/// Extensions are only allowed at the level in a file
474+
/// FIXME: do this for Protocols, too someday
475+
bool canBeParentOfExtension() const;
476+
473477
/// Returns true if lookups within this context could affect downstream files.
474478
///
475479
/// \param functionsAreNonCascading If true, functions are considered non-

branches/master-next/include/swift/Basic/ExternalUnion.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,27 +433,27 @@ struct MembersHelper<> {
433433

434434
LLVM_ATTRIBUTE_ALWAYS_INLINE
435435
static void copyConstruct(void *self, int index, const void *other) {
436-
llvm_unreachable("bad index");
436+
assert(false && "bad index");
437437
}
438438

439439
LLVM_ATTRIBUTE_ALWAYS_INLINE
440440
static void moveConstruct(void *self, int index, void *other) {
441-
llvm_unreachable("bad index");
441+
assert(false && "bad index");
442442
}
443443

444444
LLVM_ATTRIBUTE_ALWAYS_INLINE
445445
static void copyAssignSame(int index, void *self, const void *other) {
446-
llvm_unreachable("bad index");
446+
assert(false && "bad index");
447447
}
448448

449449
LLVM_ATTRIBUTE_ALWAYS_INLINE
450450
static void moveAssignSame(int index, void *self, void *other) {
451-
llvm_unreachable("bad index");
451+
assert(false && "bad index");
452452
}
453453

454454
LLVM_ATTRIBUTE_ALWAYS_INLINE
455455
static void destruct(int index, void *self) {
456-
llvm_unreachable("bad index");
456+
assert(false && "bad index");
457457
}
458458
};
459459

branches/master-next/include/swift/Reflection/ReflectionContext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,17 @@ class ReflectionContext
608608
auto CDAddr = this->readCaptureDescriptorFromMetadata(*MetadataAddress);
609609
if (!CDAddr)
610610
return nullptr;
611+
if (!CDAddr->isResolved())
612+
return nullptr;
611613

612614
// FIXME: Non-generic SIL boxes also use the HeapLocalVariable metadata
613615
// kind, but with a null capture descriptor right now (see
614616
// FixedBoxTypeInfoBase::allocate).
615617
//
616618
// Non-generic SIL boxes share metadata among types with compatible
617619
// layout, but we need some way to get an outgoing pointer map for them.
618-
auto CD = getBuilder().getCaptureDescriptor(*CDAddr);
620+
auto CD = getBuilder().getCaptureDescriptor(
621+
CDAddr->getResolvedAddress().getAddressData());
619622
if (CD == nullptr)
620623
return nullptr;
621624

branches/master-next/include/swift/Remote/MemoryReader.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MemoryReader {
6969
/// NOTE: subclasses MUST override at least one of the readBytes functions. The default
7070
/// implementation calls through to the other one.
7171
virtual ReadBytesResult
72-
readBytes(RemoteAddress address, uint64_t size) {
72+
readBytes(RemoteAddress address, uint64_t size) {
7373
auto *Buf = malloc(size);
7474
ReadBytesResult Result(Buf, [](const void *ptr) {
7575
free(const_cast<void *>(ptr));
@@ -96,6 +96,34 @@ class MemoryReader {
9696
memcpy(dest, Ptr.get(), size);
9797
return true;
9898
}
99+
100+
/// Attempts to resolve a pointer value read from the given remote address.
101+
virtual RemoteAbsolutePointer resolvePointer(RemoteAddress address,
102+
uint64_t readValue) {
103+
// Default implementation returns the read value as is.
104+
return RemoteAbsolutePointer("", readValue);
105+
}
106+
107+
/// Attempt to read and resolve a pointer value at the given remote address.
108+
llvm::Optional<RemoteAbsolutePointer> readPointer(RemoteAddress address,
109+
unsigned pointerSize) {
110+
auto result = readBytes(address, pointerSize);
111+
if (!result)
112+
return llvm::None;
113+
114+
uint64_t pointerData;
115+
if (pointerSize == 4) {
116+
uint32_t theData;
117+
memcpy(&theData, result.get(), 4);
118+
pointerData = theData;
119+
} else if (pointerSize == 8) {
120+
memcpy(&pointerData, result.get(), 8);
121+
} else {
122+
return llvm::None;
123+
}
124+
125+
return resolvePointer(address, pointerData);
126+
}
99127

100128
virtual ~MemoryReader() = default;
101129
};

0 commit comments

Comments
 (0)