[clang] [Clang] Fix crash involving `__attribute__((cleanup))` attributes and improve handling of multiple `cleanup` attributes (PR #207785)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 7 08:08:15 PDT 2026


================
@@ -3904,6 +3904,13 @@ static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
     return;
   }
 
+  // If a declaration contains multiple cleanup attributes, GCC only uses
+  // the last one.
+  if (auto *A = D->getAttr<CleanupAttr>()) {
----------------
AaronBallman wrote:

```suggestion
  if (const auto *A = D->getAttr<CleanupAttr>()) {
```

https://github.com/llvm/llvm-project/pull/207785


More information about the cfe-commits mailing list