diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-05 15:35:11 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-05 15:35:11 +0300 |
| commit | e563af13296cdb3e64f0f396fdc58112d4484968 (patch) | |
| tree | 46d5066948ebcce3825932839d25577014cb8ab6 /src/zig_clang.cpp | |
| parent | f374ea2cd16cf5d0f6f8df6b50f55a9e315ae565 (diff) | |
| parent | a560af96568a668bf0c01b3c58ad4dda647ea1b4 (diff) | |
| download | zig-e563af13296cdb3e64f0f396fdc58112d4484968.tar.gz zig-e563af13296cdb3e64f0f396fdc58112d4484968.zip | |
Merge pull request #12745 from Techcable/translate-c/packed-struct-implies-align1
translate-c: Translate clang packed struct C into Zig extern struct with align(1)
Diffstat (limited to 'src/zig_clang.cpp')
| -rw-r--r-- | src/zig_clang.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index 223dc29067..bd06ead4b0 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -1941,10 +1941,7 @@ const char* ZigClangVarDecl_getSectionAttribute(const struct ZigClangVarDecl *se bool ZigClangRecordDecl_getPackedAttribute(const ZigClangRecordDecl *zig_record_decl) { const clang::RecordDecl *record_decl = reinterpret_cast<const clang::RecordDecl *>(zig_record_decl); - if (record_decl->getAttr<clang::PackedAttr>()) { - return true; - } - return false; + return record_decl->hasAttr<clang::PackedAttr>(); } unsigned ZigClangVarDecl_getAlignedAttribute(const struct ZigClangVarDecl *self, const ZigClangASTContext* ctx) { @@ -1985,6 +1982,16 @@ unsigned ZigClangFunctionDecl_getAlignedAttribute(const struct ZigClangFunctionD return 0; } +bool ZigClangVarDecl_getPackedAttribute(const struct ZigClangVarDecl *self) { + auto casted_self = reinterpret_cast<const clang::VarDecl *>(self); + return casted_self->hasAttr<clang::PackedAttr>(); +} + +bool ZigClangFieldDecl_getPackedAttribute(const struct ZigClangFieldDecl *self) { + auto casted_self = reinterpret_cast<const clang::FieldDecl *>(self); + return casted_self->hasAttr<clang::PackedAttr>(); +} + ZigClangQualType ZigClangParmVarDecl_getOriginalType(const struct ZigClangParmVarDecl *self) { return bitcast(reinterpret_cast<const clang::ParmVarDecl *>(self)->getOriginalType()); } |
