Bug 360338

Summary: qstring-ref check does not trigger for toFloat() calls on string temporaries
Product: [Developer tools] clazy Reporter: Volker Krause <vkrause>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: normal CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Volker Krause 2016-03-09 21:23:57 UTC
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
Comment 1 Sergio Martins 2016-03-13 13:02:41 UTC
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