Skip to content

Commit 09d9f50

Browse files
authored
[OpenACC] Fix memory leak for recipe list in Reduction (llvm#163219)
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.
1 parent 7a11eb9 commit 09d9f50

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clang/include/clang/AST/OpenACCClause.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,17 +1325,17 @@ class OpenACCReductionClause final
13251325
Op(Operator) {
13261326
assert(VarList.size() == Recipes.size());
13271327
setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
1328+
llvm::uninitialized_copy(Recipes,
1329+
getTrailingObjects<OpenACCReductionRecipe>());
1330+
}
13281331

1329-
// Initialize the recipe list.
1330-
unsigned I = 0;
1331-
for (const OpenACCReductionRecipe &R : Recipes) {
1332-
new (&getTrailingObjects<OpenACCReductionRecipe>()[I])
1333-
OpenACCReductionRecipe(R);
1334-
++I;
1332+
public:
1333+
~OpenACCReductionClause() {
1334+
for (unsigned I = 0; I < getExprs().size(); ++I) {
1335+
getTrailingObjects<OpenACCReductionRecipe>()[I].~OpenACCReductionRecipe();
13351336
}
13361337
}
13371338

1338-
public:
13391339
static bool classof(const OpenACCClause *C) {
13401340
return C->getClauseKind() == OpenACCClauseKind::Reduction;
13411341
}

0 commit comments

Comments
 (0)