Skip to content

enabled modernize-use-trailing-return-type clang-tidy check and fixed lamdba-related warnings only#7750

Draft
firewave wants to merge 2 commits into
cppcheck-opensource:mainfrom
firewave:clang-21-x
Draft

enabled modernize-use-trailing-return-type clang-tidy check and fixed lamdba-related warnings only#7750
firewave wants to merge 2 commits into
cppcheck-opensource:mainfrom
firewave:clang-21-x

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

if (Token::simpleMatch(args[1], "(") && Token::simpleMatch(args[1]->astOperand1(), ". c_str") && args[1]->astOperand1()->astOperand1()) {
const std::list<ValueFlow::Value>& contValues = args[1]->astOperand1()->astOperand1()->values();
auto it = std::find_if(contValues.cbegin(), contValues.cend(), [](const ValueFlow::Value& value) {
auto it = std::find_if(contValues.cbegin(), contValues.cend(), [](const ValueFlow::Value& value) -> bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we should be adding an explicit return type on lambdas when it can be deduced.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helps to deduce issue if you accidentally change the result. I had had such a case where I returned a wrong variable but it was accepted since the result was implicitly casted later on. It also helps with readability in case of bigger lambdas.

There is also a long-standing shortcoming in Clang (no idea bout others) with auto-deduced types generating worse code (I do not have the ticket handy right now).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a long-standing shortcoming in Clang (no idea bout others) with auto-deduced types generating worse code (I do not have the ticket handy right now).

See
llvm/llvm-project#144323
llvm/llvm-project#38674

@sonarqubecloud
Copy link
Copy Markdown

@firewave firewave marked this pull request as draft August 20, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants