diff options
Diffstat (limited to 'contrib/llvm/utils/TableGen/SetTheory.cpp')
-rw-r--r-- | contrib/llvm/utils/TableGen/SetTheory.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/llvm/utils/TableGen/SetTheory.cpp b/contrib/llvm/utils/TableGen/SetTheory.cpp index ade1825..21ac09c 100644 --- a/contrib/llvm/utils/TableGen/SetTheory.cpp +++ b/contrib/llvm/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<IntInit*>(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<DefInit&>(*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(); |