[PATCH] D151325: [analyzer] Differentiate lifetime extended temporaries
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 25 15:27:32 PDT 2023
NoQ added a comment.
I totally support this! There's no reason why the region wouldn't carry such information.
This patch is surprisingly tiny, but this matches my grep observations: almost nothing in the static analyzer treats `CXXTempObjectRegion` specially. Even in case of live symbols/regions analysis, it simply relies on how temporary region is bound in the Store to the lifetime-extending reference, so it doesn't need to be handled explicitly.
I see that there's no change in `MoveChecker` which treats `CXXTempObjectRegion` specially, and I suspect it may start emitting more warnings after this patch, but I'm not sure if it's a good thing or a bad thing. Could be worth experimenting (eg. by analyzing LLVM itself, it has enough move semantics to demonstrate potential problems).
Do you have any preferences on creating a common base class for `CXXTempObjectRegion` and `CXXLifetimeExtendedObjectRegion`? Or, as an opposite extreme, simply add a nullable `ExD` field to `CXXTempObjectRegion` instead of making a new class? Both could save us some code when these regions do need to be treated uniformly, but it doesn't look like a popular situation to worry about.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151325/new/
https://reviews.llvm.org/D151325
More information about the cfe-commits
mailing list