[Qt-creator] Macro definition position in code model

Jochen Becher jochen_becher at gmx.de
Fri Jul 22 23:08:06 CEST 2016


Hello,

currently I am working on a new feature for QtCreator. I need to
analyze the C++ source code (non preprocessed) very precisely. Seems to
be difficult because I couldn't find the token stream of the non-
preprocessed source code.

I tried to use the information from CppTools::SemanticInfo. It gives me
most of the info I need but not in a simple token stream.

Analyzing the macro definitions I found that CPlusPlus::Macro is
inconsistent: the utf16CharOffset() points to the start of the macro
name while the length() includes the #define token. So I can neither
know the start of the #define token nor the end of the macro definition
(because I do not know how many whitespaces were skipped between
#define and macro name).

Today Macro::length() is used only once and only to compare the values
from two Macro entities. Thus I could fix the length() to not include
the #define token and whitespaces.

But unfortunately that still does not give me the start of the #define
token. Shall I include another offset in Macro pointing to that #define
token start or is there any other simple way (instead of parsing the
source code myself) to find this #define token start position?

BTW: Is there a simple way to get the full token stream of the non-
preprocessed code? I wouldn't like to start the preprocessor though
this might be a solution.

Regards, Jochen




More information about the Qt-creator mailing list