From cb4c488cbd1e02b88ca8e7466a0945691f06d4fd Mon Sep 17 00:00:00 2001 From: Vexu Date: Tue, 10 Mar 2020 15:57:57 +0200 Subject: translate-c support struct field alignment --- src/zig_clang.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/zig_clang.cpp') diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index c5ea182e87..ca93634aab 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -1615,6 +1615,16 @@ unsigned ZigClangVarDecl_getAlignedAttribute(const struct ZigClangVarDecl *self, return 0; } +unsigned ZigClangFieldDecl_getAlignedAttribute(const struct ZigClangFieldDecl *self, const ZigClangASTContext* ctx) { + auto casted_self = reinterpret_cast(self); + auto casted_ctx = const_cast(reinterpret_cast(ctx)); + if (const clang::AlignedAttr *AA = casted_self->getAttr()) { + return AA->getAlignment(*casted_ctx); + } + // Zero means no explicit alignment factor was specified + return 0; +} + unsigned ZigClangFunctionDecl_getAlignedAttribute(const struct ZigClangFunctionDecl *self, const ZigClangASTContext* ctx) { auto casted_self = reinterpret_cast(self); auto casted_ctx = const_cast(reinterpret_cast(ctx)); -- cgit v1.2.3