Details
- Reviewers
lebedev.ri JonasToth george.karpenkov - Commits
- rG4305993c89de: [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.
rL342409: [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.
rC342409: [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.
Diff Detail
- Repository
- rL LLVM
Event Timeline
Thank you for working on this!
Ok, got the results.
Without that change, my check fires ~1k times.
With this change it only fires 572 times.
So this clearly changes things.
The entirety of the new build log:
I see no mentions of emplace_back/push_back.
Though some of that is still false-positives (pointers, va_arg, callback lambdas passed as templated function param), but i'll file further bugs i guess.
As far i'm concerned, this is good.
But please wait for the actual code review.
Once again, thank you for working on this!
Thank you very much for the good work from my side as well!
unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
---|---|---|
387 ↗ | (On Diff #165578) | I am thinking about the correctness of the change. If we have this case: std::string s1 = "Hello World!"; std::string s2 = std::move(s1); s1 gets mutated, but it looks like it would not be considered as mutation? On the other hand int i1 = 42; int i2 = std::move(i1); should resolve in a copy i1 and therefor not be a mutation. Could you please add tests demonstrating this difference and the correct diagnostic detection for that. Potentially interesting:
These thoughts are just thinking and writing, I just wondered that moving a variable with std::move is not considered as mutation here, even though there are cases were it is actually a mutation. |
unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
---|---|---|
387 ↗ | (On Diff #165578) |
unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
---|---|---|
387 ↗ | (On Diff #165578) | Added these tests:
Didn't test array because array can't be assigned (so copy/move isn't relevant) and passing array to function can only be done via reference (passing by value results in array to pointer decay) so no copy/move there as well. |
The last testcase i mentioned, after that LGTM
unittests/Analysis/ExprMutationAnalyzerTest.cpp | ||
---|---|---|
441 ↗ | (On Diff #165684) | You could add a final test for struct S { S(); S(S s); S& operator(S s); }; Note that the copy and assignment take by value, so should not resolve in a mutation by move. Then i think the testsuite covers all potential variants |