Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.cc

    r17129659 r6896548  
    5151}
    5252
    53 Constant Constant::from_string( std::string const & str ) {
    54         return Constant(
    55                 new ArrayType(
    56                         noQualifiers,
    57                         new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    58                         new ConstantExpr( Constant::from_int( str.size() + 1 /* \0 */ )),
    59                         false, false ),
    60                 std::string("\"") + str + "\"", (unsigned long long int)0 );
     53Constant Constant::from_string( std::string const & cEscapedVal, Type *charType ) {
     54        assert(cEscapedVal.length() >= 2);
     55        assert(cEscapedVal.front() == '"');
     56        assert(cEscapedVal.back() == '"');
     57        ArrayType * at = new ArrayType( noQualifiers, charType,
     58                                                                        new ConstantExpr( Constant::from_ulong( cEscapedVal.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
     59                                                                        false, false );
     60        return Constant( at, cEscapedVal, (unsigned long long int)0 );
    6161}
    6262
Note: See TracChangeset for help on using the changeset viewer.