diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-15 06:23:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-15 06:23:52 +0000 |
commit | 632eb65cd2315c68e4a43ef5950cd31e82adf7cb (patch) | |
tree | 6c5939a627e01f8d5f33af9375ccc58ae0fa1ba5 /llvm/lib/CodeGen | |
parent | 133487696abe700b10a096680db651b37c6b8846 (diff) | |
download | bcm5719-llvm-632eb65cd2315c68e4a43ef5950cd31e82adf7cb.tar.gz bcm5719-llvm-632eb65cd2315c68e4a43ef5950cd31e82adf7cb.zip |
fix MCSectionELF to not leak memory, just like I did for MCSymbol.
MCSectionMachO is already fine (yay for fixed size arrays?),
MCSectionCOFF still leaks.
llvm-svn: 98537
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 788bbf11908..05e0ea8dfc1 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -53,11 +53,13 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags, ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)UniquingMap; // Do the lookup, if we have a hit, return it. - const MCSectionELF *&Entry = Map[Section]; - if (Entry) return Entry; + StringMapEntry<const MCSectionELF*> &Entry = Map.GetOrCreateValue(Section); + if (Entry.getValue()) return Entry.getValue(); - return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, IsExplicit, - getContext()); + MCSectionELF *Result = MCSectionELF::Create(Entry.getKey(), Type, Flags, Kind, + IsExplicit, getContext()); + Entry.setValue(Result); + return Result; } void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, |