Bug 357966 - MSVC does not support QStringLiteral with multi-string initializer
Summary: MSVC does not support QStringLiteral with multi-string initializer
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-14 08:17 UTC by Kåre Särs
Modified: 2016-01-14 23:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kåre Särs 2016-01-14 08:17:19 UTC
Strings that are separated into multiple parts don't work on Windows
together with QStringLiteral as the first string is interpreted as a
wide (16bit) string, and the second one as a narrow (8bit) string. 
(Copy pasted from Patrick Spendrin's RRs)

This fails:
QStringLiteral("Foo"   "Baar"); 
and could be replaced with QLatin1String()

This fails also but can not be replaced with QLatin1String as it does not take .arg()
QStringLiteral("Foo %1" "Baar").arg("Foo");
Here the strings would have to be joined....

We have had some breakage on Windows when Clazy fixes have been committed...

Clazy is a great tool. Keep up the good work :)


Reproducible: Always
Comment 1 Sergio Martins 2016-01-14 09:57:50 UTC
clazy has an msvc-compat compat option:
export CLAZY_EXTRA_OPTIONS="qstring-uneeded-heap-allocations-msvc-compat"

which will honour those cases.

I'll turn on msvc-compat by default, and introduce a no-msvc-compat option instead.
Comment 2 Sergio Martins 2016-01-14 10:30:32 UTC
Git commit 04a6c6665e73da087cec7d66039830d2932305f7 by Sergio Martins.
Committed on 14/01/2016 at 10:29.
Pushed by smartins into branch 'master'.

qstring-uneeded-heap-allocations: Rename msvc-compat to no-msvc-compat

Meaning msvc-compat is the default and if you don't want it you should:
export CLAZY_EXTRA_OPTIONS="qstring-uneeded-heap-allocations-no-msvc-compat"

Helps stopping annoying our windows friends.

Ignoring multi-string literals is not implemented yet, only ignoring list initialization.

M  +3    -3    checks/README-qstring-uneeded-heap-allocations
M  +3    -3    checks/qstringuneededheapallocations.cpp
M  +11   -4    tests/qstring-uneeded-heap-allocations/config.json
M  +2    -2    tests/qstring-uneeded-heap-allocations/main.cpp
M  +0    -2    tests/qstring-uneeded-heap-allocations/main.cpp.expected
M  +2    -2    tests/qstring-uneeded-heap-allocations/main.cpp_fixed.cpp.expected
A  +9    -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp     [License: UNKNOWN]  *
A  +2    -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp.expected
A  +9    -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp_fixed.cpp.expected

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


http://commits.kde.org/clazy/04a6c6665e73da087cec7d66039830d2932305f7
Comment 3 Kåre Särs 2016-01-14 10:50:20 UTC
Thanks :)
Comment 4 Sergio Martins 2016-01-14 23:54:09 UTC
Git commit 9c1458765dbdad21739cbe2b9154667657d2352e by Sergio Martins.
Committed on 14/01/2016 at 23:49.
Pushed by smartins into branch 'master'.

qstring-uneeded-heap-allocations: Improve msvc compat

Now we don't warn when using multi token literals like:
QString s = "foo" "bar";

because MSVC is dumb

M  +19   -2    checks/qstringuneededheapallocations.cpp
M  +8    -8    tests/qstring-uneeded-heap-allocations/main.cpp
M  +0    -3    tests/qstring-uneeded-heap-allocations/main.cpp.expected
M  +8    -8    tests/qstring-uneeded-heap-allocations/main.cpp_fixed.cpp.expected
M  +13   -0    tests/qstring-uneeded-heap-allocations/msvc-compat.cpp
M  +13   -0    tests/qstring-uneeded-heap-allocations/msvc-compat.cpp_fixed.cpp.expected
M  +12   -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp
M  +5    -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp.expected
M  +12   -0    tests/qstring-uneeded-heap-allocations/no-msvc-compat.cpp_fixed.cpp.expected

http://commits.kde.org/clazy/9c1458765dbdad21739cbe2b9154667657d2352e