Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
65 | This is not safe, we can get a nullptr if this type is not a normal RecordType. I think there are more cases we need to handle:
For the 3), some code like std::vector<T>().size(), it is tricky -- because we can't get any decl from a dependent type, we need some heuristics (in clangd we have some bits), we don't need to do that in this patch. In the code implementation, we should add a dedicated handleType(QualType) helper to handle all these cases, so VisitMemberExpr, VisitCXXDependentScopeMemberExpr callbacks can just dispatch the type to this helper. |
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
62 | comment doesn't really say why. maybe include something along the lines as we want to mark usage of most specific type (e.g. derived class, when using members from the base). |
Add more comments. Add unimplemented VisitCXXDependentScopeMemberExpr method with a FIXME comment.
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
65 | Ok, added pointer types. Reference types seem to be working already. Added a FIXME for dependent members. |
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
68 | nit: just report(E->getMemberLoc(), getDeclFromTye(Type));. | |
71 | Be more specific about the comment, something like // FIMXE: support the dependent type case like "std::vector<T>().size();". I will move this FIXME to VisitMemberExpr, and remove this function. | |
75 |
| |
76 | nit: remove the surrounding {} | |
79 | nit: just return Type->getAsRecordDecl();. |
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
62–66 | 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). | |
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp | ||
182 | 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?
|
Thanks, looks good.
Add a Fix <github issue link> in the commit message.
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
61 | while reading it again, I realize that there is another case (operator overloading) we probably want to handle it as well. It is a more tricky case, no need to worry about it in this patch. |
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
61 | Thank you. If you'd like me to take care of it, please file an issue with an example that needs to be taken care of :) |
while reading it again, I realize that there is another case (operator overloading) we probably want to handle it as well. It is a more tricky case, no need to worry about it in this patch.