[cfe-dev] [analyzer] How to detect a block inside which SVal is used?

Denis Petrov via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 20 13:29:11 PDT 2020


>Cause your high-level goal sounds extraordinary enough to discuss *before* discussing implementation details.


I'm developing this idea of a checker:

Consider this:

std::mutex m;
void foo()
{
  m.lock(); // catch the context
  for(int i = 0; i < 99999999; ++i) //long loop
  {
    // I'm trying to detect that `m` is not used inside long/inf loop
    // in other words all the rest threads may be potentially locked/idle for a long/inf time.
    // For this I have to determine whether `m` is inside the loop body block.
  }
  m.unlock();
}
?


________________________________
Denys Petrov
Senior С++ Developer | Kharkiv, Ukraine

________________________________
От: Artem Dergachev <noqnoqneo at gmail.com>
Отправлено: 20 июля 2020 г. 20:41
Кому: Denis Petrov; cfe-dev
Тема: Re: [cfe-dev] [analyzer] How to detect a block inside which SVal is used?

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.  If you suspect potential phishing or spam email, report it to ReportSpam at accesssoftek.com
There was a plan to handle this stuff with LocationContexts but it's currently stuck (https://reviews.llvm.org/D19979). I.e., when we enter a scope, we can put another LocationContext on the stack that'll indicate that we're in that scope, and when we exit the scope we remove it.

You can still figure this out syntactically by exploring parent statements of the current statement via ParentMap. This should work fairly well.

Given that nobody needed this particular functionality so far: what are you trying to achieve? 'Cause your high-level goal sounds extraordinary enough to discuss *before* discussing implementation details.


On 20.07.2020 08:28, Denis Petrov via cfe-dev wrote:

 How to detect a block inside which SVal is used in a path-sensitive way?


E.g.

void foo(int x) // Here `x` has a Symbolic representation (e.g. reg_$0<int x>)
{
  // block 1
  {
    int y = x; // Here I want to know that `x` is used inside a simple block
  }

  // block 2
  if(){
    int y = x; ? // Here I want to know that `x` is used inside if-true-block
  }

  // block 3
  while(){
    int y = x; // Here ?I want to know that `x` is used inside while-loop-body
  }
}

?I'm fighting with this sereval days. Insensitive way (checkASTCodeBody) is quite poor and not the case.

?Thanks.



________________________________
Denys Petrov
Senior С++ Developer | Kharkiv, Ukraine




_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200720/ea0e5832/attachment-0001.html>


More information about the cfe-dev mailing list