[PATCH] D139087: [include-cleaner] Handle base class member access from derived class.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 6 03:20:23 PST 2022
hokein added inline comments.
================
Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:68
bool VisitMemberExpr(MemberExpr *E) {
- report(E->getMemberLoc(), E->getFoundDecl().getDecl());
+ // Instead of the FieldDecl for MemberExpr, we report the Decl of
+ // the corresponding record. This is done in order to report
----------------
I'd rephrase something like -- A member expr implies a usage of the class type (e.g. to prevent inserting a header of base class when using base members from a derived object).
================
Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:182
+ testWalk("struct Base { int a; }; struct $explicit^Derived : public Base {};",
+ "void fun(Derived& d) { d.^a; }");
}
----------------
can you add more test cases (the AST node is a bit different among the following cases) to make sure our code handle all of them?
- `Derived foo(); foo().^a;`
- `Derived& foo(); foo().^a;`
- `Derived().^a;`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139087/new/
https://reviews.llvm.org/D139087
More information about the cfe-commits
mailing list