Issue 128201
Summary [clang-tidy] Check request: bugprone-thread-local-synchronization-primitive
Labels clang-tidy
Assignees
Reporter denzor200
    Needs a check that will find definitions of synchronization primitives(like `std::mutex`, `std::condition_variable`, etc) with `thread_local` attribute and suggest removing that attribute.

BEFORE
```
thread_local std::mutex m;
```

AFTER
```
std::mutex m;
```

https://godbolt.org/z/W9E4jWMKW

You might be surprised seeing that code snippet and you may doubt the usefulness of the diagnostics I propose talking "How can you even make such a mistake in your code? It's impossible to allow `thread_local` to be used with `std::mutex` without explicit intent! It's a nonsense!". I completely understand you - I never seen the code like this in real code bases written by humans. But it possible to find in the code written by ChatGPT... The bot wished us happy debugging:)

So, the things are changing - we are living in 2025 and we review the code not only written by humans. And our review tool(I mean Clang Tidy) must also begin adapting to new reality.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to