-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
translate-c: emit alignCast when casting pointers #2316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think you can use unsigned ZigClangASTContext_getTypeAlignIfKnown(const ZigClangASTContext* self, ZigClangQualType T) {
return reinterpret_cast<const clang::ASTContext *>(self)->getTypeAlignIfKnown(bitcast(T));
}
|
…an source alignment
@LemonBoy Thanks, that really helped! I still need to trigger a test case, but in theory this should be enough. The other places where ptrCast is emitted don't seem to be an issue. I'll let you know once I've got some tests EDIT: Nope, I'm not really doing the right thing. I'll try again tonight. |
Turns out I was checking the alignment of the pointer and not the pointee... At this point, this handles the following test code if you ignore the c alignment attributes:
generating
Once translate-c can handle alignment attributes, it should skip the alignCast |
Questions:
|
This small patch makes all pointer casts include an align cast as well. This isn't great, but I haven't quite worked out how to work out when they're needed. Tests still need to be changed.
Is there a simple way of running only the translate-c tests?