When two modules contain struct/union with the same name, check the
definitions are equivalent and diagnose if they are not. This is similar
to CXXRecordDecl where we already discover and diagnose mismatches.
rdar://problem/56764293
Differential D71734
[ODRHash] Hash `RecordDecl` and diagnose discovered mismatches. vsapsai on Dec 19 2019, 4:29 PM. Authored by
Details When two modules contain struct/union with the same name, check the rdar://problem/56764293
Diff Detail
Unit Tests Event Timeline
Comment Actions
Comment Actions Updated the patch to refactor mode code.
Once the patch gets approved the idea is to upstream some of the refactoring
Comment Actions Think I'll need to make another review pass but here are my comments so far:
Comment Actions Heads up in case it affects you refactoring work: https://reviews.llvm.org/rGa60e8927297005898b10a46300d929ba5cf7833c Comment Actions
The reason is that in C++ ODR diagnostics for TagDecl are handled as part of CXXRecordDecl, I didn't want add a path in TagDecl for C/ObjC only.
They are at the top level but not nested ones, I fixed that and should upload a new patch with that next.
Done in upcoming patch.
Ditto.
Thanks for the heads up @rtrieu, I end up including that as part of rG90f58eaeff5f Comment Actions
Comment Actions Thanks for taking a look Richard, comments inline.
Comment Actions Found another case that doesn't emit an error #if defined(FIRST) struct Indirect { int x; }; struct Direct { struct Indirect i; }; #elif defined(SECOND) struct Indirect { double a; }; struct Direct { struct Indirect i; }; #else struct Direct d; #endif According to my debugging there is no error because Direct fields aren't deserialized in -fsyntax-only mode and therefore Indirect definitions aren't compared. But during IRGen there is diagnostic and that's because calculating record layout triggers full deserialization. Also there is diagnostic in C++ because we are dealing with default initialization and DeclareImplicitDefaultConstructor iterates through all the fields deserializing them. I believe the best user experience is consistent diagnostic, so we should emit the error even with -fsyntax-only. If anybody has any objections, please let me know, it would save time. Comment Actions If anybody is curious about anonymous structs/unions, the relevant change is D140055. Comment Actions Ping. Also checked the change on a bunch of internal Objective-C/C code using modules - no new errors.
Comment Actions LGTM generally. It'd better to mention this in the Potentially Breaking Changes section of ReleaseNotes.
Comment Actions Thanks for all your efforts during the review! Mentioned the change in the release notes.
|
We shouldn't store this here; this will make all CXXRecordDecls larger to store a field they will never look at.
We have 27 spare trailing bits in RecordDeclBitfields (28 if you don't add the HasODRHash bit and use 0 to mean "hash not computed"). Can we store this there instead of here?