Import declarations in correct order if a class contains
multiple redundant friend (type or decl) declarations.
If the order is incorrect this could cause false structural
equivalences and wrong declaration chains after import.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hello Balazs,
This look almost good to me except some comments inline.
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
3649 | It's better to turn the tuple into a named struct (FriendCountAndPosition?) to make the code more readable. | |
3650 | const FriendDecl *FD? | |
3653 | const? | |
3654 | if (const TypeSourceInfo *FriendType = FD->getFriendType()) { QualType TypeOfFriend = FriendType->getType().getCanonicalType(); ... ? | |
3729 | Why not strictly equal? | |
clang/unittests/AST/ASTImporterTest.cpp | ||
3978 | clang-tidy wants this to be const auto* Code. | |
4003 | clang-tidy wants this to be const auto* Code. | |
clang/unittests/AST/StructuralEquivalenceTest.cpp | ||
763 | We need to place spaces after foo. | |
773 | Could you please add a positive test with two struct foo{ friend class X; friend class Y; };", structures as well? |
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
3654 | In the current way the branches (after if and else) look relatively similar, I like that better. | |
3729 | D id the Decl to be imported, ImportedEquivalentFriends contains the similar friends already imported. This may be less than the total (0 at first time) if not all friends are imported yet (should be a temporary state). The next line checks for equality. |
LGTM WDYT @teemperor
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
3652 | uint32_t Is there a reason to not prefer fixed width integer types? | |
3654 | uint32_t | |
3658 | uint32_t | |
3674 | Can we refactor to not repeat code? They look identical. Duplicate code is a source for errors when once piece of code is fixed both the other is not etc | |
clang/unittests/AST/ASTImporterTest.cpp | ||
3978 | Does auto really buy us anything here? Why not use use const char*? | |
4003 | const char*? |
clang/lib/AST/ASTImporter.cpp | ||
---|---|---|
3652 | I do not know about any reason, but in ASTImporter.cpp uint32_t does not appear but unsigned and unsigned int yes. Why can be fixed width type better that the default-sized int? |
It's better to turn the tuple into a named struct (FriendCountAndPosition?) to make the code more readable.