Discussion:
[umbrello] [Bug 397664] New: C++ importer does not correctly detect generalization in template classes
Thomas Jansen
2018-08-20 16:08:10 UTC
Permalink
https://bugs.kde.org/show_bug.cgi?id=397664

Bug ID: 397664
Summary: C++ importer does not correctly detect generalization
in template classes
Product: umbrello
Version: Git
Platform: Other
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: NOR
Component: general
Assignee: umbrello-***@kde.org
Reporter: ***@mithi.net
Target Milestone: ---

Created attachment 114517
--> https://bugs.kde.org/attachment.cgi?id=114517&action=edit
Initial patch

Umbrello does not correctly parse existing C++ code that uses template classes
when trying to detect a generalization. I debugged the code and found that in
CppTree2Uml::parseBaseClause the baseName contains the template parameters as
part of the name which does not match the name of the class (that has only the
name of the class without any template parameters).

By stripping the template parameters from baseName the generalization is
detected.

The attached patch works for my needs and can be used as a starting point.

Test Cases:

Generalization detection works when not using template classes:
class u1 {
public:
u1() {}
~u1() {}
};

class u2: public u1 {
public:
u2() {}
~u2() {}
};

It does not work when using template classes:
template <class T>
class t1 {
public:
t1() {}
~t1() {}
};

template <class T>
class t2: public t1<T> {
public:
t2() {}
~t2() {}
};
--
You are receiving this mail because:
You are the assignee for the bug.
Ralf Habacker
2018-08-21 09:19:54 UTC
Permalink
https://bugs.kde.org/show_bug.cgi?id=397664

Ralf Habacker <***@freenet.de> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
Latest Commit| |https://commits.kde.org/umb
| |rello/f7c4d22cf3663d1346560
| |55226c7207c88bbef97
Version Fixed In| |2.26.1 (KDE Applications
| |18.08.1)

--- Comment #1 from Ralf Habacker <***@freenet.de> ---
Git commit f7c4d22cf3663d134656055226c7207c88bbef97 by Ralf Habacker.
Committed on 21/08/2018 at 09:19.
Pushed by habacker into branch 'Applications/18.08'.

Fix 'C++ importer does not correctly detect generalization in template classes'

With this commit a related test case has been added.
FIXED-IN:2.26.1 (KDE Applications 18.08.1)

A +13 -0 test/import/cxx/templates.h [License: UNKNOWN] *
M +10 -0 umbrello/codeimport/kdevcppparser/cpptree2uml.cpp

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


https://commits.kde.org/umbrello/f7c4d22cf3663d134656055226c7207c88bbef97
--
You are receiving this mail because:
You are the assignee for the bug.
Ralf Habacker
2018-08-21 09:20:06 UTC
Permalink
https://bugs.kde.org/show_bug.cgi?id=397664

Ralf Habacker <***@freenet.de> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |***@freenet.de

--- Comment #2 from Ralf Habacker <***@freenet.de> ---
Thanks for your contribution
--
You are receiving this mail because:
You are the assignee for the bug.
Ralf Habacker
2018-08-22 11:40:53 UTC
Permalink
https://bugs.kde.org/show_bug.cgi?id=397664

--- Comment #3 from Ralf Habacker <***@freenet.de> ---
Git commit fc7dd9e1578d289a322de12cc33eabf91405b4a2 by Ralf Habacker.
Committed on 22/08/2018 at 11:40.
Pushed by habacker into branch 'Applications/18.08'.

More robust determination of the name of the base class with template
parameters using the abstract syntax tree

This should also work with multiple template parameters.

M +8 -14 umbrello/codeimport/kdevcppparser/cpptree2uml.cpp

https://commits.kde.org/umbrello/fc7dd9e1578d289a322de12cc33eabf91405b4a2
--
You are receiving this mail because:
You are the assignee for the bug.
Ralf Habacker
2018-08-22 11:47:12 UTC
Permalink
https://bugs.kde.org/show_bug.cgi?id=397664

--- Comment #4 from Ralf Habacker <***@freenet.de> ---
Git commit 2d3369b2252b1f6255f9a4afc0d607a5c067c858 by Ralf Habacker.
Committed on 22/08/2018 at 11:46.
Pushed by habacker into branch 'Applications/18.08'.

Adding a C++ test case with multiple template parameters

M +14 -0 test/import/cxx/templates.h

https://commits.kde.org/umbrello/2d3369b2252b1f6255f9a4afc0d607a5c067c858
--
You are receiving this mail because:
You are the assignee for the bug.
Loading...