Adam Kemp wrote:
>
> I am very excited about some of the things I might be able to do with 
> Dehydra. I found it while trying to see if anyone is maintaining Elsa 
> (which, thankfully, you seem to be doing as well). So thank you very 
> much for working on these projects.
Hi Adam,
Glad to hear this stuff is useful to you.
>
> Unfortunately there's an issue that's getting in my way with my first 
> attempt at using Dehydra. I'm trying to look at all function calls to 
> check for a specific kind of bug. I've been able to detect all of the 
> bad calls correctly, but I discovered that Dehydra is incorrectly 
> setting up the function call objects, so the location is wrong. 
> Instead of pointing at the location of the call, the object points to 
> the location of the function declaration.
That's awesome!
This isn't a bug, it's how things are done in gcc. Locations on decls 
point to the definition, not use.
The testcase in bug shows how to get the location from the containing 
statement.
https://bugzilla.mozilla.org/show_bug.cgi?id=444941

If you set this._loc as you iterate through statements, 
print/error/warning() will use that.
>
> I looked into the code a bit and noticed that when you create the 
> JSObject for the function call you're actually starting by creating an 
> object for the function type. Here's the code (line 131 of 
> dehydra_ast.c):
> JSObject *obj = dehydra_makeVar (this, fn, NULL, NULL);
>
> "fn" is the function, not the call. The first thing I tried was 
> replacing fn with t (the call node), but that failed for reasons that 
> are probably obvious to you (it recurses; oops). Then I tried 
> following the dehydra_makeVar call with dehydra_setLoc(this, obj, t) 
> to override the location. That didn't seem to have any effect.
>
> I think the correct fix would be to create the JSObject from scratch 
> with the correct location and then set a field to point to the 
> function type instead of creating it from the function type itself. 
> I'm just not sure how to do that. Could you help me out?
>
> I am definitely interested in contributing to this project if you need 
> the help, but I just need a bit of guidance to get started.
You do raise a good point. Perhaps it is not useful to follow the gcc 
semantics and it would be better to provide a useful .loc.
If someone else agrees with your viewpoint here, I'll change it to the 
behavior you expect.

Thanks,
Taras
_______________________________________________
Dev-static-analysis mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-static-analysis

Reply via email to