Author Topic: References shows only local usage  (Read 531 times)

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
References shows only local usage
« on: February 09, 2021, 06:47:48 pm »
hotfix_se2501_1_cumulative

When I do Goto Reference from a usage, the Reference pane shows only that usage. What am I doing wrong?

When I do Goto Reference from the declaration/definition, the Reference pane shows all instances (declaration/definition and usages).

Thanks.



joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #1 on: February 09, 2021, 06:56:18 pm »
Filter is set to show all tags.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: References shows only local usage
« Reply #2 on: February 09, 2021, 08:15:28 pm »
Can you put together a small example I could reproduce that with?  Also, make sure "Look in:" is not set to "<Current File>"

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #3 on: February 10, 2021, 12:33:57 am »
"Look in:" is set to "<Current Workspace>".

As I put together small examples for you, they seem to work properly...  ::)

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #4 on: February 10, 2021, 12:44:40 am »
It also happens when "Look in" is set to "<All Open Files>"

and the files containing the declarations/definitions are open.

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #5 on: February 10, 2021, 09:39:26 am »
Here is a pic (I had to obfuscate the details), see attached.

I'm still working on a simple example that shows the problem.
« Last Edit: February 10, 2021, 09:47:01 am by joecar »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: References shows only local usage
« Reply #6 on: February 10, 2021, 03:29:58 pm »
It appears that the definition is "static inline" but in a separate file.  Is that correct?  What is the file extension on that file?  We do have a special case to treat static functions in a ".h*" file as an extern function, but otherwise, a static definition is limited to the scope of the module it is declared in.

Some folks have suggested working around this by defining a preprocessor macro like #define STATIC_IN_HEADER static, which I can declare to SlickEdit as an empty #define in the C/C++ Proprocessor setup, and using that instead of using the static keyword directly in header files.

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #7 on: February 10, 2021, 07:07:18 pm »
Thanks.

That static inline is in the same file at line 748 (see Search Results pane in pic posted above), and is referenced at lines 916, 932, 956.

It is happening regardless of inline, and in the same or other files, but not for all cases.

I'm still working on a suitable simple example to show this behaviour.
« Last Edit: February 10, 2021, 07:12:38 pm by joecar »

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #8 on: February 10, 2021, 07:21:45 pm »
I should have said files are .c or .h.

Also note:
Goto Definition and Goto Declaration work ok.
Goto References from definition/declaration works ok (shows all instances/usages).


Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: References shows only local usage
« Reply #9 on: February 10, 2021, 09:27:37 pm »
The good news for a case like that is it appears to be restricted to that single file.  In fact, if you opened SlickEdit with a default configuration and the opened just that file, hopefully, you would get the same result.  Then all you need to do is whittle that file down to the bare bones and rename and/or obfuscate the rest.

You could try the attached macro (which I will add to SlickEdit for 25.0.2) to do the obfuscation.

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #10 on: February 11, 2021, 12:21:15 am »
Quote
. . .
More info:
When the usage assigns the return value to a variable, Goto References works properly.
When the usage does not assign the return value, Goto Refrences shows only the usage.
I have found this, but I have also found cases where this does not matter.
« Last Edit: February 11, 2021, 06:16:26 pm by joecar »

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #11 on: February 11, 2021, 06:21:42 pm »
Obfuscated file attached.

Look for function sL60C().
Doing Goto References from line 738 produces 4 references.
Doing Goto References from lines 877, 891, 911 produces only 1 reference.
In this case, the function is defined within the same file as its usages (there are cases where this is not so).

joecar

  • Senior Community Member
  • Posts: 278
  • Hero Points: 9
  • engineer/gearhead
Re: References shows only local usage
« Reply #12 on: February 12, 2021, 10:29:44 am »
BTW: Thanks for the file obfuscator, it does a very good job and includes strings and comments  ;)

vandermyer

  • Community Member
  • Posts: 27
  • Hero Points: 2
Re: References shows only local usage
« Reply #13 on: February 12, 2021, 11:25:35 am »
I don't know if this is related, but I have also found an example where the references is funny. In the simple example, try 'Find References' on the function called 'ReferencesOdd' and on the single use of this function in the function 'Func1'. In the first case I get three results: the function, the prototype and the use. In the second case, I only get the use. The other odd thing is, when I Preview the function, I get the function and prototype when I click on the definition; when I click on the use I get the function and two prototypes, one with '()' and one with '(void)' as the parameter list.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: References shows only local usage
« Reply #14 on: February 12, 2021, 09:50:55 pm »
REVISED

@joecar:  I was able to reproduce this only by adding the file to a project,
     and turning on Document > C/C++ Options... > C/C++ Parsing Options,
     "Tag function prototypes with no return type" = ON

     Is this an option you need to have enabled?

@vandermyer:  I can also reproduce your case, likewise, only if I turn on
     Document > ANSI-C Options... > C/C++ Parsing Options > Tag function prototypes with no return type

I am putting together a hot fix to help references work better knowing that there are false-positives,
locally tagged prototypes with no return type.

I will also make some improvements to the parser for how we handle that archaic option for 25.0.2.
« Last Edit: February 12, 2021, 11:29:59 pm by Dennis »