Handles dependent type members in AST.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
92 | Rebase the current patch. Move the implementation in the resolveType method, then this method will just pass the BaseType to resolveType. | |
104 | if we just aim to support the vector<T>().size() case, we only need this part of code right? | |
106 | You can simplify it in a single if statement: if (const TemplateSpecializationType *TS = Type->getAs<TemplateSpecializationType>()) | |
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp | ||
260 | Thanks for coming up these cases. IMO a more reasonable behavior would be that the target symbol of the reported reference is Nested rather than the outer class Base, but implementing it would require some dependent name lookup in the Base (in clangd we have a similar thing HeuristicResolver, but it is sophisticated). I think it is find to ignore these cases (these cases are more tricky, and less interesting to us) right now, this would simplify the implementation. Note that the existing behavior of accessing a member expr from a dependent type is that we don't report any reference on d.^method(), so the original "include base header via a base-member-access from a derived-class object" issue doesn't exist. We aim to improve this behavior for some critical cases. The critical case we want to support is the vector<T>().size(), if other cases come up in the furture, we could revisit it. |
thanks, looks mostly good, I think we can simplify the unittest further.
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
37 | nit: we can use const auto* here as the type is explicitly spelled in the getAs<XXX> | |
38 | nit: remove the {} around the if statement | |
91 | nit: I will remove this blank line, to make VisitMemberExpr and VisitCXXDependentScopeMemberExpr group together as they both achieve the same goal. | |
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp | ||
247 | I think keeping the above 3 test cases is enough, I would probably add them to the exiting MemberExprs test (with a comment saying this is dependent-type case). | |
249 | I think we can remove this test, this test duplicates the first test | |
251 | And this case as well |
clang-tools-extra/include-cleaner/lib/WalkAST.cpp | ||
---|---|---|
36–37 | please rebase the patch, this API is changed in https://github.com/llvm/llvm-project/commit/0ab57bdc9745bfc8147831c09ed05073f87e7040, and the TemplateSpecializationType is handled already (to fix the sugar type issue). |
nit: we can use const auto* here as the type is explicitly spelled in the getAs<XXX>