Skip to content

unify detection of object mutation in clang-tidy checks #106374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
firewave opened this issue Aug 28, 2024 · 1 comment
Open

unify detection of object mutation in clang-tidy checks #106374

firewave opened this issue Aug 28, 2024 · 1 comment
Labels
clang-tidy enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@firewave
Copy link

firewave commented Aug 28, 2024

Weirdly, those two checks are using distinct methods to infer whether the underlying container is mutated. unnecessary-copy-initialization uses doesNotMutateObject while performance-unnecessary-value-param uses FunctionParmMutationAnalyzer.

So unfortunately this change won't improve performance-unnecessary-value-param.

I can have a look at unifying both in a subsequent PR.

Originally posted by @legrosbuffle in #94362 (comment)

@firewave firewave added the enhancement Improving things as opposed to bug fixing, e.g. new or missing feature label Aug 28, 2024
@HerrCai0907
Copy link
Contributor

I think the target of two functions is totally different.
isOnlyUsedAsConst want to detect the usage of object itself.
MutationAnalyzer want to detect mutation of the symbol of this object.

e.g.
For symbol a,
a = A{}, isOnlyUsedAsConst should not treat it as non-const usage but MutationAnalyzer should treat it as mutation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

No branches or pull requests

2 participants