[all-commits] [llvm/llvm-project] a999ab: Thread safety analysis: Fix substitution for opera...

Aaron Puchert via All-commits all-commits at lists.llvm.org
Sat Dec 14 07:55:05 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a999ab44be8994d39d2469c1b4d025c4e1131197
      https://github.com/llvm/llvm-project/commit/a999ab44be8994d39d2469c1b4d025c4e1131197
  Author: Aaron Puchert <aaron.puchert at sap.com>
  Date:   2024-12-14 (Sat, 14 Dec 2024)

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

  Log Message:
  -----------
  Thread safety analysis: Fix substitution for operator calls (#116487)

For operator calls that go to methods we need to substitute the first
parameter for "this" and the following parameters into the function
parameters, instead of substituting all of them into the parameters.

This revealed an issue about lambdas. An existing test accidentally
worked because the substitution bug was covered by a speciality of
lambdas: a CXXThisExpr in a lambda CXXMethodDecl does not refer to the
implicit this argument of the method, but to a captured "this" from the
context the lambda was created in. This can happen for operator calls,
where it worked due to the substitution bug (we treated the implicit
this argument incorrectly as parameter), and for regular calls (i.e.
obj.operator()(args) instead of obj(args)), where it didn't work.

The correct fix seems to be to clear the self-argument on a lambda call.
Lambdas can only capture "this" inside methods, and calls to the lambda
in that scope cannot substitute anything for "this".



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list