Review Request 114628: Improves declarator parsing.

Paweł Nowak pn347193 at
Sun Dec 22 23:27:44 UTC 2013

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

(Updated Dec. 22, 2013, 11:27 p.m.)

Review request for KDevelop.


Forgot to update some comments in test2.cpp

Bugs: 280244

Repository: kdevelop


This patch fixes incorrect parsing of declarations like "int (func)(int);" - where the declarator id is inside parentheses but it is not a function pointer, as well as some more issues. I have attached a file comparing old and new parsing results. It shouldn't affect anything that was already parsed successfully.
Additionally it eliminates some code duplication: now both parseDeclarator and parseAbstractDeclarator call parseDeclaratorInternal.

However, still a lot of old problems remain: 
 -function pointers are displayed as functions
 -grouping in declarations like "int *(test[3])" is dropped so it becomes "int *test[3]"
 -function types as template parameters are not handled correctly - "std::function<void(int)>" becomes "std::function<void>" somewhere in builders
and fixing them doesn't look that easy.

This is my first contribution to kdevelop and I hope I haven't broken anything :)


  languages/cpp/cppduchain/contextbuilder.cpp 668aed1 
  languages/cpp/cppduchain/declarationbuilder.cpp b264858 
  languages/cpp/cppduchain/expressionvisitor.cpp d62f3e2 
  languages/cpp/parser/ast.h db20d74 
  languages/cpp/parser/codegenerator.cpp 2bc5f8e 
  languages/cpp/parser/default_visitor.cpp 9b43ae0 
  languages/cpp/parser/parser.h 933e2c8 
  languages/cpp/parser/parser.cpp c59bd78 



Current git head is pretty broken so I tested using commit 4ac7ec339a29ee419f08d9ff29ce544e8a710c7c.
All tests pass (except for qtprinters, what is unrelated to this patch).

File Attachments (updated)

Comparison between old and new declarator parsing


Paweł Nowak

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

More information about the KDevelop-devel mailing list