This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenObjC] Fix a crash when attempting to copy a zero-sized bit-field in a non-trivial C struct
ClosedPublic

Authored by erik.pilkington on Mar 25 2020, 10:02 AM.

Details

Summary

Zero sized bit-fields aren't included in the CGRecordLayout, so we shouldn't be calling EmitLValueForField for them.

rdar://60695105

Diff Detail

Event Timeline

Thanks for fixing this!

clang/lib/CodeGen/CGNonTrivialStruct.cpp
545

Can you add the same check to GenBinaryFuncName::visitVolatileTrivial to avoid encoding the zero-length bit field into the name of the copy constructor/assignment functions? It isn't necessary to generate different functions for ZeroBitfieldin the test case and the following struct:

struct S {
  id strong;
};
clang/test/CodeGenObjC/strong-in-c-struct.m
894

Can you check that the zero-sized field information isn't encoded into the name of the copy assignment function?

erik.pilkington marked 3 inline comments as done.

Don't bother including zero length bit-fields in the mangling of the copy/destroy helpers.

This revision is now accepted and ready to land.Apr 6 2020, 10:41 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2020, 1:05 PM