zaks.anna added a comment.

Hi!

Looks like this this is used by the Infinite recursion checker. Specifically, 
the checker not only needs to get Smalls for arguments of the current 
CallEvent, but it also looks for arguments of other calls on the stack. The 
checker walks the LocationContext and uses this new API to look up the 
arguments passed to the calls on the stack.

The two concerns I have with this patch is that it is extending the overloaded 
ProgramState API and also that this does not fully cover all the call types we 
have in C/ObjC/C++. The good news is that the CallEvent API was created 
specifically to encapsulate this complexity and it already contains the needed 
API to look up the SVal of the argument. Have you considered creating CallEvent 
for the calls on the stack and using that existing API to find the Smalls of 
the arguments.

Here is some documentation from CallEvent.h:
`
 /// CallEvents are created through the factory methods of CallEventManager.
 ///
 /// CallEvents should always be cheap to create and destroy. In order for
 /// CallEventManager to be able to re-use CallEvent-sized memory blocks,
 /// subclasses of CallEvent may not add any data members to the base class.
 /// Use the "Data" and "Location" fields instead.

`

It looks like this code from BugReporterVisitors.cpp is doing something similar:

  ` // Don't automatically suppress a report if one of the arguments is
   // known to be a null pointer. Instead, start tracking /that/ null
   // value back to its origin.
   ProgramStateManager &StateMgr = BRC.getStateManager();
   CallEventManager &CallMgr = StateMgr.getCallEventManager();
  
   ProgramStateRef State = N->getState();
   CallEventRef<> Call = CallMgr.getCaller(StackFrame, State);
   for (unsigned I = 0, E = Call->getNumArgs(); I != E; ++I) {
     Optional<Loc> ArgV = Call->getArgSVal(I).getAs<Loc>();
     if (!ArgV)
       continue;

`

     

I hope this approach works and you could just add that code to your checker. 
(If not, we can investigate other options.)


https://reviews.llvm.org/D27091



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to