Bug 373973 - Kdevelop clang parser has many issues
Summary: Kdevelop clang parser has many issues
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 5.0.3
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-20 19:33 UTC by Ted
Modified: 2017-01-02 04:03 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ted 2016-12-20 19:33:30 UTC
I have spent a lot of time playing with the Kdevelop configuration for the C++ parser.  However I cannot get the clang parser to work with STL header (for example).

I am not using c++11 but even with the default settings of std=c++11, the STL headers are not fully recognized.  

If I explicitly include a path to find /usr/include/c++/6.2.1 then the STL headers are found, but typedefs are not recognized.

Simple example.

#include <string>
using namespace std;

string myString;

This is what the parser will show for string.

typedef int string
Container: std Kind: Typedef 
Decl.: stringfwd.h :74 Show uses


It does not seem to find the real typedef which should be:

typedef basic_string<char>    string;

My guess is that the clang parser is not going deep enough to resolve these types.  It appears it gives up and the uses the default type of int for anything it doesn't know.

What are the correct settings to get the clang parser to work?
I have spent hours on trying to find a solution to no avail.
Comment 1 Ted 2016-12-20 20:33:42 UTC
The settings I am referring to are under 
project->Open Configuration...->Language Support

Maybe this is an issue with c++11 v.s. older ABI
When I pulled up a project that had c++11 for the language version then I do see std::string interpreted correctly:

typedef basic_string< char, std< char >, std< char > > string
Container: __cxx11 Kind: Typedef 
Decl.: stringfwd.h :74 Show uses

If I try to use 03 it reverts to this:
typedef int string
Container: __cxx11 Kind: Typedef 
Decl.: stringfwd.h :74 Show uses

If I include the define for _GLIBCXX_USE_CXX11_ABI 0 then back to this:
(Using 03 or 11, doesn't matter).
typedef int string
Container: std Kind: Typedef 
Decl.: stringfwd.h :74 Show uses
Comment 2 Ted 2016-12-20 20:48:41 UTC
Further strangeness:

I have found while initially reparsing my project with the only change in 
project->Open Configuration...->Language Support
_GLIBCXX_USE_CXX11_ABI 0

std::string
Show correctly
typedef basic_string< char, std< char >, std< char > > string
Container: std Kind: Typedef 
Decl.: stringfwd.h :74 Show uses

But somewhere during the reparsing back to this:

typedef int string
Container: std Kind: Typedef 
Decl.: stringfwd.h :74 Show uses
Comment 3 Ted 2016-12-20 21:10:47 UTC
Looks like this has boiled down to the lack of pkg-config support.
I am using glib and in my Makefile I use `pkg-config  glib-2.0 --cflags`
As you may know, this will provide the paths:
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
It appears that the clang parser will not be able to parse if these paths are not present and hence the strange behavior with the STL includes.

Is there a way to add the pkg-config support into the parser?
Comment 4 Ted 2016-12-29 19:49:33 UTC
The whole problem was relying on the Makefile to supply the include paths.
Apparently KDevelop does not parse pkg-config entires in the Makefile.
I added the needed include files paths in Kdevelop and resolved the problem.
Comment 5 Ted 2016-12-29 19:50:41 UTC
I must say that with my issues resolved, the Background parser is working very well.  I am very impressed with Kdevelop 5.x.x.
Comment 6 Kevin Funk 2016-12-30 08:39:31 UTC
Thanks, glad you figured out how to solve the problems!
Comment 7 Ted 2017-01-02 04:03:46 UTC
I would like to add a comment that may help others stumbling across this issue.

If there are any RED issues reported in Problems for include files, the parser will not work.  You must resolve these problems in order for the parser to work again.