X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTableGen%2FRecord.cpp;h=431f4aa089be0a43a210894bb53198839c89b92d;hb=88d74c3093de563408ceb834d999613038195e98;hp=9ad20532d7eb47200130775bce8d488664f7b751;hpb=74b3c8da4800c7e8ba8f019879db29738ecc5f74;p=oota-llvm.git diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 9ad20532d7e..431f4aa089b 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -557,9 +557,23 @@ Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) const { return const_cast(this); } +namespace { + template + class Pool : public T { + public: + ~Pool(); + }; + template + Pool::~Pool() { + for (typename T::iterator I = this->begin(), E = this->end(); I != E; ++I) { + typename T::value_type &Item = *I; + delete Item.second; + } + } +} + IntInit *IntInit::get(int64_t V) { - typedef DenseMap Pool; - static Pool ThePool; + static Pool > ThePool; IntInit *&I = ThePool[V]; if (!I) I = new IntInit(V); @@ -586,8 +600,7 @@ IntInit::convertInitializerBitRange(const std::vector &Bits) const { void StringInit::anchor() { } StringInit *StringInit::get(StringRef V) { - typedef StringMap Pool; - static Pool ThePool; + static Pool > ThePool; StringInit *&I = ThePool[V]; if (!I) I = new StringInit(V); @@ -726,9 +739,7 @@ Init *OpInit::getBit(unsigned Bit) const { UnOpInit *UnOpInit::get(UnaryOp opc, Init *lhs, RecTy *Type) { typedef std::pair, RecTy *> Key; - - typedef DenseMap Pool; - static Pool ThePool; + static Pool > ThePool; Key TheKey(std::make_pair(std::make_pair(opc, lhs), Type)); @@ -873,8 +884,7 @@ BinOpInit *BinOpInit::get(BinaryOp opc, Init *lhs, RecTy * > Key; - typedef DenseMap Pool; - static Pool ThePool; + static Pool > ThePool; Key TheKey(std::make_pair(std::make_pair(std::make_pair(opc, lhs), rhs), Type)); @@ -1298,8 +1308,7 @@ VarInit *VarInit::get(const std::string &VN, RecTy *T) { VarInit *VarInit::get(Init *VN, RecTy *T) { typedef std::pair Key; - typedef DenseMap Pool; - static Pool ThePool; + static Pool > ThePool; Key TheKey(std::make_pair(T, VN));