[cfe-dev] Missing edges in analysis call graph
ganna at apple.com
Fri Nov 21 10:48:24 PST 2014
> On Nov 20, 2014, at 4:34 PM, Daniel DeFreez <dcdefreez at ucdavis.edu <mailto:dcdefreez at ucdavis.edu>> wrote:
> Thanks for your reply Anna. I finally got a chance to play around with this again today.
> I believe with your patch, the node will get added, but the definition used will not have the body attached to it, so the analyzer will not process the body.
> Hmm, doesn't the analyzer itself use getBody() to access the body, thereby walking the list of redeclarations? It seems like it is still processing the body of the function, but maybe I don't know what to look for.
This is a good point. We might not be gaining anything by replacing the decl with the one that has a body since getBody is guaranteed to search the redeclarations regardless.
How about just removing both calls to isThisDeclarationADefinition() (from includeInGraph) and replacing the call to getBody with hasBody (to avoid the unnecessary AST de-serialization of the body)? That should work and would simplify the function greatly. What do you think?
I am not sure why some of the checks in your first patch were necessary (like this one).
+ // Skip definitions with previous declarations
+ if (FD->getPreviousDecl())
+ return false;
> How about changing the logic in the CallGraph to check if there is a redeclaration with the body and insert that one insted of the one referenced by the call? (This could also be handled on the analyzer side, but I think all the CallGraph users might prefer the declarations that have the bodies attached when those are available.) I would try to use hasBody, followed by getBody(). What do you think?
> It isn't obvious to me how to do this with hasBody / getBody directly, since the call graph node Decl isn't const. However, it can be easily done by iterating over redecls() and testing each with doesThisDeclarationHaveABody. It seems to work. Any problems with this approach?
> Is cfe-commits the place to submit the actual patch?
> Thanks again for you help,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev