Skip to content

Commit 5d9e704

Browse files
committed
SILGen: Move BlackHoleInitialization to Initialization.h
1 parent a2ca44b commit 5d9e704

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

lib/SILGen/Initialization.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,39 @@ class TupleInitialization : public Initialization {
307307
void finishUninitialized(SILGenFunction &SGF) override;
308308
};
309309

310+
/// A "null" initialization that indicates that any value being initialized
311+
/// into this initialization should be discarded. This represents AnyPatterns
312+
/// (that is, 'var (_)') that bind to values without storing them.
313+
class BlackHoleInitialization : public Initialization {
314+
public:
315+
BlackHoleInitialization() {}
316+
317+
bool canSplitIntoTupleElements() const override {
318+
return true;
319+
}
320+
321+
MutableArrayRef<InitializationPtr>
322+
splitIntoTupleElements(SILGenFunction &SGF, SILLocation loc,
323+
CanType type,
324+
SmallVectorImpl<InitializationPtr> &buf) override {
325+
// "Destructure" an ignored binding into multiple ignored bindings.
326+
for (auto fieldType : cast<TupleType>(type)->getElementTypes()) {
327+
(void) fieldType;
328+
buf.push_back(InitializationPtr(new BlackHoleInitialization()));
329+
}
330+
return buf;
331+
}
332+
333+
void copyOrInitValueInto(SILGenFunction &SGF, SILLocation loc,
334+
ManagedValue value, bool isInit) override {
335+
/// This just ignores the provided value.
336+
}
337+
338+
void finishUninitialized(SILGenFunction &SGF) override {
339+
// do nothing
340+
}
341+
};
342+
310343
} // end namespace Lowering
311344
} // end namespace swift
312345

lib/SILGen/SILGenDecl.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,6 @@ using namespace Lowering;
3939
void Initialization::_anchor() {}
4040
void SILDebuggerClient::anchor() {}
4141

42-
namespace {
43-
/// A "null" initialization that indicates that any value being initialized
44-
/// into this initialization should be discarded. This represents AnyPatterns
45-
/// (that is, 'var (_)') that bind to values without storing them.
46-
class BlackHoleInitialization : public Initialization {
47-
public:
48-
BlackHoleInitialization() {}
49-
50-
bool canSplitIntoTupleElements() const override {
51-
return true;
52-
}
53-
54-
MutableArrayRef<InitializationPtr>
55-
splitIntoTupleElements(SILGenFunction &SGF, SILLocation loc,
56-
CanType type,
57-
SmallVectorImpl<InitializationPtr> &buf) override {
58-
// "Destructure" an ignored binding into multiple ignored bindings.
59-
for (auto fieldType : cast<TupleType>(type)->getElementTypes()) {
60-
(void) fieldType;
61-
buf.push_back(InitializationPtr(new BlackHoleInitialization()));
62-
}
63-
return buf;
64-
}
65-
66-
void copyOrInitValueInto(SILGenFunction &SGF, SILLocation loc,
67-
ManagedValue value, bool isInit) override {
68-
/// This just ignores the provided value.
69-
}
70-
71-
void finishUninitialized(SILGenFunction &SGF) override {
72-
// do nothing
73-
}
74-
};
75-
} // end anonymous namespace
76-
7742
static void copyOrInitValueIntoHelper(
7843
SILGenFunction &SGF, SILLocation loc, ManagedValue value, bool isInit,
7944
ArrayRef<InitializationPtr> subInitializations,

0 commit comments

Comments
 (0)