llcppsigfetch:Constant & Incomplete Array

This commit is contained in:
luoliwoshang
2024-08-14 18:22:14 +08:00
parent 9a77a0c201
commit 6b1bc15f37
4 changed files with 123 additions and 4 deletions

View File

@@ -147,11 +147,20 @@ func (ct *Converter) ProcessType(t clang.Type) ast.Expr {
expr = &ast.FuncType{Ret: ret}
case clang.TypeTypedef:
expr = ct.ProcessType(t.CanonicalType())
case clang.TypeConstantArray, clang.TypeVariableArray, clang.TypeIncompleteArray, clang.TypeDependentSizedArray:
expr = &ast.ArrayType{
Elt: ct.ProcessType(t.ArrayElementType()),
case clang.TypeConstantArray, clang.TypeIncompleteArray, clang.TypeVariableArray, clang.TypeDependentSizedArray:
if t.Kind == clang.TypeConstantArray {
valueStr := make([]c.Char, 20)
c.Sprintf(unsafe.SliceData(valueStr), c.Str("%d"), t.ArraySize())
expr = &ast.ArrayType{
Elt: ct.ProcessType(t.ArrayElementType()),
Len: &ast.BasicLit{Kind: ast.IntLit, Value: c.GoString(unsafe.SliceData(valueStr))},
}
} else if t.Kind == clang.TypeIncompleteArray {
// incomplete array havent len expr
expr = &ast.ArrayType{
Elt: ct.ProcessType(t.ArrayElementType()),
}
}
// todo(zzy):array length
}
return expr
}