summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-09-14 00:36:52 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-09-14 00:36:52 +0000
commitc9f936778584da23f837b8703b07606cd946cad9 (patch)
treedb1dec79a74a426eb04a34fdc2f17042e92c2006 /llvm/lib
parentb4091a9c6aa1356d4acc71b9af473ce21651d07a (diff)
downloadbcm5719-llvm-c9f936778584da23f837b8703b07606cd946cad9.tar.gz
bcm5719-llvm-c9f936778584da23f837b8703b07606cd946cad9.zip
Don't leak! Always remove oneself as a listener after adding oneself.
llvm-svn: 81736
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Verifier.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp
index 9f7be43b54a..7b2afde0a0e 100644
--- a/llvm/lib/VMCore/Verifier.cpp
+++ b/llvm/lib/VMCore/Verifier.cpp
@@ -57,7 +57,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/InstVisitor.h"
-#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -108,25 +108,34 @@ static const PassInfo *const PreVerifyID = &PreVer;
namespace {
struct TypeSet : public AbstractTypeUser {
- SmallSet<const Type *, 16> Types;
+ SmallSetVector<const Type *, 16> Types;
/// Insert a type into the set of types.
bool insert(const Type *Ty) {
- bool Inserted = Types.insert(Ty);
- if (!Inserted)
+ if (!Types.insert(Ty))
return false;
-
if (Ty->isAbstract())
Ty->addAbstractTypeUser(this);
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.
/// Remove types from the set when refined. Do not insert the type it was
/// refined to because that type hasn't been verified yet.
void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
- Types.erase(OldTy);
+ Types.remove(OldTy);
OldTy->removeAbstractTypeUser(this);
}
void typeBecameConcrete(const DerivedType *AbsTy) {}
OpenPOWER on IntegriCloud