[PATCH] D101790: [clang-tidy] Aliasing: Add support for passing the variable into a function by reference.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 3 15:19:26 PDT 2021


NoQ created this revision.
NoQ added reviewers: alexfh, gribozavr2, aaron.ballman, vsavchenko.
Herald added subscribers: martong, mgehre, xazax.hun.
NoQ requested review of this revision.
Herald added a project: clang-tools-extra.

This is a fairly basic form of aliasing that as we've noticed in D96215 <https://reviews.llvm.org/D96215> hasn't been covered yet.

At the same time this patch causes unfortunate false negatives on the regression tests for `bugprone-redundant-branch-condition` that has a builtin incomplete but slightly more robust solution to the same problem. These false negatives are something that we didn't really have a right to warn at until we've had a more flow-sensitive alias analysis. Like, they're valid warnings but we can't emit them with the analysis that we have without consciously introducing false positives as well. So I think it's a judgement call. I'm definitely in favor of landing it despite the false negatives it introduces but this may go against clang-tidy's philosophy on this issue so I'm open to not landing it.

The patch uses `AnyCall` in order to cover 5 different AST node kinds for call-like expressions none of which inherit from `CallExpr` (apart from `CallExpr` itself).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D101790

Files:
  clang-tools-extra/clang-tidy/utils/Aliasing.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101790.342562.patch
Type: text/x-patch
Size: 4314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210503/531dff7a/attachment-0001.bin>


More information about the cfe-commits mailing list