[all-commits] [llvm/llvm-project] e318fc: Thread Safety Analysis: Fix crash with wide string...
Marco Elver via All-commits
all-commits at lists.llvm.org
Tue Feb 10 14:48:31 PST 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e318fc8ce415ad93afb7c11d4ad60252038ac427
https://github.com/llvm/llvm-project/commit/e318fc8ce415ad93afb7c11d4ad60252038ac427
Author: Marco Elver <elver at google.com>
Date: 2026-02-10 (Tue, 10 Feb 2026)
Changed paths:
M clang/lib/Analysis/ThreadSafetyCommon.cpp
M clang/test/SemaCXX/warn-thread-safety-analysis.cpp
Log Message:
-----------
Thread Safety Analysis: Fix crash with wide string literals (#180349)
The SExprBuilder was previously using StringLiteral::getString() to
extract the value of string literals. This method asserts that the
string is a narrow string (char width == 1):
```
clang/include/clang/AST/Expr.h:1872: StringRef clang::StringLiteral::getString() const: Assertion `(isUnevaluated() || getCharByteWidth() == 1) && "This function is used in places that assume strings use char"' failed.
[...]
#9 0x0000556247fcfe3e clang::threadSafety::SExprBuilder::translate(clang::Stmt const*, clang::threadSafety::SExprBuilder::CallingContext*)
[...]
```
This fails when using wide string literals as in the new test case
added.
Switch to using StringLiteral::getBytes(), which provides the raw byte
representation of the string. This is sufficient to compare expressions
for identity.
Fixes: https://github.com/llvm/llvm-project/pull/148551
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