Bug 357774 - C source files are not parsed by new Clang parser in mixed (C and C++) project
Summary: C source files are not parsed by new Clang parser in mixed (C and C++) project
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 4.90.90
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-10 01:28 UTC by Piotr Mierzwinski
Modified: 2016-03-08 06:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2016-01-10 01:28:38 UTC
My project includes C and C++ files. When I run kdevelop from terminal (konsole) I can see a lot of messages saying: "libclang: crash detected during parsing". They all are referring to C source files.

Example of message:
kdevelop(2058)/(default) unknown: Failed to parse translation unit: "/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeparent.c"
libclang: crash detected during parsing: {
  'source_filename' : '/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/home/piotrek/Projekty/Qt/qtcmd_work/qtcmd_git/qtcmd2/libs/xdgmime/xdgmimeint.c'
  'command_line_args' : ['-ferror-limit=100', '-fspell-checking', '-Wdocumentation', '-Wunused-parameter', '-Wunreachable-code', '-Wall', '-std=c++11', '-nostdinc', '-nostdinc++', '-xc++', '-include/usr/include/qt4/Qt/QtCore', '-include/usr/include/qt4/Qt/QtGui', '-include/usr/include/qt4/Qt/QtNetwork', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/x86_64-linux-gnu/c++/5', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/include/c++/5/backward', '-isystem/usr/local/include', '-isystem/media/piotrek/FreeAgent/linux_containers/kubuntu_15.10/usr/lib/llvm-3.6/lib/clang/3.6.2/include', '-isystem/usr/include/x86_64-linux-gnu', '-isystem/usr/include', '-imacros', '/tmp/kdevelop.If2058'],
  'unsaved_files' : [],
  'options' : 45,
}
kdevelop(2058)/(default) unknown: clang_parseTranslationUnit2 return with error code 2

And because of this I think that C files are not parsed properly. More visible effect is lack of semantic highlighting of source in editor.

All C files coming from xdgmime project: git://anongit.freedesktop.org/xdg/xdgmime

Clicking "Show imports" in "Problems view" showing empty list.
My setting for clang are default, so in "Language Support" I have set "Compiler for path: Clang" and auto-detected is Clang and GCC (in this order). I use "Predefined profile c++11".

Now I realized that maybe this bug report has no sense, because used standard "c++11" in Clang parser. Could somebody confirm it?
And one more question. Whether it is possible to get semantic highlighting of C source file in editor in mixed (C++ and C) project?


Reproducible: Always

Steps to Reproduce:
1. Open mixed project (C and C++) in kdevelop

Actual Results:  
no semantic highlighting of C source file in editor

Expected Results:  
would be nice to have semantic highlighting of C source file in editor

kdevelop and kdevplatform cloned at January 8-th 2016 (branch 5.0.0).
Comment 1 Sergey Kalinichev 2016-03-08 06:21:20 UTC
Git commit 70834035889654703d9b3eca2c4951a03a0eda53 by Sergey Kalinichev.
Committed on 08/03/2016 at 06:05.
Pushed by skalinichev into branch '5.0'.

Parse C files in C mode

Now there are 2 language profiles: one for C++, another one for C.
The language type is determined by mime type.
Since *.h files used in C and C++, by default they are parsed
in C++ mode, to change that behavior there is a "Parse *.h headers
in plain C" check-box.
Related: bug 357615, bug 57156

Differential revision: https://phabricator.kde.org/D1047

M  +1    -1    languages/clang/clangparsejob.cpp
M  +5    -0    languages/clang/clangsettings/clangsettingsmanager.cpp
M  +2    -0    languages/clang/clangsettings/clangsettingsmanager.h
M  +1    -1    languages/clang/duchain/parsesession.cpp
M  +2    -1    languages/clang/tests/test_duchain.cpp
M  +0    -1    languages/clang/tests/test_files.cpp
M  +12   -2    languages/plugins/custom-definesandincludes/compilerprovider/compilerprovider.cpp
M  +64   -9    languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
M  +33   -2    languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.h
M  +15   -6    languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
M  +1    -0    languages/plugins/custom-definesandincludes/definesandincludesmanager.h
M  +2    -2    languages/plugins/custom-definesandincludes/idefinesandincludesmanager.h
M  +57   -24   languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
M  +6    -3    languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.h
M  +120  -8    languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
M  +4    -3    languages/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp
M  +1    -1    languages/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.h
M  +3    -2    languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.cpp
M  +1    -1    languages/plugins/custom-definesandincludes/tests/test_definesandincludes.cpp

http://commits.kde.org/kdevelop/70834035889654703d9b3eca2c4951a03a0eda53