kdev-clang: Invalid inheriters list.

Milian Wolff mail at milianw.de
Sat Nov 14 16:04:34 UTC 2015


On Donnerstag, 12. November 2015 20:30:44 CET Gustaw Smolarczyk wrote:
> Hi,
> 
> First, I want to say that I am new to the kdevelop internals. Any
> guidance would be beneficial.
> 
> There is a problem when using kdev-clang with the list of inheritors
> of a class. It lists not only the inheritors but also the inner
> classes.
> 
> To reproduce:
> class X { class Y {}; };
> 
> After parsing and hovering over X, it will say that Y inherits from X.
> 
> I have tried to track why is this information wrong. I have found that
> DUChainUtils::getInheritors() function uses class declaration's
> importers list for this purpose. However, kdev-clang marks the inner
> class as an importer of the outer class. I suspect the old cpp plugin
> didn't do so.
> 
> Is the behaviour of kdev-clang correct? If so, should the
> getInheritors() function be fixed not to follow inner classes?

Oh, that sounds like a bug. I'll try to look into the code and figure out a 
way to improve the situation.

Do I understand you correctly, that you are interested in diving into the code 
yourself to fix this (and future) problems? A good first step to solve this 
problem would be to add a unit test. Either JSON-based (see tests/files), or 
via a C++ test (tests/test_duchain.cpp). With your example code it should be 
quite straight-forward to write a test which detects this errors.

Once done, we'll need to fix the bug by figuring out a way to solve this. If 
DUChainUtils::getInheritors is only looking at the imports than this sounds 
wrong. Instead, ClassDeclaration::baseClass should be used. I don't know 
without looking what kdev-clang is currently doing. So if you want to fix it, 
feel free to look into it! If you have any question, don't hesitate to ask 
here or on IRC (#kdevelop on Freenode).

Cheers
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20151114/8a7aca5e/attachment.sig>


More information about the KDevelop-devel mailing list