Skip to content

Does clang-tidy support cross-thread checks? #167816

@Xlicks

Description

@Xlicks

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<std::string> 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions