| Summary: | qstring-ref check does not trigger for toFloat() calls on string temporaries | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | Volker Krause <vkrause> |
| Component: | general | Assignee: | Sergio Martins <smartins> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | smartins |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | http://commits.kde.org/clazy/1c0c5b24c2ac7599459754f1d0e2d9201c983c5d | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
Git commit 1c0c5b24c2ac7599459754f1d0e2d9201c983c5d by Sergio Martins, on behalf of Volker Krause. Committed on 13/03/2016 at 13:02. Pushed by smartins into branch 'master'. qstring-ref: also trigger on QString::toFloat() M +2 -2 checks/qstringref.cpp http://commits.kde.org/clazy/1c0c5b24c2ac7599459754f1d0e2d9201c983c5d |
qtdeclarative/src/quick/util/qquickglobal.cpp contains example code that should trigger (s.left/mid().toFloat()), but does not. This seems to fix it: diff --git a/checks/qstringref.cpp b/checks/qstringref.cpp index 1ef8e88..45b5920 100644 --- a/checks/qstringref.cpp +++ b/checks/qstringref.cpp @@ -58,7 +58,7 @@ static bool isInterestingSecondMethod(CXXMethodDecl *method, const clang::LangOp return false; static const vector<string> list = { "compare", "contains", "count", "startsWith", "endsWith", "indexOf", - "isEmpty", "isNull", "lastIndexOf", "length", "size", "toDouble", "toInt", + "isEmpty", "isNull", "lastIndexOf", "length", "size", "toDouble", "toFloat", "toInt", "toUInt", "toULong", "toULongLong", "toUShort", "toUcs4"}; if (!clazy_std::contains(list, method->getNameAsString())) Reproducible: Always