[all-commits] [llvm/llvm-project] 1850f5: Thread safety analysis: Support deferring locks

Aaron Puchert via All-commits all-commits at lists.llvm.org
Mon Jun 8 08:08:48 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 1850f56c8abae637c2cc1b8d27b8577c5700101a
      https://github.com/llvm/llvm-project/commit/1850f56c8abae637c2cc1b8d27b8577c5700101a
  Author: Aaron Puchert <aaron.puchert at sap.com>
  Date:   2020-06-08 (Mon, 08 Jun 2020)

  Changed paths:
    M clang/lib/Analysis/ThreadSafety.cpp
    M clang/test/SemaCXX/warn-thread-safety-analysis.cpp

  Log Message:
  -----------
  Thread safety analysis: Support deferring locks

Summary:
The standard std::unique_lock can be constructed to manage a lock without
initially acquiring it by passing std::defer_lock as second parameter.
It can be acquired later by calling lock().

To support this, we use the locks_excluded attribute. This might seem
like an odd choice at first, but its consistent with the other
annotations we support on scoped capability constructors. By excluding
the lock we state that it is currently not in use and the function
doesn't change that, which is exactly what the constructor does.

Along the way we slightly simplify handling of scoped capabilities.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D81332


  Commit: f70912f885f991d5af11d8ecb10b703f3cbed982
      https://github.com/llvm/llvm-project/commit/f70912f885f991d5af11d8ecb10b703f3cbed982
  Author: Aaron Puchert <aaron.puchert at sap.com>
  Date:   2020-06-08 (Mon, 08 Jun 2020)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/ThreadSafety.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Analysis/ThreadSafety.cpp
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    M clang/test/Sema/warn-thread-safety-analysis.c
    M clang/test/SemaCXX/warn-thread-safety-analysis.cpp

  Log Message:
  -----------
  Thread safety analysis: Add note for double unlock

Summary:
When getting a warning that we release a capability that isn't held it's
sometimes not clear why. So just like we do for double locking, we add a
note on the previous release operation, which marks the point since when
the capability isn't held any longer.

We can find this previous release operation by looking up the
corresponding negative capability.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D81352


Compare: https://github.com/llvm/llvm-project/compare/31eeee1d8e0d...f70912f885f9


More information about the All-commits mailing list