[PATCH] D140551: [include-cleaner] Don't count references to operators as uses

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 22 06:42:41 PST 2022


sammccall added a comment.

Yeah, I think this makes sense.
I think this sort of thing should ideally be captured in the include-cleaner design doc if there was one. (Doesn't make sense to create one just for this issue, but it seems like a doc that should exist).



================
Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:69
 
+  bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+    // Operators are always ADL extension points, by design references to them
----------------
Rather than override TraverseCXXOperatorCallExpr to do everything *except* call WalkUpFrom, maybe override WalkUpFromCXXOperatorCallExpr to call VisitCXXOperatorCallExpr but not WalkUpFromCallExpr? (With a comment that we don't want to treat operators as calls)



================
Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:71
+    // Operators are always ADL extension points, by design references to them
+    // doesn't count as uses. Ignore them by traversing arguments instead of
+    // children.
----------------
maybe motivate this a little: `(generally the type should provide them)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140551



More information about the cfe-commits mailing list