[all-commits] [llvm/llvm-project] 0b70c8: clang-extra: fix incorrect use of std::lock_guard ...

Conrad Poelman via All-commits all-commits at lists.llvm.org
Mon Feb 1 21:08:36 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0b70c86e2007d3f32968f0a7d9efe8eab3bf0f0a
      https://github.com/llvm/llvm-project/commit/0b70c86e2007d3f32968f0a7d9efe8eab3bf0f0a
  Author: Conrad Poelman <cpgithub at stellarscience.com>
  Date:   2021-02-02 (Tue, 02 Feb 2021)

  Changed paths:
    M clang-tools-extra/clangd/support/Function.h

  Log Message:
  -----------
  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




More information about the All-commits mailing list