Skip to content

Conversation

@erichkeane
Copy link
Collaborator

After misunderstanding what was going on in the ASAN patches, I finally realize I just missed a call to a destructor! This patch ensures that the Recipe is deleted properly with the AST.

After misunderstanding what was going on in the ASAN patches, I finally
realize I just missed a call to a destructor!  This patch ensures that
the Recipe is deleted properly with the AST.
@erichkeane erichkeane merged commit 09d9f50 into llvm:main Oct 13, 2025
8 of 11 checks passed
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 13, 2025

@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)

Changes

After misunderstanding what was going on in the ASAN patches, I finally realize I just missed a call to a destructor! This patch ensures that the Recipe is deleted properly with the AST.


Full diff: https://github.com/llvm/llvm-project/pull/163219.diff

1 Files Affected:

  • (modified) clang/include/clang/AST/OpenACCClause.h (+7-7)
diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index ab2bf0e08692c..613c03ce4ad64 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -1325,17 +1325,17 @@ class OpenACCReductionClause final
         Op(Operator) {
           assert(VarList.size() == Recipes.size());
     setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
+    llvm::uninitialized_copy(Recipes,
+                             getTrailingObjects<OpenACCReductionRecipe>());
+  }
 
-    // Initialize the recipe list.
-    unsigned I = 0;
-    for (const OpenACCReductionRecipe &R : Recipes) {
-      new (&getTrailingObjects<OpenACCReductionRecipe>()[I])
-          OpenACCReductionRecipe(R);
-      ++I;
+public:
+  ~OpenACCReductionClause() {
+    for (unsigned I = 0; I < getExprs().size(); ++I) {
+      getTrailingObjects<OpenACCReductionRecipe>()[I].~OpenACCReductionRecipe();
     }
   }
 
-public:
   static bool classof(const OpenACCClause *C) {
     return C->getClauseKind() == OpenACCClauseKind::Reduction;
   }

akadutta pushed a commit to akadutta/llvm-project that referenced this pull request Oct 14, 2025
After misunderstanding what was going on in the ASAN patches, I finally
realize I just missed a call to a destructor! This patch ensures that
the Recipe is deleted properly with the AST.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants