translate-c: add support for __cleanup__ attribute
Use a `defer` statement to implement the C __cleanup__ attribute. See https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
This commit is contained in:
committed by
Veikka Tuominen
parent
28a89b9ebc
commit
1273bc277f
@@ -1784,6 +1784,14 @@ unsigned ZigClangVarDecl_getAlignedAttribute(const struct ZigClangVarDecl *self,
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct ZigClangFunctionDecl *ZigClangVarDecl_getCleanupAttribute(const struct ZigClangVarDecl *self) {
|
||||
auto casted_self = reinterpret_cast<const clang::VarDecl *>(self);
|
||||
if (const clang::CleanupAttr *CA = casted_self->getAttr<clang::CleanupAttr>()) {
|
||||
return reinterpret_cast<const ZigClangFunctionDecl *>(CA->getFunctionDecl());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned ZigClangFieldDecl_getAlignedAttribute(const struct ZigClangFieldDecl *self, const ZigClangASTContext* ctx) {
|
||||
auto casted_self = reinterpret_cast<const clang::FieldDecl *>(self);
|
||||
auto casted_ctx = const_cast<clang::ASTContext *>(reinterpret_cast<const clang::ASTContext *>(ctx));
|
||||
|
||||
Reference in New Issue
Block a user