Skip to content

Commit ac43709

Browse files
committed
[OpenACC] Ensure ArrayRef and SmallVector are kept in sync.
My OpenACCReductionRecipeWithStorage attempted to get its allocations in sync with the ArrayRef so I could use the arrayref to refer to the allocation. Unfortunately I'd forgotten about the move constructor, which made it get out of sync, which Asan caught.
1 parent fe00ab4 commit ac43709

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

clang/include/clang/AST/OpenACCClause.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,13 +1311,37 @@ struct OpenACCReductionRecipe {
13111311
// the OpenACCReductionClause node has been created. This one has storage for
13121312
// the CombinerRecipe, since Trailing storage for it doesn't exist yet.
13131313
struct OpenACCReductionRecipeWithStorage : OpenACCReductionRecipe {
1314+
private:
13141315
llvm::SmallVector<CombinerRecipe, 1> CombinerRecipeStorage;
13151316

1317+
public:
13161318
OpenACCReductionRecipeWithStorage(VarDecl *A,
13171319
llvm::ArrayRef<CombinerRecipe> Combiners)
13181320
: OpenACCReductionRecipe(A, {}), CombinerRecipeStorage(Combiners) {
13191321
CombinerRecipes = CombinerRecipeStorage;
13201322
}
1323+
1324+
OpenACCReductionRecipeWithStorage(
1325+
const OpenACCReductionRecipeWithStorage &Other)
1326+
: OpenACCReductionRecipe(Other),
1327+
CombinerRecipeStorage(Other.CombinerRecipeStorage) {
1328+
CombinerRecipes = CombinerRecipeStorage;
1329+
}
1330+
1331+
OpenACCReductionRecipeWithStorage(OpenACCReductionRecipeWithStorage &&Other)
1332+
: OpenACCReductionRecipe(std::move(Other)),
1333+
CombinerRecipeStorage(std::move(Other.CombinerRecipeStorage)) {
1334+
CombinerRecipes = CombinerRecipeStorage;
1335+
}
1336+
1337+
// There is no real problem implementing these, we just have to make sure the
1338+
// array-ref this inherits from stays in sync. But as we don't need it at the
1339+
// moment, make sure we don't accidentially call these.
1340+
OpenACCReductionRecipeWithStorage &
1341+
operator=(OpenACCReductionRecipeWithStorage &&) = delete;
1342+
OpenACCReductionRecipeWithStorage &
1343+
operator=(const OpenACCReductionRecipeWithStorage &) = delete;
1344+
13211345
static OpenACCReductionRecipeWithStorage Empty() {
13221346
return OpenACCReductionRecipeWithStorage(/*AllocaDecl=*/nullptr, {});
13231347
}

0 commit comments

Comments
 (0)