translate-c: handle more wrapper types in isAnyopaque

This commit is contained in:
Veikka Tuominen 2023-03-02 12:48:13 +02:00
parent 0909f47f86
commit 72443fb88c
2 changed files with 17 additions and 1 deletions

View File

@ -4926,6 +4926,22 @@ fn isAnyopaque(qt: clang.QualType) bool {
const typedef_decl = typedef_ty.getDecl();
return isAnyopaque(typedef_decl.getUnderlyingType());
},
.Elaborated => {
const elaborated_ty = @ptrCast(*const clang.ElaboratedType, ty);
return isAnyopaque(elaborated_ty.getNamedType().getCanonicalType());
},
.Decayed => {
const decayed_ty = @ptrCast(*const clang.DecayedType, ty);
return isAnyopaque(decayed_ty.getDecayedType().getCanonicalType());
},
.Attributed => {
const attributed_ty = @ptrCast(*const clang.AttributedType, ty);
return isAnyopaque(attributed_ty.getEquivalentType().getCanonicalType());
},
.MacroQualified => {
const macroqualified_ty = @ptrCast(*const clang.MacroQualifiedType, ty);
return isAnyopaque(macroqualified_ty.getModifiedType().getCanonicalType());
},
else => return false,
}
}

View File

@ -3026,7 +3026,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub export fn log2(arg_a: u32) c_int {
\\ var a = arg_a;
\\ var i: c_int = 0;
\\ while (a > @bitCast(c_uint, @as(c_int, 0))) {
\\ while (a > @bitCast(u32, @as(c_int, 0))) {
\\ a >>= @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1));
\\ }
\\ return i;