From 1176aa52646fe641a4243a246aa7f960c708a274 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 17 Jul 2011 15:36:56 +0000 Subject: Vendor import of llvm trunk r135360: http://llvm.org/svn/llvm-project/llvm/trunk@135360 --- utils/TableGen/SetTheory.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index ade1825..21ac09c 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "SetTheory.h" +#include "Error.h" #include "Record.h" #include "llvm/Support/Format.h" @@ -155,10 +156,15 @@ struct SequenceOp : public SetTheory::Operator { From = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); + if (From < 0 || From >= (1 << 30)) + throw "From out of range"; + if (IntInit *II = dynamic_cast(Expr->arg_begin()[2])) To = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); + if (To < 0 || To >= (1 << 30)) + throw "To out of range"; RecordKeeper &Records = dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); @@ -167,7 +173,7 @@ struct SequenceOp : public SetTheory::Operator { for (To += Step; From != To; From += Step) { std::string Name; raw_string_ostream OS(Name); - OS << format(Format.c_str(), From); + OS << format(Format.c_str(), unsigned(From)); Record *Rec = Records.getDef(OS.str()); if (!Rec) throw "No def named '" + Name + "': " + Expr->getAsString(); -- cgit v1.1