X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTableGen%2FRecord.cpp;h=431f4aa089be0a43a210894bb53198839c89b92d;hb=2becaaf3a15a8815f93e65f768038427051ee004;hp=fcee93aac475fa73c03fdfb3c8bc911ac6be3fb2;hpb=d23a41c153712b929bd84f5e713bda5db5d6e66d;p=oota-llvm.git diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index fcee93aac47..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)); @@ -1525,11 +1534,9 @@ Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) const { return const_cast(this); } -void ProfileDagInit(FoldingSetNodeID &ID, - Init *V, - const std::string &VN, - ArrayRef ArgRange, - ArrayRef NameRange) { +static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, const std::string &VN, + ArrayRef ArgRange, + ArrayRef NameRange) { ID.AddPointer(V); ID.AddString(VN);