cppcheck
cppcheck copied to clipboard
valueflow.cpp: limit `const_cast` to the necessary calls
This shows that there's only two calls which actually require the const_cast so there's no need to do it arbitrary all over the code (there was even at least one redundant one). The valueFlowGeneric*() probably also just require this just for setTokenValue() so it might be possible to get rid of those as well.
I dont really understand why we are just reducing const_cast instead of fixing them in the first place, as this seems to make it harder to fix in the future.
I dont really understand why we are just reducing
const_castinstead of fixing them in the first place, as this seems to make it harder to fix in the future.
It's an incremental approach. I mentioned the intentions in my initial comment.
Closing as though the idea to pinpoint the exact location where something is actually modifying is enticing the usage of const_cast should be avoided in general. So actually getting rid of those calls makes way more sense. Also we have the constParameter* and constVariable checks which would help to properly propagate const where possible.
Also this can no longer be properly rebased.