@@ -44,6 +44,23 @@ template <> struct ilist_alloc_traits<Instruction> {
44
44
iterator_range<simple_ilist<DbgRecord>::iterator>
45
45
getDbgRecordRange (DbgMarker *);
46
46
47
+ class InsertPosition {
48
+ using InstListType = SymbolTableList<Instruction, ilist_iterator_bits<true >,
49
+ ilist_parent<BasicBlock>>;
50
+ InstListType::iterator InsertAt;
51
+
52
+ public:
53
+ InsertPosition (std::nullopt_t ) : InsertAt() {}
54
+ InsertPosition (std::nullptr_t ) : InsertAt() {}
55
+ // LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead",
56
+ // "BasicBlock::iterator")
57
+ InsertPosition (Instruction *InsertBefore);
58
+ InsertPosition (BasicBlock *InsertAtEnd);
59
+ InsertPosition (InstListType::iterator InsertAt) : InsertAt(InsertAt) {}
60
+ operator InstListType::iterator () const { return InsertAt; }
61
+ bool IsValid () const { return InsertAt.getNodePtr (); }
62
+ };
63
+
47
64
class Instruction : public User ,
48
65
public ilist_node_with_parent<Instruction, BasicBlock,
49
66
ilist_iterator_bits<true >,
@@ -1023,11 +1040,7 @@ class Instruction : public User,
1023
1040
}
1024
1041
1025
1042
Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1026
- InstListType::iterator InsertBefore);
1027
- Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1028
- Instruction *InsertBefore = nullptr );
1029
- Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1030
- BasicBlock *InsertAtEnd);
1043
+ InsertPosition InsertBefore = nullptr );
1031
1044
1032
1045
private:
1033
1046
// / Create a copy of this instruction.
0 commit comments