diff options
author | Marco Elver <elver@google.com> | 2025-07-16 08:45:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-16 08:45:45 +0200 |
commit | 871038759afb491c16fb2cd14b78e51e410efbf3 (patch) | |
tree | 370701cf0543a5647af9e834f5152cac700b4691 /clang/lib/AST/ByteCode/Compiler.cpp | |
parent | 5480fc6bb8ef6a6a895be7952d50d557116dcb38 (diff) | |
download | llvm-871038759afb491c16fb2cd14b78e51e410efbf3.zip llvm-871038759afb491c16fb2cd14b78e51e410efbf3.tar.gz llvm-871038759afb491c16fb2cd14b78e51e410efbf3.tar.bz2 |
Thread Safety Analysis: Fix pointer handling of variables with deprecated attributes (#148974)
de10e44b6fe7 ("Thread Safety Analysis: Support warning on
passing/returning pointers to guarded variables") added checks for
passing pointer to guarded variables. While new features do not
necessarily need to support the deprecated attributes (`guarded_var`,
and `pt_guarded_var`), we need to ensure that such features do not cause
the compiler to crash.
As such, code such as this:
struct {
int v __attribute__((guarded_var));
} p;
int *g() {
return &p.v; // handleNoMutexHeld() with POK_ReturnPointer
}
Would crash in debug builds with the assertion in handleNoMutexHeld()
triggering. The assertion is meant to capture the fact that this helper
should only be used for warnings on variables (which the deprecated
attributes only applied to).
To fix, the function handleNoMutexHeld() should handle all POK cases
that apply to variables explicitly, and produce a best-effort warning.
We refrain from introducing new warnings to avoid unnecessary code bloat
for deprecated features.
Fixes: https://github.com/llvm/llvm-project/issues/140330
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
0 files changed, 0 insertions, 0 deletions