Page 1 of 1

References don't work for local variables

Posted: Wed Mar 17, 2021 11:20 am
by guyr
While trying to understand a complex code base, I discovered that Goto Declaration, Goto Implementation, and Search -> Find References don't appear to work for local variables. Here is a small, standalone code sample that demonstrates this. Within Codelite, only global_int gets any results for those 3 search actions. Those 3 search actions don't do anything with local variables - main_int, ret, param_int, func1_int. Is this intentional?

Thanks.

Code: Select all

#include <stdio.h>

int global_int = 4;

int func1(int param_int)
{
	int func1_int = 3;
	func1_int *= param_int;
	func1_int += global_int;	
	printf("func1 ret: %d\n", func1_int);
	return func1_int;
}

int main(int argc, char **argv)
{
	int main_int =  global_int + 1;
	printf("main hello world\n");
	int ret = func1(main_int);
	printf("main ret: %d\n", ret);
	return 0;
}

Re: References don't work for local variables

Posted: Tue Mar 23, 2021 7:17 pm
by eranif
if the code base can be compiled within CodeLite (I am not sure you are browsing the source code)
the goto decl/impl should work for local variables. for several versions now, we switched to use clangd as our main C/C++ code completion engine
and it proven to be quite reliable. so if you can shed some more info on your workspace details...

Re: References don't work for local variables

Posted: Thu Mar 25, 2021 12:19 pm
by guyr
I'm using CodeLite version 14.0 on Windows, using the WinGW-W64 compiler version 8.1.0. I also tried with the msys2 embedded compiler gcc version 10.2.0, same result. I just created a new C++ workspace, using all defaults. I created a new project: Console, Simple executable (gcc), compiler WinGW-W64 8.1.0. I copied and pasted the code I posted into main.c, compiled and ran it. Got the expected results.

But still trying to Goto Declaration, Goto Implementation, and Search -> Find References don't work for local variables.