summaryrefslogtreecommitdiff
path: root/lib/VMCore/Type.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-13 04:22:39 +0000
committerChris Lattner <sabre@nondot.org>2011-07-13 04:22:39 +0000
commitc09ef37171b2a6c914ce34928a4ff4a839b21dbe (patch)
treecf3a291fa985da8d813e8e8806279397f933c43f /lib/VMCore/Type.cpp
parent3b737081e49ef7d640d50285b6cb5f686c75f63d (diff)
downloadllvm-c09ef37171b2a6c914ce34928a4ff4a839b21dbe.tar.gz
llvm-c09ef37171b2a6c914ce34928a4ff4a839b21dbe.tar.bz2
llvm-c09ef37171b2a6c914ce34928a4ff4a839b21dbe.tar.xz
stop leaking all named struct types with an empty name. Thanks
to Benjamin Kramer for steering me in the right direction here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r--lib/VMCore/Type.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 10467a8d90..dc5053acc2 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -412,7 +412,10 @@ void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
StructType *StructType::createNamed(LLVMContext &Context, StringRef Name) {
StructType *ST = new StructType(Context);
- ST->setName(Name);
+ if (!Name.empty())
+ ST->setName(Name);
+ else
+ Context.pImpl->EmptyNamedStructTypes.insert(ST);
return ST;
}
@@ -423,11 +426,16 @@ void StructType::setName(StringRef Name) {
if (SymbolTableEntry) {
getContext().pImpl->NamedStructTypes.erase(getName());
SymbolTableEntry = 0;
+ } else {
+ getContext().pImpl->EmptyNamedStructTypes.erase(this);
}
// If this is just removing the name, we're done.
- if (Name.empty())
+ if (Name.empty()) {
+ // Keep track of types with no names so we can free them.
+ getContext().pImpl->EmptyNamedStructTypes.insert(this);
return;
+ }
// Look up the entry for the name.
StringMapEntry<StructType*> *Entry =