Bug 369538 - Implement a C++ parser using Clang
Summary: Implement a C++ parser using Clang
Status: REPORTED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 17:19 UTC by Shawn McKenney
Modified: 2021-11-02 22:41 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
ClassImport inheritance diagram (53.90 KB, image/png)
2016-09-29 23:36 UTC, Shawn McKenney
Details
TreeParser inheritance (86.68 KB, image/png)
2016-09-29 23:38 UTC, Shawn McKenney
Details
CodeImportWizard sequence (30.51 KB, image/png)
2016-09-29 23:38 UTC, Shawn McKenney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn McKenney 2016-09-29 17:19:48 UTC
Clang has a very good C++ parser and AST generator. It is also up to date with all of the c++11 and c++14 standards. Using the clang tools will be more robust and easier to maintain.

Reproducible: Always
Comment 1 Shawn McKenney 2016-09-29 23:36:31 UTC
Created attachment 101353 [details]
ClassImport inheritance diagram
Comment 2 Shawn McKenney 2016-09-29 23:38:26 UTC
Created attachment 101354 [details]
TreeParser inheritance
Comment 3 Shawn McKenney 2016-09-29 23:38:50 UTC
Created attachment 101355 [details]
CodeImportWizard sequence
Comment 4 Shawn McKenney 2016-09-29 23:40:40 UTC
Attached are some diagrams. It looks we should extend the TreeParser and the ClassImport classes with Clang equivalents. Then in the wizard we can select which parser to use.

I agree with you, Ralf. I am going to start by creating some test cases. Should I just do that in my fork and send pull requests?

Also, your llvmparser test case looks like what we should use to traverse the Clang AST. Those classes look like a good starting point.

Is there any place I can stick these diagrams? I am a big fan of diagrams and will keep creating them for my own understanding. I'll be happy to organize them somewhere for others as well. I don't mind writing some technical documentation.

Do we need to create some new Jenkins jobs for qt5? I don't see them anywhere.

Comments/questions always welcome.
Comment 5 Ralf Habacker 2016-10-04 12:55:38 UTC
(In reply to Shawn McKenney from comment #2)
> Created attachment 101354 [details]
> TreeParser inheritance

From the testllvmparse unit test you can see that clang provides the template class RecursiveASTVisitor for exactly that purpose.  See class FindNamedClassVisitor, which already uses a subset of the provided methods like 
    bool VisitStmt(Stmt *s)
    bool VisitCXXRecordDecl(CXXRecordDecl *Declaration)

this may change your proposed design in this area.
Comment 6 Ralf Habacker 2016-10-04 13:31:20 UTC
(In reply to Shawn McKenney from comment #1)
> Created attachment 101353 [details]
> ClassImport inheritance diagram

This looks good
Comment 7 Ralf Habacker 2016-10-04 13:44:35 UTC
(In reply to Shawn McKenney from comment #3)
> Created attachment 101355 [details]
> CodeImportWizard sequence

This sequence diagram shows the state in case clang support has been finished. 
Until clang support is finished it is required  to provide clang cpp import as alternative way to not break the current (stable) way people may depends on. This can be archived for example by adding a checkbox in umbrello setting "Use clang based c++ import" or by providing additional (context) menu entries with dedicated clang import. The related menu entries are Sourcecode->Import from Directory, Sourcecode->Import Wizard and context menu of Logical view in the tree view.
Comment 8 Ralf Habacker 2017-05-04 06:27:45 UTC
(In reply to Shawn McKenney from comment #4)
> Should I just do that in my fork and send pull requests?
see https://community.kde.org/Infrastructure/Github_Mirror
Comment 9 Oliver Kellogg 2021-11-02 22:41:45 UTC
clang-parser is geared towards compiling and requires visibility to the header files transitively #included
(all the way to the system's header files).

Umbrello's C++ parser does not have this constraint; it deals with incomplete sources.