translate-c remove error set from checkForBuiltinTypedef

This commit is contained in:
Vexu 2020-05-13 17:53:15 +03:00
parent cefc04348e
commit afab095b61
No known key found for this signature in database
GPG Key ID: 59AEB8936E16A6AC

View File

@ -668,7 +668,7 @@ fn transTypeDefAsBuiltin(c: *Context, typedef_decl: *const ZigClangTypedefNameDe
return transCreateNodeIdentifier(c, builtin_name); return transCreateNodeIdentifier(c, builtin_name);
} }
fn checkForBuiltinTypedef(checked_name: []const u8) !?[]const u8 { fn checkForBuiltinTypedef(checked_name: []const u8) ?[]const u8 {
const table = [_][2][]const u8{ const table = [_][2][]const u8{
.{ "uint8_t", "u8" }, .{ "uint8_t", "u8" },
.{ "int8_t", "i8" }, .{ "int8_t", "i8" },
@ -703,7 +703,7 @@ fn transTypeDef(c: *Context, typedef_decl: *const ZigClangTypedefNameDecl, top_l
// TODO https://github.com/ziglang/zig/issues/3756 // TODO https://github.com/ziglang/zig/issues/3756
// TODO https://github.com/ziglang/zig/issues/1802 // TODO https://github.com/ziglang/zig/issues/1802
const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmt.allocPrint(c.a(), "{}_{}", .{ typedef_name, c.getMangle() }) else typedef_name; const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmt.allocPrint(c.a(), "{}_{}", .{ typedef_name, c.getMangle() }) else typedef_name;
if (try checkForBuiltinTypedef(checked_name)) |builtin| { if (checkForBuiltinTypedef(checked_name)) |builtin| {
return transTypeDefAsBuiltin(c, typedef_decl, builtin); return transTypeDefAsBuiltin(c, typedef_decl, builtin);
} }
@ -1411,7 +1411,7 @@ fn transDeclStmt(rp: RestorePoint, scope: *Scope, stmt: *const ZigClangDeclStmt)
const underlying_type = ZigClangQualType_getTypePtr(underlying_qual); const underlying_type = ZigClangQualType_getTypePtr(underlying_qual);
const mangled_name = try block_scope.makeMangledName(c, name); const mangled_name = try block_scope.makeMangledName(c, name);
if (try checkForBuiltinTypedef(name)) |builtin| { if (checkForBuiltinTypedef(name)) |builtin| {
try block_scope.variables.push(.{ try block_scope.variables.push(.{
.alias = builtin, .alias = builtin,
.name = mangled_name, .name = mangled_name,