@@ -44,6 +44,23 @@ template <> struct ilist_alloc_traits<Instruction> {
4444iterator_range<simple_ilist<DbgRecord>::iterator>
4545getDbgRecordRange (DbgMarker *);
4646
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+
4764class Instruction : public User ,
4865 public ilist_node_with_parent<Instruction, BasicBlock,
4966 ilist_iterator_bits<true >,
@@ -1018,11 +1035,7 @@ class Instruction : public User,
10181035 }
10191036
10201037 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1021- InstListType::iterator InsertBefore);
1022- Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1023- Instruction *InsertBefore = nullptr );
1024- Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
1025- BasicBlock *InsertAtEnd);
1038+ InsertPosition InsertBefore = nullptr );
10261039
10271040private:
10281041 // / Create a copy of this instruction.
0 commit comments