hokein added inline comments.

================
Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:65
+    Expr *BE = E->getBase()->IgnoreImpCasts();
+    RecordDecl *RD = BE->getType()->getAsRecordDecl();
+    report(E->getMemberLoc(), RD);
----------------
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:
1) pointer type (`Derived *`)
2) reference type (`Derived &`)
3) a dependent type

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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139087/new/

https://reviews.llvm.org/D139087

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to