-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
valueflow.cpp: reduced some variable scopes/lifetimes #7076
Conversation
…lues()` until necessary
This highlights some cases we could report via |
@@ -3699,8 +3699,11 @@ static void valueFlowSymbolicInfer(const SymbolDatabase& symboldatabase, const S | |||
if (astIsFloat(tok->astOperand2(), false)) | |||
continue; | |||
|
|||
SymbolicInferModel leftModel{tok->astOperand1()}; | |||
std::vector<ValueFlow::Value> values = infer(leftModel, tok->str(), 0, tok->astOperand2()->values()); | |||
std::vector<ValueFlow::Value> values; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't an opinion but we could also write:
std::vector<ValueFlow::Value> values = [tok](){
SymbolicInferModel leftModel{tok->astOperand1()};
return infer(leftModel, tok->str(), 0, tok->astOperand2()->values());
}();
Use the syntax you like..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not find that more readable. I am also not sure fi that might introduce some overhead.
I mainly changed this because I was debugging the lifetime of the infer models at some point and was confused that two of them were alive at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok np
No description provided.