Review Request: Add "language features" to the C++ parser

Alexandre Courbot gnurou at
Sun May 13 06:41:20 UTC 2012

This is an automatically generated e-mail. To reply, visit:

(Updated May 13, 2012, 6:41 a.m.)

Review request for KDevelop.


Only process designated initializers for C99 files. Also enabled a couple more C-specific features in the parser.


   Currently the parser is a pure C++ parser with C++11 elements, without
    any option to disable C++11 or to make it more C compatible. C
    compatibility in particular is a big challenge since many C++ tokens can
    be used as identifiers in C, and C also has some constructs that are not
    valid in C++ (like designated initializers or casted braced init lists).
    This patch adds "language features" which are flags that enable specific
    language support in the parser. Currently flags exist for C99, C++ and
    C++11. Code that invokes the parser can use the new
    setLanguageFeatures() method to change the current set of supported
    features (the default is C++ | C++11). This is useful for instance for
    C-specific projects.
    CppLanguageSupport::createParseJob has been modified to check for a
    "Language" entry in the configuration of the project the parsed file
    belongs to. Project controllers can set this option if they know that
    the project is limited to C, C++ or C++11 files. Other means (for
    instance, based on file extension of Makefile analysis) could be
    implemented in the future.

Diffs (updated)

  languages/cpp/cpplanguagesupport.cpp 4ee1ffe 
  languages/cpp/cppparsejob.h debb1b0 
  languages/cpp/cppparsejob.cpp 1e0a51b 
  languages/cpp/parser/languagefeatures.h PRE-CREATION 
  languages/cpp/parser/lexer.h 3494cbd 
  languages/cpp/parser/lexer.cpp 81302d7 
  languages/cpp/parser/parser.h c519891 
  languages/cpp/parser/parser.cpp edeab85 
  languages/cpp/parser/tests/test_parser.h dea9902 
  languages/cpp/parser/tests/test_parser.cpp 804f379 
  languages/cpp/preprocessjob.cpp 803c237 



Modified kdev-kernel to set that "Language=C" option to the projects it manages. Checked that C++ keywords like "class", "private" were indeed treated as identifiers. This alone improves kernel parsing quality a great deal.

Made sure that parsing of C++ projects is not affected in any way by this patch.


Alexandre Courbot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the KDevelop-devel mailing list