Thread safety analysis: Warn when demoting locks on back edges
authorAaron Puchert <aaron.puchert@sap.com>
Sat, 18 Sep 2021 11:46:50 +0000 (13:46 +0200)
committerAaron Puchert <aaron.puchert@sap.com>
Sat, 18 Sep 2021 11:46:55 +0000 (13:46 +0200)
commit9b889f826ff587e9758c80823419512d502e457d
tree7a3049b5f42c72cc0c29e9b40f0554c10c7fe838
parent0eb75a41c5d46bda6e31bc33bb81acef1b0890f2
Thread safety analysis: Warn when demoting locks on back edges

Previously in D104261 we warned about dropping locks from back edges,
this is the corresponding change for exclusive/shared joins. If we're
entering the loop with an exclusive change, which is then relaxed to a
shared lock before we loop back, we have already analyzed the loop body
with the stronger exclusive lock and thus might have false positives.

There is a minor non-observable change: we modify the exit lock set of a
function, but since that isn't used further it doesn't change anything.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D106713
clang/lib/Analysis/ThreadSafety.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp