X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FTGParser.cpp;h=1ea6b9816f6d34a3dac6451152a3ddb0939d6cf1;hb=f45a82890e34984ad1e1e259f8fb902caddfb0b1;hp=d6515e8b384ce10cb6df2430da00e8ee31c4fa71;hpb=f460165a4c1bf4bc762f9b3f12b9ed284b89cc99;p=oota-llvm.git diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp index d6515e8b384..1ea6b9816f6 100644 --- a/utils/TableGen/TGParser.cpp +++ b/utils/TableGen/TGParser.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Chris Lattner and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -11,6 +11,8 @@ // //===----------------------------------------------------------------------===// +#include + #include "TGParser.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" @@ -116,13 +118,13 @@ bool TGParser::SetValue(Record *CurRec, LocTy Loc, const std::string &ValName, if (RV->setValue(V)) return Error(Loc, "Value '" + ValName + "' of type '" + RV->getType()->getAsString() + - "' is incompatible with initializer ''"); // FIXME: Add init! + "' is incompatible with initializer '" + V->getAsString() +"'"); return false; } /// AddSubClass - Add SubClass as a subclass to CurRec, resolving its template /// args as SubClass's template arguments. -bool TGParser::AddSubClass(Record *CurRec, class SubClassReference &SubClass) { +bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) { Record *SC = SubClass.Rec; // Add all of the values in the subclass into the current class. const std::vector &Vals = SC->getValues(); @@ -288,9 +290,12 @@ ParseSubClassReference(Record *CurRec, bool isDefm) { /// RangePiece ::= INTVAL '-' INTVAL /// RangePiece ::= INTVAL INTVAL bool TGParser::ParseRangePiece(std::vector &Ranges) { - assert(Lex.getCode() == tgtok::IntVal && "Invalid range"); - int Start = Lex.getCurIntVal(); - int End; + if (Lex.getCode() != tgtok::IntVal) { + TokError("expected integer or bitrange"); + return true; + } + int64_t Start = Lex.getCurIntVal(); + int64_t End; if (Start < 0) return TokError("invalid range, cannot be negative"); @@ -421,7 +426,7 @@ RecTy *TGParser::ParseType() { TokError("expected integer in bits type"); return 0; } - unsigned Val = Lex.getCurIntVal(); + uint64_t Val = Lex.getCurIntVal(); if (Lex.Lex() != tgtok::greater) { // Eat count. TokError("expected '>' at end of bits type"); return 0; @@ -586,9 +591,8 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) { for (unsigned i = 0, e = Vals.size(); i != e; ++i) { Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); if (Bit == 0) { - // FIXME: Include value in error. - Error(BraceLoc, "Element #" + utostr(i) + " ("/* << *Vals[i] - <<*/ ") is not convertable to a bit"); + Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+ + ") is not convertable to a bit"); return 0; } Result->setBit(Vals.size()-i-1, Bit); @@ -612,6 +616,11 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) { } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' + if (Lex.getCode() != tgtok::Id) { + TokError("expected identifier in dag init"); + return 0; + } + Init *Operator = ParseIDValue(CurRec); if (Operator == 0) return 0; @@ -737,9 +746,8 @@ Init *TGParser::ParseValue(Record *CurRec) { return 0; } if (!Result->getFieldType(Lex.getCurStrVal())) { - // FIXME INCLUDE VALUE IN ERROR. TokError("Cannot access field '" + Lex.getCurStrVal() + "' of value '" + - /*<< *$1 <<*/ "'"); + Result->getAsString() + "'"); return 0; } Result = new FieldInit(Result, Lex.getCurStrVal());