[umbrello] [Bug 397666] New: C++ importer does not recognize 'final' keyword

Thomas Jansen bugzilla_noreply at kde.org
Mon Aug 20 17:15:10 BST 2018


https://bugs.kde.org/show_bug.cgi?id=397666

            Bug ID: 397666
           Summary: C++ importer does not recognize 'final' keyword
           Product: umbrello
           Version: Git
          Platform: Other
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: umbrello-devel at kde.org
          Reporter: mithi at mithi.net
  Target Milestone: ---

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

When trying to import existing C++ code that uses the 'final' keyword
introduced in C++11 (https://en.cppreference.com/w/cpp/language/final),
umbrello fails to parse it correctly. Apparently the lexer doesn't know about
the final keyword.

Final can occur in two places:
1. class definition (e.g. "class foo final {...};") 
2. member function declaration "virtual void foo() final;"

Case 1: The following code is imported incorrectly:
class foo final {...};
class bar final {...};

I would expect the C++ import parser to give me two classes named 'foo' and
'bar', instead, it gives me one class named 'final'.

Case 2: The member function declaration is also not correctly parsed, leading
to an empty list of member functions for a class that has at least one member
function decorated with 'final'.

The attached patch introduces a token for the final keyword to the lexer and
uses that token in the parser for the places it may appear. This patch is only
the starting point for fixing the bug. In particular the part in
Parser::parseDeclarator is not really elegant and needs to be corrected. The
problem is that 'final' and 'override' may both be used on a declarator and the
order is arbitrary. However, each may only be specified once. This check for
duplication is not yet in the patch. Feel expand the code as you see fit. Also
this information is not forwarded to other parts of umbrello, e.g. there is no
GUI frontend for the parsed final keywords. For my purposes it is enough to
parse existing C++ code correctly and display UML class diagrams.

Proposed test case for part 1: The parser should create a class called 'foo'
rather than 'final' on the following code:

class foo final {
public:
  foo() {};
  ~foo() {};
};

Proposed test case for part 2: The parser should create a declarator list with
the four functions 'a', 'b', 'c', and 'd' for the following code:
class foo {
public:
  virtual bool a() const;
  virtual bool b() const override;
  virtual bool c() const final override;
  virtual bool d() const override final;
};

Please note that function d is not yet properly parsed by my patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the umbrello-devel mailing list