universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.51k stars 622 forks source link

Make: add CppDef extra for extracting FOO in -DFOO as a macro of CPreProcessor #4024

Closed masatake closed 2 months ago

masatake commented 3 months ago

See https://github.com/bootlin/elixir/issues/221 .

input.mak:

CPPFLAGS = -DOUTPUT=stdout
foo.o: foo.c
    $(CC) $(CPPFLAGS) $<

Output:

$ ./ctags --extras-Make='+{CppDef}' --fields=+lE -o - input.mak 
CPPFLAGS    input.mak   /^CPPFLAGS = -DOUTPUT=stdout$/;"    m   language:Make
OUTPUT  input.mak   /^CPPFLAGS = -DOUTPUT=stdout$/;"    d   language:CPreProcessor  extras:CppDef
foo.o   input.mak   /^foo.o: foo.c$/;"  t   language:Make

When --extras-Make='+{CppDef}' is given, the Make parser extracts OUTPUT.

Violent heuristics, but I know this is useful when reading a source tree like Linux kernel. I have tried hard to make the impact on the original code small.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.45%. Comparing base (ac6c14c) to head (c16adc6).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #4024 +/- ## ========================================== + Coverage 85.42% 85.45% +0.03% ========================================== Files 235 235 Lines 56729 56848 +119 ========================================== + Hits 48462 48582 +120 + Misses 8267 8266 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

masatake commented 3 months ago

We must merge #4025 first. The coverage must be 100%.

masatake commented 2 months ago

The last one line the test cases don't cover looks a bit strange for me. Though I have modified the line, I cannot convince we need the line. I took more time for inspecting the line before merging.