There was a plan to handle this stuff with LocationContexts but it’s currently stuck (). 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.
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();
}