forked from OSchip/llvm-project
MustBeExecutedContextExplorer::InstructionIteratorMap: use unique_ptr for values in this map to simplify memory management
This commit is contained in:
parent
3c89256d71
commit
89e2fe3210
|
@ -416,11 +416,6 @@ struct MustBeExecutedContextExplorer {
|
||||||
ExploreCFGBackward(ExploreCFGBackward), LIGetter(LIGetter),
|
ExploreCFGBackward(ExploreCFGBackward), LIGetter(LIGetter),
|
||||||
DTGetter(DTGetter), PDTGetter(PDTGetter), EndIterator(*this, nullptr) {}
|
DTGetter(DTGetter), PDTGetter(PDTGetter), EndIterator(*this, nullptr) {}
|
||||||
|
|
||||||
/// Clean up the dynamically allocated iterators.
|
|
||||||
~MustBeExecutedContextExplorer() {
|
|
||||||
DeleteContainerSeconds(InstructionIteratorMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Iterator-based interface. \see MustBeExecutedIterator.
|
/// Iterator-based interface. \see MustBeExecutedIterator.
|
||||||
///{
|
///{
|
||||||
using iterator = MustBeExecutedIterator;
|
using iterator = MustBeExecutedIterator;
|
||||||
|
@ -428,15 +423,15 @@ struct MustBeExecutedContextExplorer {
|
||||||
|
|
||||||
/// Return an iterator to explore the context around \p PP.
|
/// Return an iterator to explore the context around \p PP.
|
||||||
iterator &begin(const Instruction *PP) {
|
iterator &begin(const Instruction *PP) {
|
||||||
auto *&It = InstructionIteratorMap[PP];
|
auto &It = InstructionIteratorMap[PP];
|
||||||
if (!It)
|
if (!It)
|
||||||
It = new iterator(*this, PP);
|
It.reset(new iterator(*this, PP));
|
||||||
return *It;
|
return *It;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an iterator to explore the cached context around \p PP.
|
/// Return an iterator to explore the cached context around \p PP.
|
||||||
const_iterator &begin(const Instruction *PP) const {
|
const_iterator &begin(const Instruction *PP) const {
|
||||||
return *InstructionIteratorMap.lookup(PP);
|
return *InstructionIteratorMap.find(PP)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an universal end iterator.
|
/// Return an universal end iterator.
|
||||||
|
@ -544,7 +539,7 @@ private:
|
||||||
DenseMap<const Function*, Optional<bool>> IrreducibleControlMap;
|
DenseMap<const Function*, Optional<bool>> IrreducibleControlMap;
|
||||||
|
|
||||||
/// Map from instructions to associated must be executed iterators.
|
/// Map from instructions to associated must be executed iterators.
|
||||||
DenseMap<const Instruction *, MustBeExecutedIterator *>
|
DenseMap<const Instruction *, std::unique_ptr<MustBeExecutedIterator>>
|
||||||
InstructionIteratorMap;
|
InstructionIteratorMap;
|
||||||
|
|
||||||
/// A unique end iterator.
|
/// A unique end iterator.
|
||||||
|
|
Loading…
Reference in New Issue