OSDN Git Service

clang-extra: fix incorrect use of std::lock_guard by adding variable name (identified...
authorConrad Poelman <cpgithub@stellarscience.com>
Tue, 2 Feb 2021 04:59:38 +0000 (05:59 +0100)
committerTom Stellard <tstellar@redhat.com>
Mon, 22 Feb 2021 20:07:39 +0000 (12:07 -0800)
commit76e4c93ea42b3d23907611d14e347bfeae8d4b0a
treedc263f4642754db0ca7d5e2994640176cf6404cf
parent3444f052006ca2b19052a4599dd9001b01088c25
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

(cherry picked from commit 0b70c86e2007d3f32968f0a7d9efe8eab3bf0f0a)
clang-tools-extra/clangd/support/Function.h