Ignore:
Timestamp:
Apr 26, 2017, 9:12:43 PM (2 years ago)
Author:
cameron
Message:

Turn UnicodePropertyExpressionErrors? into LLVM fatal errors

Location:
icGREP/icgrep-devel/icgrep/UCD
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.cpp

    r5328 r5428  
    1818#include "UCD/PropertyObjectTable.h"
    1919#include "UCD/PropertyValueAliases.h"
     20#include <llvm/Support/ErrorHandling.h>
    2021
    2122using namespace UCD;
     
    2829
    2930namespace UCD {
     31   
     32void UnicodePropertyExpressionError(std::string errmsg) {
     33    llvm::report_fatal_error(errmsg);
     34
     35}
     36
    3037
    3138void generateGraphemeClusterBoundaryRule(Name * const &property) {
     
    7885        auto propit = alias_map.find(property->getNamespace());
    7986        if (propit == alias_map.end()) {
    80             throw UnicodePropertyExpressionError("Expected a property name but '" + property->getNamespace() + "' was found instead");
     87            UnicodePropertyExpressionError("Expected a property name but '" + property->getNamespace() + "' was found instead");
    8188        }
    8289        auto theprop = propit->second;
     
    127134        auto propit = alias_map.find(property->getNamespace());
    128135        if (propit == alias_map.end()) {
    129             throw UnicodePropertyExpressionError("Expected a property name but '" + property->getNamespace() + "' was found instead");
     136            UnicodePropertyExpressionError("Expected a property name but '" + property->getNamespace() + "' was found instead");
    130137        }
    131138        auto theprop = propit->second;
     
    133140            int valcode = p->GetPropertyValueEnumCode(value);
    134141            if (valcode < 0) {
    135                 throw UnicodePropertyExpressionError("Erroneous property value '" + value + "' for " + property_full_name[theprop] + " property");
     142                UnicodePropertyExpressionError("Erroneous property value '" + value + "' for " + property_full_name[theprop] + " property");
    136143            }
    137144            functionName = "__get_" + property_enum_name[theprop] + "_" + p->GetValueEnumName(valcode);
     
    141148            int valcode = GetPropertyValueEnumCode(sc, value);
    142149            if (valcode < 0) {
    143                 throw UnicodePropertyExpressionError("Erroneous property value for script_extension property");
     150                UnicodePropertyExpressionError("Erroneous property value for script_extension property");
    144151            }
    145152            functionName = "__get_scx_" + SC_ns::enum_names[valcode];
     
    148155            auto valit = Binary_ns::aliases_only_map.find(value);
    149156            if (valit == Binary_ns::aliases_only_map.end()) {
    150                 throw UnicodePropertyExpressionError("Erroneous property value for binary property " + property_full_name[theprop]);
     157                UnicodePropertyExpressionError("Erroneous property value for binary property " + property_full_name[theprop]);
    151158            }
    152159            if (valit->second == Binary_ns::Y) {
    153160                functionName = "__get_" + property_enum_name[theprop] + "_Y";
    154161            } else {
    155                 throw UnicodePropertyExpressionError("Unexpected property value for binary property " + property_full_name[theprop]);
     162                UnicodePropertyExpressionError("Unexpected property value for binary property " + property_full_name[theprop]);
    156163            }
    157164        }
    158165        else {
    159             throw UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
     166            UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
    160167        }
    161168    } else { // No namespace (property) name.
     
    176183                }
    177184                else {
    178                     throw UnicodePropertyExpressionError("Error: property " + property_full_name[theprop] + " specified without a value");
     185                    UnicodePropertyExpressionError("Error: property " + property_full_name[theprop] + " specified without a value");
    179186                }
    180187            }
    181188            else {
    182                 throw UnicodePropertyExpressionError("Expected a general category, script or binary property name but '" + value + "' was found instead");
     189                UnicodePropertyExpressionError("Expected a general category, script or binary property name but '" + value + "' was found instead");
    183190            }
    184191        }
     
    191198    auto propit = alias_map.find(canonicalize_value_name(prop));
    192199    if (propit == alias_map.end()) {
    193         throw UnicodePropertyExpressionError("Expected a property name, but '" + prop + "' found instead");
     200        UnicodePropertyExpressionError("Expected a property name, but '" + prop + "' found instead");
    194201    }
    195202    auto theprop = propit->second;
     
    200207    }
    201208
    202     throw UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
     209    UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
    203210}
    204211
     
    211218            auto propit = alias_map.find(prop);
    212219            if (propit == alias_map.end()) {
    213                 throw UnicodePropertyExpressionError("Expected a property name, but '" + name->getNamespace() + "' found instead");
     220                UnicodePropertyExpressionError("Expected a property name, but '" + name->getNamespace() + "' found instead");
    214221            }
    215222            auto theprop = propit->second;
     
    220227                auto valit = Binary_ns::aliases_only_map.find(value);
    221228                if (valit == Binary_ns::aliases_only_map.end()) {
    222                     throw UnicodePropertyExpressionError("Erroneous property value for binary property " + property_full_name[theprop]);
     229                    UnicodePropertyExpressionError("Erroneous property value for binary property " + property_full_name[theprop]);
    223230                }
    224231                return p->GetCodepointSet(value);
    225232            }           
    226             throw UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
     233            UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
    227234        }
    228235        else {
     
    244251                }
    245252                else {
    246                     throw UnicodePropertyExpressionError("Error: property " + property_full_name[theprop] + " specified without a value");
     253                    UnicodePropertyExpressionError("Error: property " + property_full_name[theprop] + " specified without a value");
    247254                }
    248255            }
     
    275282        }
    276283    }
    277     throw UnicodePropertyExpressionError("Expected a general category, script or binary property name, but '" + name->getName() + "' found instead");
    278 }
    279 
    280 }
     284    UnicodePropertyExpressionError("Expected a general category, script or binary property name, but '" + name->getName() + "' found instead");
     285}
     286
     287}
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.h

    r5236 r5428  
    1313namespace UCD {
    1414
    15 
    16 class UnicodePropertyExpressionError : public std::exception {
    17 public:
    18     UnicodePropertyExpressionError(const std::string && msg) noexcept : _msg(msg) {}
    19     const char* what() const noexcept { return _msg.c_str();}
    20 private:
    21     inline UnicodePropertyExpressionError() noexcept {}
    22     const std::string _msg;
    23 };
     15LLVM_ATTRIBUTE_NORETURN void UnicodePropertyExpressionError(std::string errmsg);
    2416
    2517void generateGraphemeClusterBoundaryRule(re::Name * const &property);
Note: See TracChangeset for help on using the changeset viewer.