WALA icon indicating copy to clipboard operation
WALA copied to clipboard

I got a wrong local name

Open EdisonE3 opened this issue 4 years ago • 6 comments

Hello, when I try to get a local name of a variable, the wala did not give me the right name. I write a program like this:

    public void testString() {
        String phoneModel = "aaaaa";
        switch (phoneModel){
            case "wwwww":
                break;
        }
    }

Then I want to get the local name of variable phoneModel. However, the wala returns 3=[phoneModel, null].

EdisonE3 avatar Oct 12 '21 13:10 EdisonE3

The IR like this: image

EdisonE3 avatar Oct 12 '21 13:10 EdisonE3

A value number in WALA IR may correspond to more than one source-level local variable; see here:

https://github.com/wala/WALA/wiki/Mapping-to-source-code#mapping-value-numbers-back-to-local-names

In this case, getting a null value is a bit weird, but otherwise the result looks correct. Are you able to just ignore null values and use the results?

msridhar avatar Oct 12 '21 16:10 msridhar

It seems that there is a bug in wala. Is it possible to fix it in the future?

EdisonE3 avatar Oct 12 '21 16:10 EdisonE3

Is the bug the null value? Or are you seeing something else that is incorrect? If it's the null value I can try to look, but not sure how easy it will be to fix.

msridhar avatar Oct 12 '21 16:10 msridhar

Yes. When I change the code to

public void testString() {
        String phoneModel = "aaaaa";
        System.out.println(phoneModel.hashCode());
    }

The local name is correct: image

So, I guess there are something when dealing with switch...case...

EdisonE3 avatar Oct 12 '21 16:10 EdisonE3

Ok, thanks for the details! We appreciate the report. I will try to look into this, though it may not be very soon.

msridhar avatar Oct 12 '21 16:10 msridhar