Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 6d09b28

Browse files
committed
ScheduleTreeSequence: hide copy constructor
ScheduleTree nodes are not supposed to be manipulated by-value, only via unique pointers. Make the copy constructor of ScheduleTreeSequence private, similarly to its main constructor, and provide a static member function to return copies wrapped in a unique pointer. Note that unlike the conventional copy constructor, this static function takes a pointer to the tree rather than a reference. This keeps the API consistent as all other functions manipulate with pointers to the tree nodes rather than references.
1 parent ac7fee4 commit 6d09b28

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

tc/core/polyhedral/schedule_tree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static std::unique_ptr<ScheduleTree> makeElem(const ScheduleTree& st) {
143143
ELEM_MAKE_CASE_CSTR(ScheduleTreeExtension)
144144
ELEM_MAKE_CASE_CSTR(ScheduleTreeFilter)
145145
ELEM_MAKE_CASE_CSTR(ScheduleTreeMapping)
146-
ELEM_MAKE_CASE(ScheduleTreeSequence)
146+
ELEM_MAKE_CASE_CSTR(ScheduleTreeSequence)
147147
ELEM_MAKE_CASE(ScheduleTreeSet)
148148
ELEM_MAKE_CASE(ScheduleTreeThreadSpecificMarker)
149149

tc/core/polyhedral/schedule_tree_elem.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ std::unique_ptr<ScheduleTreeSequence> ScheduleTreeSequence::make(
158158
return res;
159159
}
160160

161+
std::unique_ptr<ScheduleTreeSequence> ScheduleTreeSequence::make(
162+
const ScheduleTreeSequence* tree,
163+
std::vector<ScheduleTreeUPtr>&& children) {
164+
auto res =
165+
std::unique_ptr<ScheduleTreeSequence>(new ScheduleTreeSequence(*tree));
166+
res->appendChildren(std::move(children));
167+
return res;
168+
}
169+
161170
std::unique_ptr<ScheduleTreeSet> ScheduleTreeSet::make(
162171
isl::ctx ctx,
163172
std::vector<ScheduleTreeUPtr>&& children) {

tc/core/polyhedral/schedule_tree_elem.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ struct ScheduleTreeSequence : public ScheduleTree {
211211
private:
212212
explicit ScheduleTreeSequence(isl::ctx ctx)
213213
: ScheduleTree(ctx, {}, NodeType) {}
214+
ScheduleTreeSequence(const ScheduleTreeSequence& eb) : ScheduleTree(eb) {}
214215

215216
public:
216-
ScheduleTreeSequence(const ScheduleTreeSequence& eb) : ScheduleTree(eb) {}
217217
virtual ~ScheduleTreeSequence() override {}
218218

219219
bool operator==(const ScheduleTreeSequence& other) const;
@@ -224,6 +224,9 @@ struct ScheduleTreeSequence : public ScheduleTree {
224224
static std::unique_ptr<ScheduleTreeSequence> make(
225225
isl::ctx ctx,
226226
std::vector<ScheduleTreeUPtr>&& children = {});
227+
static std::unique_ptr<ScheduleTreeSequence> make(
228+
const ScheduleTreeSequence* tree,
229+
std::vector<ScheduleTreeUPtr>&& children = {});
227230

228231
virtual std::ostream& write(std::ostream& os) const override;
229232
};

0 commit comments

Comments
 (0)