Bug 430138

Summary: qt6-qlatin1stringchar-to-u creates duplicates in replacements yaml file
Product: [Developer tools] clazy Reporter: Jörg Bornemann <joerg.bornemann>
Component: generalAssignee: Jörg Bornemann <joerg.bornemann>
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 Jörg Bornemann 2020-12-08 07:12:25 UTC
SUMMARY

Consider code like this:

---snip---
#define MY_CONSTANT(type, name, value)                \
static const type &name() {                           \
    static const type var{QLatin1String(value)};      \
return var;                                           \
}
#define MY_STRING_CONSTANT(name, value) MY_CONSTANT(QString, name, value)

MY_STRING_CONSTANT(fooProperty, "foo")
MY_STRING_CONSTANT(barProperty, "bar")
---snap---

Applying the qt6-qlatin1stringchar-to-u fixit will create duplicates in the replacements yaml file at the position of QLatin1String within the macro.
This leads to errors like this:

The new replacement overlaps with an existing replacement.
New replacement: ../../../../master/src/lib/corelib/tools/stringconstants.h: 2133:+20:"u"~/""
Existing replacement: ../../../../master/src/lib/corelib/tools/stringconstants.h: 2133:+20:"u"*""


ADDITIONAL INFORMATION

Playground project for this was https://code.qt.io/cgit/qbs/qbs.git/
and the file I ran the fixit on was src/lib/corelib/language/language.cpp
Comment 1 Sergio Martins 2021-01-10 13:46:21 UTC
can you reassign to Lucie ? I'm not finding then name in the assign list
Comment 2 Jörg Bornemann 2021-01-12 12:52:18 UTC
This was fixed with https://invent.kde.org/sdk/clazy/-/merge_requests/29