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: adjust line numbers when reading characters from unget-chars-buffer #4198

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

masatake
Copy link
Member

@masatake masatake commented Feb 17, 2025

Fixes #4018.

foo.c

$ cat -n /tmp/foo.c                                                                                                                      
     1	SYSCALL_DEFINE3(
     2	   /*
     3	    * noise
     4	    */
     5	   mysyscall, int, dfd,
     6	   const char __user *, filename,
     7	                umode_t, mode)
     8	{
     9	        return 0
    10	}

With the original code:

$ /usr/bin/ctags --quiet --options=NONE --fields=+Sn -D'SYSCALL_DEFINE3(s,t0,a0,t1,a1,t2,a2)=int s (t0 a0, t1 a1, t2 a2)' -o - /tmp/foo.c
mysyscall	/tmp/foo.c	/^                umode_t, mode)$/;"	f	line:7	typeref:typename:int	signature:(int dfd,const char __user * filename,umode_t mode)

With ctags with this change:

$ ./ctags --quiet --options=NONE --fields=+Sn -D'SYSCALL_DEFINE3(s,t0,a0,t1,a1,t2,a2)=int s (t0 a0, t1 a1, t2 a2)' -o - /tmp/foo.c
mysyscall	/tmp/foo.c	/^   mysyscall, int, dfd,$/;"	f	line:5	typeref:typename:int	signature:(int dfd,const char __user * filename,umode_t mode)

This is a step for solving bootlin/elixir#379.

TODO:

  • updating ASM parser, too
  • limiting the size of the unget buffer
  • updating manual page?

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
The original code provided a vString as the result of macro
expansion. In the proces of expansion, we lost the orignal line
numbers of the macro arguments.

To solve "CPreprocessor,C: macro expands multiple lines" universal-ctags#4018, we
must provide a way to keep the the orignal line numbers in the result
of expansion. This commit is the first step for providing the way.

TODO:
- limiting the size of the unget buffer

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Close universal-ctags#4018

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 93.18996% with 19 lines in your changes missing coverage. Please review.

Project coverage is 85.93%. Comparing base (e7db33b) to head (a7a3968).

Files with missing lines Patch % Lines
parsers/cpreprocessor.c 91.70% 18 Missing ⚠️
parsers/vera.c 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4198    +/-   ##
========================================
  Coverage   85.93%   85.93%            
========================================
  Files         241      241            
  Lines       59171    59294   +123     
========================================
+ Hits        50847    50957   +110     
- Misses       8324     8337    +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 this pull request may close these issues.

CPreprocessor,C: macro expands multiple lines
1 participant