mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Don't leak! Always remove oneself as a listener after adding oneself.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81736 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bc6836bbe3
commit
adc3142fdd
@ -57,7 +57,7 @@
|
|||||||
#include "llvm/Support/CallSite.h"
|
#include "llvm/Support/CallSite.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@ -108,25 +108,34 @@ static const PassInfo *const PreVerifyID = &PreVer;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct TypeSet : public AbstractTypeUser {
|
struct TypeSet : public AbstractTypeUser {
|
||||||
SmallSet<const Type *, 16> Types;
|
SmallSetVector<const Type *, 16> Types;
|
||||||
|
|
||||||
/// Insert a type into the set of types.
|
/// Insert a type into the set of types.
|
||||||
bool insert(const Type *Ty) {
|
bool insert(const Type *Ty) {
|
||||||
bool Inserted = Types.insert(Ty);
|
if (!Types.insert(Ty))
|
||||||
if (!Inserted)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Ty->isAbstract())
|
if (Ty->isAbstract())
|
||||||
Ty->addAbstractTypeUser(this);
|
Ty->addAbstractTypeUser(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove ourselves as abstract type listeners for any types that remain
|
||||||
|
// abstract when the TypeSet is destroyed.
|
||||||
|
~TypeSet() {
|
||||||
|
for (SmallSetVector<const Type *, 16>::iterator I = Types.begin(),
|
||||||
|
E = Types.end(); I != E; ++I) {
|
||||||
|
const Type *Ty = *I;
|
||||||
|
if (Ty->isAbstract())
|
||||||
|
Ty->removeAbstractTypeUser(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Abstract type user interface.
|
// Abstract type user interface.
|
||||||
|
|
||||||
/// Remove types from the set when refined. Do not insert the type it was
|
/// Remove types from the set when refined. Do not insert the type it was
|
||||||
/// refined to because that type hasn't been verified yet.
|
/// refined to because that type hasn't been verified yet.
|
||||||
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
|
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
|
||||||
Types.erase(OldTy);
|
Types.remove(OldTy);
|
||||||
OldTy->removeAbstractTypeUser(this);
|
OldTy->removeAbstractTypeUser(this);
|
||||||
}
|
}
|
||||||
void typeBecameConcrete(const DerivedType *AbsTy) {}
|
void typeBecameConcrete(const DerivedType *AbsTy) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user