[all-commits] [llvm/llvm-project] 9dcc82: Thread safety analysis: Consider global variables ...

Aaron Puchert via All-commits all-commits at lists.llvm.org
Sat Sep 5 08:27:09 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9dcc82f34ea9b623d82d2577b93aaf67d36dabd2
      https://github.com/llvm/llvm-project/commit/9dcc82f34ea9b623d82d2577b93aaf67d36dabd2
  Author: Aaron Puchert <aaronpuchert at alice-dsl.net>
  Date:   2020-09-05 (Sat, 05 Sep 2020)

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

  Log Message:
  -----------
  Thread safety analysis: Consider global variables in scope

Instead of just mutex members we also consider mutex globals.
Unsurprisingly they are always in scope. Now the paper [1] says that

> The scope of a class member is assumed to be its enclosing class,
> while the scope of a global variable is the translation unit in
> which it is defined.

But I don't think we should limit this to TUs where a definition is
available - a declaration is enough to acquire the mutex, and if a mutex
is really limited in scope to a translation unit, it should probably be
only declared there.

[1] https://static.googleusercontent.com/media/research.google.com/en/us/pubs/archive/42958.pdf

Fixes PR46354.

Reviewed By: aaron.ballman

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


  Commit: b2ce79ef66157dd752e3864ece57915e23a73f5d
      https://github.com/llvm/llvm-project/commit/b2ce79ef66157dd752e3864ece57915e23a73f5d
  Author: Aaron Puchert <aaronpuchert at alice-dsl.net>
  Date:   2020-09-05 (Sat, 05 Sep 2020)

  Changed paths:
    M clang/lib/Analysis/ThreadSafety.cpp
    M clang/lib/Analysis/ThreadSafetyCommon.cpp

  Log Message:
  -----------
  Thread safety analysis: ValueDecl in Project is non-null

The constructor asserts that, use it in the ThreadSafetyAnalyzer.
Also note that the result of a cast<> cannot be null.


Compare: https://github.com/llvm/llvm-project/compare/ac87480bd8be...b2ce79ef6615


More information about the All-commits mailing list