https://github.com/melver created https://github.com/llvm/llvm-project/pull/179049
Test that cleanup attribute is handled correctly in the presence of a unary operator before scope end. NFC. >From c3a5f4ac4e029340ced62245e1451fb23735afc6 Mon Sep 17 00:00:00 2001 From: Marco Elver <[email protected]> Date: Sat, 31 Jan 2026 16:43:57 +0100 Subject: [PATCH] Thread Safety Analysis: Add more complex cleanup attribute test Test that cleanup attribute is handled correctly in the presence of a unary operator before scope end. NFC. --- clang/test/Sema/warn-thread-safety-analysis.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clang/test/Sema/warn-thread-safety-analysis.c b/clang/test/Sema/warn-thread-safety-analysis.c index 53594609e902d..69ec109e1523c 100644 --- a/clang/test/Sema/warn-thread-safety-analysis.c +++ b/clang/test/Sema/warn-thread-safety-analysis.c @@ -192,6 +192,12 @@ int main(void) { struct Mutex* const __attribute__((unused, cleanup(unlock_scope))) scope = &mu1; mutex_exclusive_lock(&mu1); // With basic alias analysis lock through mu1 also works. } + { + int i = 0; + mutex_exclusive_lock(&mu1); + struct Mutex* const __attribute__((unused, cleanup(unlock_scope))) scope = &mu1; + i++; + } // Cleanup through cast alias pointer in a for-loop; a variant of this pattern // appears in the Linux kernel for generic scoped guard macros. for (int i = (mutex_exclusive_lock(foo_.mu_), 0), _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
