Bug 391854

Summary: New check "Avoid duplicated QStringLiterals"
Product: [Developer tools] clazy Reporter: Roman <dismine>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal CC: smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Roman 2018-03-14 14:12:21 UTC
I found two articles about QStringLiteral: https://woboq.com/blog/qstringliteral.html and http://blog.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral/. According to them there is binary overhead. For plain literals and QLatin1String, compilers try to consolidate identical literals so that they are not duplicated. For QStringLiteral, identical strings cannot be merged.

It would be nice to have a check that can warn about this overhead. I am not sure which level to use to search duplicates (unit or whole project), but probably it should be possible at least mimic compiler optimization and warn about such cases.
Comment 1 Sergio Martins 2018-03-14 20:03:46 UTC
Good idea, but this is out of scope for clazy, as it operates on a translation-unit level.

Could be a job for a separate tool, like a linker plugin though