-
Notifications
You must be signed in to change notification settings - Fork 628
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
Fortran: Improve handling of case insensitivity #3668
Comments
Should ctags generate the following tags for the former reqeust?
|
No I don't think that would be a good approach, for longer symbols where n is the number of letters you'd have to have 2n combinations, and tag files would quickly become rather large. I think just having the lowercase option makes the most sense, i.e.:
Consumers of tag files will in general need to take into account the case insensitivity of the language regardless (I'm probably going to need to make some slight changes to opengrok). If we have the underscore appended symbol too it would be:
|
If ctags records
|
It seems that case sensitivity can be handled in OpenGrok side. |
Perhaps this should be gated by a flag? As it stands if a function is defined as
I think link name makes sense.
Note there that the full search is case insensitive, but the search for definition is case sensitive. This is what I think would need to be changed in opengrok for Fortran specifically. |
I think such a flag should be part of the tools consuming the tags file.
So I think extending opengrok is the way to go instead of extending ctags.
Could you tell me a documentation or specification about the rule synthesizing the name like
Which kind may have such a link name? |
|
It's not part of the standard, but is the default behaviour for most compilers, for example gfortran, Sun Studio. By default, XLF does not do it, but it can be turned on by -qextname.
I'll double check, but off the top of my head I believe the following symbols have underscore appended: common, entry, function, interface, and subroutine. Unsure about some of the module features, and block data, but stuff like variable and types don't have any linkage significance. |
I had raised an issue on the OpenGrok repo and it looks like someone had tried to implement the case insensitive search on their side a couple of years ago! It never got merged in the end so I'll try and update that and get it over the line. As for what symbols are appended with, I wrote a small program to try and cover most of those symbols (see here), so the following should be covered: function, subroutine, block data, common and entry. Other stuff don't have symbols or they are more significantly mangled, including functions, subroutines and entries within a module, so we wont want extra link names for them. I think the approach you posted a diff of does make sense so I would be happy with that output, though I think given the symbol will actually be made all lowercase, it might make sense to make that link name lowercase. Is there any significance to the difference of the link name catching the closing parenthesis? I guess it wouldn't make much difference to finding definitions. |
As far as reading the man page for GNU Fortran you kindly introduced, the compiler appends two underscores to a link name whose original name includes an underscore. e.g. Do you think ctags should do the same? |
Hmmm I think the GFortran docs are actually slightly misleading, it describes what's happening with the non-default Testing it on the following example: program main
call subr()
call my_subr()
end program main Compiling it with the following options and inspecting the symbols in the resulting object file I get:
I'll raise an issue with GCC folks to improve that, but I think adding a single underscore regardless of how many underscores there are in the name makes sense. |
Close universal-ctags#3668. The test input is taken from https://gist.github.com/RaoulHC/a241fb714f191b5fc3a7c790d7b23523. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Excellent, looks like some tests need updating, but otherwise that looks like that'll really help our opengrok instance find Fortran definitions. Thanks so much for this! |
Close universal-ctags#3668. The test input is taken from https://gist.github.com/RaoulHC/a241fb714f191b5fc3a7c790d7b23523. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Please, give comments on the pull request. I will not merge till I get your ack. |
Fortran is a case insensitive language and as a result it would be great if ctags took this into account.
For example the following code defines a subroutine as
FOO
but can happily be called byfoo
, and similarly usesmyvar
in multiple ways, but the tags file generated from it is not as useful as I'd like.Additionally Fortran symbols are appended with an underscore by most compilers, meaning that if in a multi language codebase I want to go to the definition of a Fortran function called in c as
foo_
I similarly wont find it.I think it makes sense for ctags to lowercase symbols, and potentially make sense for it to append an underscore to subroutine and function names. However because the latter may not play well with other tooling (my usecase is with opengrok), it might make the most sense to generate two tags, with and without the underscore, probably gated behind a flag.
Looks like it should be easy enough to implement this in the Fortran parser but as I'm not all that familiar with ctags I'd appreciate some input to this problem before raising a PR.
The text was updated successfully, but these errors were encountered: