Remove obsolete workarounds for *va_list* in interop

Fix #740
This commit is contained in:
Svyatoslav Scherbina
2017-07-14 17:57:54 +03:00
committed by SvyatoslavScherbina
parent 0f20feb544
commit 8bd0bb63c9
@@ -137,43 +137,12 @@ internal class NativeIndexImpl(val library: NativeLibrary) : NativeIndex() {
}
}
private fun builtinVaListType(type: CValue<CXType>, name: String, underlying: Type): Type {
assert (type.kind == CXType_Typedef)
val declarationId = DeclarationID("c:@T@$name")
val structDeclaration = structById.getOrPut(declarationId) {
StructDeclImpl(name).apply {
val size = clang_Type_getSizeOf(type)
val align = clang_Type_getAlignOf(type).toInt()
val def = StructDefImpl(size, align, this, hasNaturalLayout = false)
this.def = def
}
}
assert (underlying is ConstArrayType)
// So the result must feel like array:
return ConstArrayType(RecordType(structDeclaration), 1)
}
fun getTypedef(type: CValue<CXType>): Type {
val declCursor = clang_getTypeDeclaration(type)
val name = getCursorSpelling(declCursor)
val underlying = convertType(clang_getTypedefDeclUnderlyingType(declCursor))
if (name == "__builtin_va_list" && underlying is ConstArrayType) {
// On some platforms (e.g. macOS) libclang reports `__builtin_va_list` to be defined as array using
// typedef struct __va_list_tag __builtin_va_list[1]
// while `struct __va_list_tag` is incomplete.
// So `__builtin_va_list` gets declared as incorrect type, and requires some dirty hacks:
return builtinVaListType(type, name, underlying)
}
if (name == "__gnuc_va_list" || name == "va_list" || name == "__va_list") {
// TODO: fix GNUC varargs support.
return UnsupportedType
}
if ((underlying is RecordType && underlying.decl.spelling.split(' ').last() == name) ||
(underlying is EnumType && underlying.def.spelling.split(' ').last() == name)) {