@@ -2252,7 +2252,9 @@ static std::string getTypedLiteral(const char *num, std::string_view type) {
22522252std::string Converter::getIntegerLiteral (clang::IntegerLiteral *expr,
22532253 bool incl_type,
22542254 const clang::QualType *type) {
2255- auto num_as_string = GetNumAsString (expr->getValue ());
2255+ auto value = GetIntegerLiteralValue (ctx_, expr, type, CharRustTypeIsSigned ());
2256+ llvm::SmallString<16 > num_as_string;
2257+ value.toString (num_as_string, 10 );
22562258 if (num_as_string[0 ] != ' -' && !incl_type) {
22572259 if (type && (*type)->isFloatingType () &&
22582260 num_as_string.find (' .' ) == llvm::StringRef::npos) {
@@ -2265,7 +2267,7 @@ std::string Converter::getIntegerLiteral(clang::IntegerLiteral *expr,
22652267 auto type_as_string = GetUnsafeTypeAsString (ty);
22662268
22672269 if (ty->isFloatingType () || incl_type) {
2268- if (expr-> getValue () .isZero ()) {
2270+ if (value .isZero ()) {
22692271 if (auto init = Mapper::MapInitializer (ctx_, ty); !init.empty ()) {
22702272 return init;
22712273 }
@@ -2956,6 +2958,15 @@ bool Converter::VisitUnaryOperator(clang::UnaryOperator *expr) {
29562958 computed_expr_type_ = ComputedExprType::FreshValue;
29572959 break ;
29582960 }
2961+ if (expr->getType ()->isUnsignedIntegerType ()) {
2962+ {
2963+ PushParen paren (*this );
2964+ Convert (sub_expr);
2965+ }
2966+ StrCat (" .wrapping_neg()" );
2967+ SetFreshType (expr->getType ());
2968+ break ;
2969+ }
29592970 [[fallthrough]] ;
29602971 default :
29612972 StrCat (expr->getOpcodeStr (opcode));
0 commit comments