Arguments not for all attributes are covered. More can be added later as
needed.
rdar://100482330
Differential D135472
[ODRHash] Hash attributes on declarations. vsapsai on Oct 7 2022, 11:24 AM. Authored by
Details Arguments not for all attributes are covered. More can be added later as rdar://100482330
Diff Detail
Event Timeline
Comment Actions I guess the reason why we didn't check odr violation for attributes is that the attributes was not a part of declarations in C++ before. But it is odd to skip the check for attributes from the perspective of users. So I think this one should be good. The only concern is that it misses too many checks for attributes. Do you plan to add it in near future or in longer future? And I guess we need to mention this in ReleaseNotes in Potential Breaking Changes section.
Comment Actions Most of my concerns change based on the feedback others have given, so after those are dealt with, I'll do another depever view.
Comment Actions I think we haven't seen many problems with attribute mismatches because in existing code attributes are often hidden behind macros. And we have sugar MacroQualifiedType that causes the definitions #define NODEREF __attribute__((noderef)) struct StructWithField { int NODEREF *i_ptr; }; struct StructWithField { int __attribute__((noderef)) *i_ptr; }; to be treated as incompatible. But the keyword alignas is used without macros and more attributes can be used in multiple compilers without macros. That's why I think it is useful to detect and to diagnose mismatches in attributes. In the near future I was planning to add various Objective-C and Swift attributes. For other attributes I don't know which are high-value. I definitely want to check attributes affecting the memory layout (alignment, packing) and believe I've addressed them (totally could have missed something). Good idea, will do.
Comment Actions
It looks like you're planning to add them one by one, or do I misunderstand? It looks not so good to add them one by one. Maybe it'll be a better idea to add them in the Attr.td?
Comment Actions
Comment Actions Given all the discussion about which attributes should be added to ODR hash, I think it is useful at this point to have TableGen infrastructure to get this information from Attr.td. So I'll work on that.
Comment Actions LGTM basically. Our discussion is mainly about the future work in Attr.td and not this patch. So I think they are not blocking issues.
Comment Actions To fix pre-merge errors like error: 'error' diagnostics seen but not expected: File .../clang/test/Modules/Output/odr_hash.cpp.tmp/Inputs/first.h Line 3797: ... found 'AlignedDoublePtr' with attribute ' __attribute__((align_value(0xb7dc9b8)))' posted D135931. Comment Actions Thank you, I think that's a good approach for the moment. Once you have the basic framework in place, we can opt in the uncontroversial attributes (like, I think anything inheriting from TypeAttr or DeclOrTypeAttr should be automatically opted in and any Argument whose Fake flag is set should not contribute to the ODR hash) and then we can do a follow-up to figure out how to distinguish "definitely an ODR violation" attributes from "not an ODR violation but still something we want to find a way to alert users about".
|