Fix code completion for nameless structs/unions with the same member
ClosedPublic

Authored by buschinski on Jul 14 2019, 2:43 PM.

Details

Summary

The code completion always shows the first declaration it finds for a matching name.
This works fine as long as the parent has a name, for nameless structs/unions it just returns the first declaration it finds.
Fix this by checking that the found declaration has the expected type.

BUG: 409041

Test Plan

See https://bugs.kde.org/show_bug.cgi?id=409041 for example code
or see the unit test in this patch.

Diff Detail

Repository
R32 KDevelop
Lint
Lint Skipped
Unit
Unit Tests Skipped
buschinski created this revision.Jul 14 2019, 2:43 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptJul 14 2019, 2:43 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
buschinski requested review of this revision.Jul 14 2019, 2:43 PM
apol accepted this revision.Jul 15 2019, 1:14 AM
This revision is now accepted and ready to land.Jul 15 2019, 1:14 AM
buschinski edited the summary of this revision. (Show Details)Jul 19 2019, 4:16 PM
buschinski closed this revision.Jul 19 2019, 5:21 PM

Seems the introduced QStringLiteral as default argument here in the template method executeCompletionTest() makes ubuntu bionic's GNU 7.4.0 C++ compiler screw up. At least there is some timely coincidence that the KDevelop builds on neon CI started to fail after this commit, with this error:

05:00:37 [100%] Building CXX object plugins/clang/tests/CMakeFiles/test_codecompletion.dir/test_codecompletion.cpp.o
05:00:37 plugins/clang/tests/CMakeFiles/test_codecompletion.dir/build.make:62: recipe for target 'plugins/clang/tests/CMakeFiles/test_codecompletion.dir/test_codecompletion.cpp.o' failed
05:00:37 make[4]: Leaving directory '/workspace/build/obj-x86_64-linux-gnu'
05:00:37 /tmp/ccrWtnBp.s: Assembler messages:
05:00:37 /tmp/ccrWtnBp.s:65174: Error: symbol `_ZZNK12_GLOBAL__N_1UlvE_clEvE15qstring_literal' is already defined
05:00:37 /tmp/ccrWtnBp.s:68144: Error: symbol `_ZZNK12_GLOBAL__N_1UlvE_clEvE15qstring_literal' is already defined
05:00:37 make[4]: *** [plugins/clang/tests/CMakeFiles/test_codecompletion.dir/test_codecompletion.cpp.o] Error 1
05:00:37 CMakeFiles/Makefile2:18121: recipe for target 'plugins/clang/tests/CMakeFiles/test_codecompletion.dir/all' failed
05:00:37 make[3]: *** [plugins/clang/tests/CMakeFiles/test_codecompletion.dir/all] Error 2

from https://build.neon.kde.org/job/bionic_unstable_extras_kdevelop_bin_amd64/220/console

The symbols demangled is "(anonymous namespace)::{lambda()#1}::operator()() const::qstring_literal", thus this is the "static const QStaticStringData<Size> qstring_literal" from the QStringLiteral macro code about which it seems to complain being defined 3x. Though this is in a lambda, which should be instantiated each time when used, no? how could we clash here...
[15:48] <volker|office> the symbol is not including the template arguments, but might be created per instantiation of the template
[15:49] <volker|office> it's the same content in all cases, so either the compiler merges them, or it needs to give them a unique name

Seems we need to work-around by not using the QStringLiteral here, and have to pass things explicitly for now.

Fail related to this commit confirmed by:
[15:58] <Riddellll> buscher: frinring it fails to link locally but when I revert d1f58562046494b78e17c50c2fdab5c2800d9aaf it's all good

Work-around pushed as 8a18a08cf17c85000c7082d5192855430a519bab , seems to pass build also with neon ci and the gcc 7.4.0 there.