Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro definitions missing in tags file #1514

Closed
olson-dan opened this issue Jul 25, 2017 · 6 comments · Fixed by #1564
Closed

Macro definitions missing in tags file #1514

olson-dan opened this issue Jul 25, 2017 · 6 comments · Fixed by #1564
Assignees

Comments

@olson-dan
Copy link

olson-dan commented Jul 25, 2017

I make a simple .cpp file containing one line:

#define TEST 1

Then, running ctags --languages=c++ test.cpp I get this output:

!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE	u-ctags	/u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR	Universal Ctags Team	//
!_TAG_PROGRAM_NAME	Universal Ctags	/Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL	https://ctags.io/	/official site/
!_TAG_PROGRAM_VERSION	0.0.0	/5567535e/

I do not get a tag for my macro. This is true even if I use --kinds-c++=+d, even though it is enabled by default.

Here is the output of ctags --version

Universal Ctags 0.0.0(5567535e), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jul 18 2017, 00:07:38
  URL: https://ctags.io/
  Optional compiled features: +win32, +wildcards, +regex, +internal-sort, +multibyte, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames
@masatake masatake self-assigned this Jul 25, 2017
@masatake
Copy link
Member

Reproduced.

@masatake
Copy link
Member

CPreProcessor must be added to --languages.
People may call this a bug. I wonder what I should do.

[jet@localhost]~/var/ctags% ./ctags --languages=c++,CPreProcessor /tmp/simple.cpp
[jet@localhost]~/var/ctags% cat tags 
!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE       u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //
!_TAG_PROGRAM_NAME      Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL       https://ctags.io/       /official site/
!_TAG_PROGRAM_VERSION   0.0.0   /5567535e/
TEST    /tmp/simple.cpp /^#define TEST /;"      d       file:
[jet@localhost]~/var/ctags% cat /tmp/simple.cpp                                  
#define TEST 1

[jet@localhost]~/var/ctags% ./ctags --languages=c++,CPreProcessor /tmp/simple.cpp
[jet@localhost]~/var/ctags% cat tags                           
!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE       u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //
!_TAG_PROGRAM_NAME      Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL       https://ctags.io/       /official site/
!_TAG_PROGRAM_VERSION   0.0.0   /5567535e/
TEST    /tmp/simple.cpp /^#define TEST /;"      d       file:

@olson-dan
Copy link
Author

Confirmed that this fixes it for me. User error, but not an obvious solution. I am not sure what should be changed either.

@masatake
Copy link
Member

At leat this must be written in man/ctags-incompatibilities.7.

@masatake
Copy link
Member

Thank you for reporting.

masatake added a commit to masatake/ctags that referenced this issue Oct 1, 2017
Old behavior:

When --language=C++ is specified, C preprocessor macro definitions in a source
code is not captured.

Because CPreProcessor parser captures the definitions and is disabled
with --language=C++ option.

As reported in universal-ctags#1514, this behavior makes use confused.

    $ ./ctags --list-kinds=C++
    d  macro definitions
    e  enumerators (values inside an enumeration)
    f  function definitions

Though CPreProcessor parser captures macro definitions, macro kind is
listed in --list-kinds=C++. A user may understand "macro kind" is
part of C++ parser, and the understanding looks reasonable.

New behavior:

In the following condition, CPreProcessor related kind language objects are recorded
even if CPreProcessor is disabled:

     The kinds are listed in --list-kinds output of a parser, that
     uses CPreProcessor parser.

C and C++ meet the condition.
DTS doesn't meet the condition.

Close universal-ctags#1514.

Signed-off-by: Masatake YAMATO <[email protected]>
@masatake
Copy link
Member

masatake commented Oct 1, 2017

I understand how critical this bug is.

In #1564, I implement the behaviour you expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants