This is an archive of the discontinued LLVM Phabricator instance.

Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls
ClosedPublic

Authored by ahatanak on Dec 6 2016, 12:26 PM.

Details

Summary

This patch silences an incorrect warning that is issued when a function pointer is cast to another function pointer type. The warning gets issued because alignments of the source and destination do not match in Sema::CheckCastAlign, which happens because ASTContext::getTypeInfoImpl and ASTContext::getDeclAlign return different values for functions (the former returns 4 while the latter returns 1).

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak updated this revision to Diff 80463.Dec 6 2016, 12:26 PM
ahatanak retitled this revision from to Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls.
ahatanak updated this object.
ahatanak added reviewers: rsmith, doug.gregor.
ahatanak added a subscriber: cfe-commits.
ahatanak updated this revision to Diff 80464.Dec 6 2016, 12:47 PM

Call getTypeInfoImpl from getDeclAlign to get the alignment of functions.

Does this happen with blocks as well?

This doesn't happen for objective-c block pointers. Sema::CheckCastAlign returns early when the type isn't a PointerType (BlockPointerType isn't a subclass of PointerType).

arphaman accepted this revision.Jan 4 2017, 6:02 AM
arphaman added a reviewer: arphaman.

Thanks. LGTM, I think the patch makes sense.

This revision is now accepted and ready to land.Jan 4 2017, 6:02 AM
This revision was automatically updated to reflect the committed changes.