Bug 391854 - New check "Avoid duplicated QStringLiterals"
Summary: New check "Avoid duplicated QStringLiterals"
Status: RESOLVED NOT A BUG
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-14 14:12 UTC by Roman
Modified: 2018-03-14 20:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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