Changeset 5788


Ignore:
Timestamp:
Dec 19, 2017, 6:35:04 AM (11 months ago)
Author:
cameron
Message:

Error checking for ranges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_range.cpp

    r5787 r5788  
    99#include <re/re_name.h>
    1010#include <llvm/Support/Casting.h>
     11#include <llvm/Support/ErrorHandling.h>
    1112
    1213using namespace llvm;
     
    1617RE * makeRange(RE * lo, RE * hi) {
    1718    if (isa<CC>(lo) && isa<CC>(hi)) {
    18         assert(dyn_cast<CC>(lo)->count() == 1);
    19         assert(dyn_cast<CC>(hi)->count() == 1);
    20         return makeCC(dyn_cast<CC>(lo)->front().first, dyn_cast<CC>(hi)->front().first);
     19        if (!(dyn_cast<CC>(lo)->count() == 1) && (dyn_cast<CC>(hi)->count() == 1))
     20            llvm::report_fatal_error("illegal range operand");
     21        auto lo_val = dyn_cast<CC>(lo)->front().first;
     22        auto hi_val = dyn_cast<CC>(hi)->front().first;
     23        if (hi_val < lo_val) llvm::report_fatal_error("illegal range");
     24        return makeCC(lo_val, hi_val);
    2125    }
    2226    else if (isa<Name>(lo) && (cast<Name>(lo)->getDefinition() != nullptr)) {
Note: See TracChangeset for help on using the changeset viewer.