Set FriendObjectKind in case of decls.
RD->pushFriendDecl(FrD); statement removed from L2240 since it is done in function Create(..).
IsStructurallyEquivalent function(s) of FriendDecl and dependent decls (RecordDecl, FunctionDecl) added.
Test cases added,
Details
Diff Detail
Event Timeline
Sorry for the late review, I saw your ping but the last week was busy. Anyway, thanks for the tests!
lib/AST/ASTImporter.cpp | ||
---|---|---|
2219 | Since getFriendObjectKind() returns an enum, in my opinion it's better style to check explicitly whether it != FOK_None. | |
2222 | From a close reading of setObjectOfFriendDecl(), it looks to me like we might not set the IDNS_Tag or IDNS_Ordinary bits in IdentifierNamespace since we're passing PerformFriendInjection = false and since getPreviousDecl() might return nullptr in ToContext. This means that getFriendObjectKind() might return FOK_Undeclared whereas it returned FOK_Declared for the original. Does this matter? | |
lib/AST/ASTStructuralEquivalence.cpp | ||
922 | Would it be appropriate to emit a diagnostic here as well? | |
1152 | What if D1->getFriendDecl() != nullptr but D2->getFriendType() != nullptr or vice versa? | |
1162 | For attributes on the function (e.g., __attribute__ ((always_inline))) are these relevant to structural equvalence? Or does really only the type matter? | |
1372 | What about if FrD1->getFriendDecl() && FrD2->getFriendDecl()? |
Could you add some context?
Generally LGTM!
One high level comment, I think we need to modify the importing of CXXRecordDecls to properly support friend declarations. When we are building the redeclarable chain of CXXRecordDecl declarations I suspect we also need to consider names in the IDNS_TagFriend namespace.
lib/AST/ASTImporter.cpp | ||
---|---|---|
2260 | This will assert unless the IdentifierNamespace is properly imported. See https://github.com/Ericsson/clang/pull/266/files#diff-7f5f26dbdb3322c6308b1018ff0dbe5aR6735 |
I have commited this patch (r330847) but unfortunately "refactored" the differential revision link from the commit message out. Added it as a dependent commit.
This will assert unless the IdentifierNamespace is properly imported. See https://github.com/Ericsson/clang/pull/266/files#diff-7f5f26dbdb3322c6308b1018ff0dbe5aR6735