This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Aliasing: Add support for aggregates with references.
ClosedPublic

Authored by NoQ on May 3 2021, 3:30 PM.

Details

Summary

When a variable is used in an initializer of an aggregate for its reference-type field this counts as aliasing.

This covers a real problem inspired by @aaron.ballman's comment in D96215#2554178. Because in the two checkers that use alias analysis (bugprone-infinite-loop and bugprone-redundant-branch-condition) only variables of plain integral types are being analyzed, we don't seem to need to worry about arrays yet. Arrays of references (unlike structures of references) don't exist. And if an array element is used as a counter (to be decomposed into a reference to an element type), it's a non-starter for those checkers as well.

Diff Detail