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

CPreprocessor: branches skip inside code block #2944

Closed
ArcsinX opened this issue Apr 7, 2021 · 1 comment
Closed

CPreprocessor: branches skip inside code block #2944

ArcsinX opened this issue Apr 7, 2021 · 1 comment

Comments

@ArcsinX
Copy link
Contributor

ArcsinX commented Apr 7, 2021

ctags does not skip preprocessor branches if we are not inside {}.

Input:

#ifdef A
int a;
#else
int b;
#endif

Output:

a       test.cpp       /^int a;$/;"    kind:variable   line:2  typeref:typename:int    end:2
b       test.cpp       /^int b;$/;"    kind:variable   line:4  typeref:typename:int    end:4

But, if preprocessor branches are inside {} then the second branch is skipped.

Input:

extern "C" {
#ifdef A
int a;
#else
int b;
#endif
}

Output:

a       test.cpp       /^int a;$/;"    kind:variable   line:3  typeref:typename:int    end:3

This looks inconsistent and the problem is here:
https://github.com/universal-ctags/ctags/blob/master/parsers/cxx/cxx_parser_block.c#L262

I think that we can remove cppBeginStatement() call here because:

  • seems the fact that we are inside some code block (function, namespace, extern "C", etc.) is not a good enough reason to skip (resolve) branches.
  • this change does not break any test
@ArcsinX
Copy link
Contributor Author

ArcsinX commented Apr 7, 2021

Sorry, seems it's duplicate of #2647

@ArcsinX ArcsinX closed this as completed Apr 7, 2021
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

No branches or pull requests

1 participant