diff options
Diffstat (limited to 'contrib/llvm/lib/TableGen')
-rw-r--r-- | contrib/llvm/lib/TableGen/Main.cpp | 2 | ||||
-rw-r--r-- | contrib/llvm/lib/TableGen/Record.cpp | 31 | ||||
-rw-r--r-- | contrib/llvm/lib/TableGen/TGParser.cpp | 12 |
3 files changed, 29 insertions, 16 deletions
diff --git a/contrib/llvm/lib/TableGen/Main.cpp b/contrib/llvm/lib/TableGen/Main.cpp index dc4167b..7fe47bc 100644 --- a/contrib/llvm/lib/TableGen/Main.cpp +++ b/contrib/llvm/lib/TableGen/Main.cpp @@ -83,7 +83,7 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) { // Parse the input file. OwningPtr<MemoryBuffer> File; if (error_code ec = - MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { + MemoryBuffer::getFileOrSTDIN(InputFilename, File)) { errs() << "Could not open input file '" << InputFilename << "': " << ec.message() <<"\n"; return 1; diff --git a/contrib/llvm/lib/TableGen/Record.cpp b/contrib/llvm/lib/TableGen/Record.cpp index 9ad2053..431f4aa 100644 --- a/contrib/llvm/lib/TableGen/Record.cpp +++ b/contrib/llvm/lib/TableGen/Record.cpp @@ -557,9 +557,23 @@ Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) const { return const_cast<BitsInit *>(this); } +namespace { + template<typename T> + class Pool : public T { + public: + ~Pool(); + }; + template<typename T> + Pool<T>::~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<int64_t, IntInit *> Pool; - static Pool ThePool; + static Pool<DenseMap<int64_t, IntInit *> > ThePool; IntInit *&I = ThePool[V]; if (!I) I = new IntInit(V); @@ -586,8 +600,7 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const { void StringInit::anchor() { } StringInit *StringInit::get(StringRef V) { - typedef StringMap<StringInit *> Pool; - static Pool ThePool; + static Pool<StringMap<StringInit *> > 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<std::pair<unsigned, Init *>, RecTy *> Key; - - typedef DenseMap<Key, UnOpInit *> Pool; - static Pool ThePool; + static Pool<DenseMap<Key, UnOpInit *> > 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<Key, BinOpInit *> Pool; - static Pool ThePool; + static Pool<DenseMap<Key, BinOpInit *> > 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<RecTy *, Init *> Key; - typedef DenseMap<Key, VarInit *> Pool; - static Pool ThePool; + static Pool<DenseMap<Key, VarInit *> > ThePool; Key TheKey(std::make_pair(T, VN)); diff --git a/contrib/llvm/lib/TableGen/TGParser.cpp b/contrib/llvm/lib/TableGen/TGParser.cpp index 86ad2a6..daac574 100644 --- a/contrib/llvm/lib/TableGen/TGParser.cpp +++ b/contrib/llvm/lib/TableGen/TGParser.cpp @@ -1271,10 +1271,11 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, if (ItemType != 0) { ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType); if (ListType == 0) { - std::stringstream s; - s << "Type mismatch for list, expected list type, got " - << ItemType->getAsString(); - TokError(s.str()); + std::string s; + raw_string_ostream ss(s); + ss << "Type mismatch for list, expected list type, got " + << ItemType->getAsString(); + TokError(ss.str()); return 0; } GivenListTy = ListType; @@ -2495,6 +2496,9 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { if (Lex.getCode() != tgtok::comma) break; Lex.Lex(); // eat ','. + if (Lex.getCode() != tgtok::Id) + return TokError("expected identifier"); + SubClassLoc = Lex.getLoc(); // A defm can inherit from regular classes (non-multiclass) as |