-
Couldn't load subscription status.
- Fork 1.5k
fixed some -Wnrvo Clang compiler warnings
#7883
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,10 +139,12 @@ FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const Token * | |
| if (!opTok) | ||
| opTok = tok->next(); | ||
| std::pair<const Token*, const Token*> startEndTokens = opTok->findExpressionStartEndTokens(); | ||
| FwdAnalysis::Result result = | ||
| checkRecursive(expr, startEndTokens.first, startEndTokens.second->next(), exprVarIds, local, true, depth); | ||
| if (result.type != Result::Type::NONE) | ||
| return result; | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is quite pedantic by clang imho. FwdAnalysis::Result is small and simple data. But yes if we want to turn on the warning then you have to fix all warnings so I guess there's not much we can do. |
||
| FwdAnalysis::Result result = | ||
| checkRecursive(expr, startEndTokens.first, startEndTokens.second->next(), exprVarIds, local, true, depth); | ||
| if (result.type != Result::Type::NONE) | ||
| return result; | ||
| } | ||
|
|
||
| // #9167: if the return is inside an inner class, it does not tell us anything | ||
| if (!inInnerClass) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -564,9 +564,9 @@ template<> std::string MathLib::toString<double>(double value) | |
| result << value; | ||
| std::string s = result.str(); | ||
| if (s == "-0") | ||
| return "0.0"; | ||
| if (s.find_first_of(".e") == std::string::npos) | ||
| return s + ".0"; | ||
| s = "0.0"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm I like the old code better here from a readability point of view. |
||
| else if (s.find_first_of(".e") == std::string::npos) | ||
| s += ".0"; | ||
| return s; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1394,18 +1394,20 @@ namespace { | |
| if (conditions1.empty()) | ||
| return unknown(); | ||
| std::unordered_map<nonneg int, ValueFlow::Value> condValues = executeAll(conditions1, &b); | ||
| bool allNegated = true; | ||
| ValueFlow::Value negatedValue = unknown(); | ||
| for (const auto& p : condValues) { | ||
| const ValueFlow::Value& v = p.second; | ||
| if (isTrueOrFalse(v, b)) | ||
| return v; | ||
| allNegated &= isTrueOrFalse(v, !b); | ||
| if (allNegated && negatedValue.isUninitValue()) | ||
| negatedValue = v; | ||
| { | ||
| bool allNegated = true; | ||
| ValueFlow::Value negatedValue = unknown(); | ||
| for (const auto& p : condValues) { | ||
| const ValueFlow::Value& v = p.second; | ||
| if (isTrueOrFalse(v, b)) | ||
| return v; | ||
| allNegated &= isTrueOrFalse(v, !b); | ||
| if (allNegated && negatedValue.isUninitValue()) | ||
| negatedValue = v; | ||
| } | ||
| if (condValues.size() == conditions1.size() && allNegated) | ||
| return negatedValue; | ||
| } | ||
| if (condValues.size() == conditions1.size() && allNegated) | ||
| return negatedValue; | ||
| if (n > 4) | ||
| return unknown(); | ||
| if (!sortConditions(conditions1)) | ||
|
|
@@ -1805,7 +1807,7 @@ namespace { | |
| if (elseStart) | ||
| result = execute(elseStart->scope()); | ||
| } else { | ||
| return {unknown()}; | ||
| result = {unknown()}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is less obvious what happens here. if the loop continues then other results can be returned.. so I want to see an unconditional return. |
||
| } | ||
| if (!result.empty()) | ||
| return result; | ||
|
|
||
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.
this looks more weird imho.