[cfe-commits] r158851 - /cfe/trunk/include/clang/Analysis/CallGraph.h

Anna Zaks ganna at apple.com
Thu Jun 21 13:41:16 PDT 2012


On Jun 20, 2012, at 5:59 PM, Anna Zaks wrote:

> 
> On Jun 20, 2012, at 4:00 PM, Douglas Gregor wrote:
> 
>> 
>> On Jun 20, 2012, at 1:57 PM, Anna Zaks <ganna at apple.com> wrote:
>> 
>>> Author: zaks
>>> Date: Wed Jun 20 15:57:49 2012
>>> New Revision: 158851
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=158851&view=rev
>>> Log:
>>> [analyzer] Do not walk the types for call graph construction.
>>> 
>>> Similar to r156661. This should be beneficial performance wise and
>>> hopefully, resolve a RecursiveASTVisitor crash that we are seeing in the
>>> wild, but are incapable of reproducing.
>> 
>> There could actually be interesting control flow in variably-modified types (e.g., VLAs). Should this be disabled only for types that aren't variably modified?
>> 
> 
> 
> It does not matter with the way the code is currently written because we only use the RecursiveASTVisitor to get the list of function declarations. Afterwards, we use StmtVisitor to find all the CallExprs they contain and process them. I don't think there is any reason why we shouldn't use the RecursiveASTVisitor for both, so it's probably worth rewriting that code.
> 

After further investigation, converting to a single traversal with RecursiveASTVisitor is much more complicated than the current solution. (Ex: we have to keep track of the root functions on a side, we need to overwrite all the TraverseFunctionDecl, TraverseCXXMethodDec,... functions and keep track of which declaration body is being currently processed so that we could communicate it to VisitCallExpr...). On top of that, the current RecursiveASTVisitor is susceptible to stack overflow issues.

I've implemented an optimization which would allow us not to recurse inside function bodies as part of the first traversal r158934.

Thanks,
Anna.

> Thanks for the review,
> Anna.
>> 	- Doug
>> 
>> 
>>> Modified:
>>>  cfe/trunk/include/clang/Analysis/CallGraph.h
>>> 
>>> Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=158851&r1=158850&r2=158851&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
>>> +++ cfe/trunk/include/clang/Analysis/CallGraph.h Wed Jun 20 15:57:49 2012
>>> @@ -121,6 +121,8 @@
>>>   return true;
>>> }
>>> 
>>> +  bool shouldWalkTypesOfTypeLocs() const { return false; }
>>> +
>>> private:
>>> /// \brief Add the given declaration to the call graph.
>>> void addNodeForDecl(Decl *D, bool IsGlobal);
>>> 
>>> 
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list