forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPreProcessor,C: skip #ifdef __cplusplus ~ #endif branch
Close universal-ctags#2647. C parser doesn't work when C++ code "extern "C" {" and "}" is given. $ cat /tmp/extern-c.c extern "C" { #ifdef X void f() {} #else void g() {} #endif } $ u-ctags --output-format=xref --kinds-c=+plz --fields=+nie -o - /tmp/extern-c.c f function 3 /tmp/extern-c.c void f() {} $ cat /tmp/none-extern-c.c #ifdef X void f() {} #else void g() {} #endif $ u-ctags --output-format=xref --kinds-c=+plz --fields=+nie -o - /tmp/none-extern-c.c f function 2 /tmp/none-extern-c.c void f() {} g function 4 /tmp/none-extern-c.c void g() {} The function g() is missed if the code is surrounded by extern "C" { and }. This change uses a heuristic rule to skip the code in the C parser. In most of cases, the code is in #ifdef __cplusplus ~ #endif branch. So when the CPreProcessor parser detects #ifdef __cplusplus ~ #endif, with this change, the CPreProcessor parser doesn't pass the code inside __cplusplus branch to its client parser that requests to the CPreProcessor parser to do so. C parser requests it. C++ parser doesn't. Signed-off-by: Masatake YAMATO <[email protected]>
- Loading branch information
Showing
8 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters