[all-commits] [llvm/llvm-project] 73417a: Thread Safety Analysis: Compare values of literals...

Aaron Puchert via All-commits all-commits at lists.llvm.org
Mon Feb 2 11:00:50 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 73417aa6424fec73765d21c3008245a7edd7cafe
      https://github.com/llvm/llvm-project/commit/73417aa6424fec73765d21c3008245a7edd7cafe
  Author: Aaron Puchert <aaronpuchert at alice-dsl.net>
  Date:   2026-02-02 (Mon, 02 Feb 2026)

  Changed paths:
    M clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
    M clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
    M clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h
    M clang/lib/Analysis/ThreadSafetyCommon.cpp
    M clang/test/SemaCXX/warn-thread-safety-analysis.cpp

  Log Message:
  -----------
  Thread Safety Analysis: Compare values of literals (#148551)

The typical case for literals is an array of mutexes, where we want to
distinguish `mutex[0]` from `mutex[1]` and so on. Currently they're
treated as the same expression, in fact all literals are treated as the
same expression.

The infrastructure for literals is already there, although it required
some changes, and some simplifications seemed opportune:
* The `ValueType` had fields for size and signedness. But only integer
have signedness, and the size is irrelevant if we don't want to emit
machine code. For the abstract semantics that we're interested in, only
the number matters.
* We remove the `BT_Void`: `void` literals don't exist in C++.
* We remove `BT_Float` and `BT_ValueRef`: floating-point numbers and
complex numbers are probably not used in lock expressions.
* We replace `BT_Pointer` with `BT_NullPointer`. There are no pointer
literals, only null pointer literals.

It seems to me that `ValueType` was intended to assign types to any node
in the TIL, but it is currently only used for literals. I was trying to
come up with reasons to assign types everywhere, but we're not trying to
type check anything, and we don't support overloading. The comparison of
expressions surely doesn't need it. But maybe this should be clarified
at some point. (Including the fact that it is called Typed Intermediate
Language.)

We turn `Literal` into a pure base class, as it seems to have been
intended, and only create `LiteralT` instances of the correct type.
Assertions on `as` ensure we're not mixing up types.

We print to `llvm::raw_ostream` instead of `std::ostream` because that's
required for `CharacterLiteral::print`.

Fixes https://github.com/llvm/llvm-project/issues/58535.



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