Skip to content

Commit 3ab6604

Browse files
committed
[gardening] Add more comprehensive comments to SILSuccessor.h.
This just makes it clearer what this class really does and also makes it clear that this is really representing a CFGEdge more than a specific successor. I may rename it to SILCFGEdge at some point to make the name match its usage.
1 parent e44bcca commit 3ab6604

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

include/swift/SIL/SILSuccessor.h

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,42 @@
1818
#include <iterator>
1919

2020
namespace swift {
21+
2122
class SILBasicBlock;
2223
class TermInst;
2324

24-
/// SILSuccessor - This represents a reference to a SILBasicBlock in a
25-
/// terminator instruction, forming a list of TermInst references to
26-
/// BasicBlocks. This forms the predecessor list, ensuring that it is always
27-
/// kept up to date.
25+
/// \brief An edge in the control flow graph.
26+
///
27+
/// A SILSuccessor is stored in the terminator instruction of the tail block of
28+
/// the CFG edge. Internally it has a back reference to the terminator that
29+
/// contains it (ContainingInst). It also contains the SuccessorBlock that is
30+
/// the "head" of the CFG edge. This makes it very simple to iterate over the
31+
/// successors of a specific block.
32+
///
33+
/// SILSuccessor also enables given a "head" edge the ability to iterate over
34+
/// predecessors. This is done by using an ilist that is embedded into
35+
/// SILSuccessors.
2836
class SILSuccessor {
2937
friend class SILSuccessorIterator;
30-
/// ContainingInst - This is the Terminator instruction that contains this
31-
/// successor.
38+
39+
/// The terminator instruction that contains this SILSuccessor.
3240
TermInst *ContainingInst = nullptr;
3341

34-
/// SuccessorBlock - If non-null, this is the BasicBlock that the terminator
35-
/// branches to.
42+
/// If non-null, this is the BasicBlock that the terminator branches to.
3643
SILBasicBlock *SuccessorBlock = nullptr;
37-
38-
/// This is the prev and next terminator reference to SuccessorBlock, or
39-
/// null if SuccessorBlock is null.
40-
SILSuccessor **Prev = nullptr, *Next = nullptr;
44+
45+
/// A pointer to the SILSuccessor that represents the previous SILSuccessor in the
46+
/// predecessor list for SuccessorBlock.
47+
///
48+
/// Must be nullptr if SuccessorBlock is.
49+
SILSuccessor **Prev = nullptr;
50+
51+
/// A pointer to the SILSuccessor that represents the next SILSuccessor in the
52+
/// predecessor list for SuccessorBlock.
53+
///
54+
/// Must be nullptr if SuccessorBlock is.
55+
SILSuccessor *Next = nullptr;
56+
4157
public:
4258
SILSuccessor() {}
4359

0 commit comments

Comments
 (0)