Does clang-tidy support cross-thread checks?
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Using clang-tidy for static code analysis in CLion has helped me resolve some code issues. However, there are also some problems, and I'm not sure if it's due to incorrect configuration?
`For example, in multi-threaded development:
class MyClass
{
public:
MyClass();
~MyClass()
{ Stop();}
void execute_task()
{
while(!stop_)
{
if (vec_.empty())
{
retry_cv_.wait(lk, [this] { return stop_ || !vec_.empty(); });
if (stop_)
{
break;
}
}
}
}
}
void Stop()
{
stop_ = true;
}
private:
bool stop_{false};
std::vector vec_;
std::condition_variable cv_;
std::mutex mutex_;
}
The code above is just for demonstrating the problem I encountered and does not consider performance and other issues.
clang-tidy will prompt "condition is always false" in if (stop_). Even though I have already set stop_ to true in other function interfaces.
`
Contributor guide
Research direction
Begin with the supplied C++ example and inspect clang-tidy's handling of stop_ across Stop() and execute_task(). Done means establishing whether cross-thread checks are supported, identifying any configuration or limitation, and documenting the expected behavior or a reproducible change request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100