clang-extra: fix incorrect use of std::lock_guard by adding variable name (identified by MSVC [[nodiscard]] error)

`std::lock_guard` is an RAII class that needs a variable name whose scope determines the guard's lifetime. This particular usage lacked a variable name, meaning the guard could be destroyed before the line that it was indented to protect.

This line was identified by building clang with the latest MSVC preview release, which declares the std::lock_guard constructor to be `[[nodiscard]]` to draw attention to such issues.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D95725
This commit is contained in:
Conrad Poelman 2021-02-02 05:59:38 +01:00 committed by Kadir Cetinkaya
parent ecb00a7762
commit 0b70c86e20
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
1 changed files with 1 additions and 1 deletions

View File

@ -51,7 +51,7 @@ public:
Subscription &operator=(Subscription &&Other) {
// If *this is active, unsubscribe.
if (Parent) {
std::lock_guard<std::recursive_mutex>(Parent->ListenersMu);
std::lock_guard<std::recursive_mutex> Lock(Parent->ListenersMu);
llvm::erase_if(Parent->Listeners,
[&](const std::pair<Listener, unsigned> &P) {
return P.second == ListenerID;