@@ -42,11 +42,11 @@ namespace patchestry::ast {
4242 virtual ~SNode () = default ;
4343
4444 SNodeKind kind () const { return kind_; }
45- static const char *kindName (SNodeKind k);
46- const char *kindName () const { return kindName (kind_); }
45+ static const char *kind_name (SNodeKind k);
46+ const char *kind_name () const { return kind_name (kind_); }
4747
4848 SNode *parent () const { return parent_; }
49- void setParent (SNode *p) { parent_ = p; }
49+ void set_parent (SNode *p) { parent_ = p; }
5050
5151 void dump (llvm::raw_ostream &os, unsigned indent = 0 ) const ;
5252
@@ -62,7 +62,7 @@ namespace patchestry::ast {
6262 const T *dyn_cast () const { return isa< T >() ? static_cast < const T * >(this ) : nullptr ; }
6363
6464 protected:
65- virtual void dumpChildren (llvm::raw_ostream & /* os*/ , unsigned /* indent*/ ) const {}
65+ virtual void dump_children (llvm::raw_ostream & /* os*/ , unsigned /* indent*/ ) const {}
6666
6767 private:
6868 SNodeKind kind_;
@@ -78,38 +78,38 @@ namespace patchestry::ast {
7878 const std::vector< SNode * > &children () const { return children_; }
7979 std::vector< SNode * > &children () { return children_; }
8080
81- void addChild (SNode *child) {
82- child->setParent (this );
81+ void add_child (SNode *child) {
82+ child->set_parent (this );
8383 children_.push_back (child);
8484 }
8585
86- void insertChild (size_t pos, SNode *child) {
87- child->setParent (this );
86+ void insert_child (size_t pos, SNode *child) {
87+ child->set_parent (this );
8888 children_.insert (children_.begin () + static_cast < ptrdiff_t >(pos), child);
8989 }
9090
91- void removeChild (size_t pos) {
91+ void remove_child (size_t pos) {
9292 children_.erase (children_.begin () + static_cast < ptrdiff_t >(pos));
9393 }
9494
95- void replaceChild (size_t pos, SNode *child) {
96- child->setParent (this );
95+ void replace_child (size_t pos, SNode *child) {
96+ child->set_parent (this );
9797 children_[pos] = child;
9898 }
9999
100100 // Replace a range [from, to) with a single node
101- void replaceRange (size_t from, size_t to, SNode *replacement) {
102- replacement->setParent (this );
101+ void replace_range (size_t from, size_t to, SNode *replacement) {
102+ replacement->set_parent (this );
103103 auto begin = children_.begin ();
104104 children_.erase (begin + static_cast < ptrdiff_t >(from) + 1 ,
105105 begin + static_cast < ptrdiff_t >(to));
106106 children_[from] = replacement;
107107 }
108108
109109 // Replace a range [from, to) with multiple nodes
110- void replaceRange (size_t from, size_t to,
111- const std::vector< SNode * > &replacements) {
112- for (auto *r : replacements) r->setParent (this );
110+ void replace_range (size_t from, size_t to,
111+ const std::vector< SNode * > &replacements) {
112+ for (auto *r : replacements) r->set_parent (this );
113113 auto begin = children_.begin ();
114114 children_.erase (begin + static_cast < ptrdiff_t >(from),
115115 begin + static_cast < ptrdiff_t >(to));
@@ -125,7 +125,7 @@ namespace patchestry::ast {
125125 static bool classof (const SNode *n) { return n->kind () == SNodeKind::SEQ; }
126126
127127 protected:
128- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
128+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
129129
130130 private:
131131 std::vector< SNode * > children_;
@@ -138,19 +138,19 @@ namespace patchestry::ast {
138138 SBlock () : SNode(SNodeKind::BLOCK) {}
139139
140140 std::string_view label () const { return label_; }
141- void setLabel (std::string_view l) { label_ = l; }
141+ void set_label (std::string_view l) { label_ = l; }
142142
143143 const std::vector< clang::Stmt * > &stmts () const { return stmts_; }
144144 std::vector< clang::Stmt * > &stmts () { return stmts_; }
145145
146- void addStmt (clang::Stmt *s) { stmts_.push_back (s); }
146+ void add_stmt (clang::Stmt *s) { stmts_.push_back (s); }
147147 bool empty () const { return stmts_.empty (); }
148148 size_t size () const { return stmts_.size (); }
149149
150150 static bool classof (const SNode *n) { return n->kind () == SNodeKind::BLOCK; }
151151
152152 protected:
153- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
153+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
154154
155155 private:
156156 std::string label_;
@@ -165,23 +165,23 @@ namespace patchestry::ast {
165165 : SNode(SNodeKind::IF_THEN_ELSE)
166166 , cond_(cond), then_(then_branch), else_(else_branch)
167167 {
168- if (then_) then_->setParent (this );
169- if (else_) else_->setParent (this );
168+ if (then_) then_->set_parent (this );
169+ if (else_) else_->set_parent (this );
170170 }
171171
172172 clang::Expr *cond () const { return cond_; }
173- void setCond (clang::Expr *c) { cond_ = c; }
173+ void set_cond (clang::Expr *c) { cond_ = c; }
174174
175- SNode *thenBranch () const { return then_; }
176- void setThenBranch (SNode *n) { then_ = n; if (n) n->setParent (this ); }
175+ SNode *then_branch () const { return then_; }
176+ void set_then_branch (SNode *n) { then_ = n; if (n) n->set_parent (this ); }
177177
178- SNode *elseBranch () const { return else_; }
179- void setElseBranch (SNode *n) { else_ = n; if (n) n->setParent (this ); }
178+ SNode *else_branch () const { return else_; }
179+ void set_else_branch (SNode *n) { else_ = n; if (n) n->set_parent (this ); }
180180
181181 static bool classof (const SNode *n) { return n->kind () == SNodeKind::IF_THEN_ELSE; }
182182
183183 protected:
184- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
184+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
185185
186186 private:
187187 clang::Expr *cond_;
@@ -196,19 +196,19 @@ namespace patchestry::ast {
196196 SWhile (clang::Expr *cond, SNode *body)
197197 : SNode(SNodeKind::WHILE), cond_(cond), body_(body)
198198 {
199- if (body_) body_->setParent (this );
199+ if (body_) body_->set_parent (this );
200200 }
201201
202202 clang::Expr *cond () const { return cond_; }
203- void setCond (clang::Expr *c) { cond_ = c; }
203+ void set_cond (clang::Expr *c) { cond_ = c; }
204204
205205 SNode *body () const { return body_; }
206- void setBody (SNode *n) { body_ = n; if (n) n->setParent (this ); }
206+ void set_body (SNode *n) { body_ = n; if (n) n->set_parent (this ); }
207207
208208 static bool classof (const SNode *n) { return n->kind () == SNodeKind::WHILE; }
209209
210210 protected:
211- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
211+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
212212
213213 private:
214214 clang::Expr *cond_;
@@ -222,19 +222,19 @@ namespace patchestry::ast {
222222 SDoWhile (SNode *body, clang::Expr *cond)
223223 : SNode(SNodeKind::DO_WHILE), body_(body), cond_(cond)
224224 {
225- if (body_) body_->setParent (this );
225+ if (body_) body_->set_parent (this );
226226 }
227227
228228 SNode *body () const { return body_; }
229- void setBody (SNode *n) { body_ = n; if (n) n->setParent (this ); }
229+ void set_body (SNode *n) { body_ = n; if (n) n->set_parent (this ); }
230230
231231 clang::Expr *cond () const { return cond_; }
232- void setCond (clang::Expr *c) { cond_ = c; }
232+ void set_cond (clang::Expr *c) { cond_ = c; }
233233
234234 static bool classof (const SNode *n) { return n->kind () == SNodeKind::DO_WHILE; }
235235
236236 protected:
237- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
237+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
238238
239239 private:
240240 SNode *body_;
@@ -249,25 +249,25 @@ namespace patchestry::ast {
249249 : SNode(SNodeKind::FOR)
250250 , init_(init), cond_(cond), inc_(inc), body_(body)
251251 {
252- if (body_) body_->setParent (this );
252+ if (body_) body_->set_parent (this );
253253 }
254254
255255 clang::Stmt *init () const { return init_; }
256- void setInit (clang::Stmt *s) { init_ = s; }
256+ void set_init (clang::Stmt *s) { init_ = s; }
257257
258258 clang::Expr *cond () const { return cond_; }
259- void setCond (clang::Expr *c) { cond_ = c; }
259+ void set_cond (clang::Expr *c) { cond_ = c; }
260260
261261 clang::Expr *inc () const { return inc_; }
262- void setInc (clang::Expr *e) { inc_ = e; }
262+ void set_inc (clang::Expr *e) { inc_ = e; }
263263
264264 SNode *body () const { return body_; }
265- void setBody (SNode *n) { body_ = n; if (n) n->setParent (this ); }
265+ void set_body (SNode *n) { body_ = n; if (n) n->set_parent (this ); }
266266
267267 static bool classof (const SNode *n) { return n->kind () == SNodeKind::FOR; }
268268
269269 protected:
270- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
270+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
271271
272272 private:
273273 clang::Stmt *init_;
@@ -291,23 +291,23 @@ namespace patchestry::ast {
291291 {}
292292
293293 clang::Expr *discriminant () const { return discriminant_; }
294- void setDiscriminant (clang::Expr *e) { discriminant_ = e; }
294+ void set_discriminant (clang::Expr *e) { discriminant_ = e; }
295295
296296 const std::vector< SCase > &cases () const { return cases_; }
297297 std::vector< SCase > &cases () { return cases_; }
298298
299- void addCase (clang::Expr *value, SNode *body) {
300- if (body) body->setParent (this );
299+ void add_case (clang::Expr *value, SNode *body) {
300+ if (body) body->set_parent (this );
301301 cases_.push_back ({value, body});
302302 }
303303
304- SNode *defaultBody () const { return default_; }
305- void setDefaultBody (SNode *n) { default_ = n; if (n) n->setParent (this ); }
304+ SNode *default_body () const { return default_; }
305+ void set_default_body (SNode *n) { default_ = n; if (n) n->set_parent (this ); }
306306
307307 static bool classof (const SNode *n) { return n->kind () == SNodeKind::SWITCH; }
308308
309309 protected:
310- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
310+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
311311
312312 private:
313313 clang::Expr *discriminant_;
@@ -322,7 +322,7 @@ namespace patchestry::ast {
322322 SGoto (std::string_view target) : SNode(SNodeKind::GOTO), target_(target) {}
323323
324324 std::string_view target () const { return target_; }
325- void setTarget (std::string_view t) { target_ = t; }
325+ void set_target (std::string_view t) { target_ = t; }
326326
327327 static bool classof (const SNode *n) { return n->kind () == SNodeKind::GOTO; }
328328
@@ -337,19 +337,19 @@ namespace patchestry::ast {
337337 SLabel (std::string_view name, SNode *body = nullptr )
338338 : SNode(SNodeKind::LABEL), name_(name), body_(body)
339339 {
340- if (body_) body_->setParent (this );
340+ if (body_) body_->set_parent (this );
341341 }
342342
343343 std::string_view name () const { return name_; }
344- void setName (std::string_view n) { name_ = n; }
344+ void set_name (std::string_view n) { name_ = n; }
345345
346346 SNode *body () const { return body_; }
347- void setBody (SNode *n) { body_ = n; if (n) n->setParent (this ); }
347+ void set_body (SNode *n) { body_ = n; if (n) n->set_parent (this ); }
348348
349349 static bool classof (const SNode *n) { return n->kind () == SNodeKind::LABEL; }
350350
351351 protected:
352- void dumpChildren (llvm::raw_ostream &os, unsigned indent) const override ;
352+ void dump_children (llvm::raw_ostream &os, unsigned indent) const override ;
353353
354354 private:
355355 std::string name_;
@@ -363,7 +363,7 @@ namespace patchestry::ast {
363363 SBreak (unsigned depth = 1 ) : SNode(SNodeKind::BREAK), depth_(depth) {}
364364
365365 unsigned depth () const { return depth_; }
366- void setDepth (unsigned d) { depth_ = d; }
366+ void set_depth (unsigned d) { depth_ = d; }
367367
368368 static bool classof (const SNode *n) { return n->kind () == SNodeKind::BREAK; }
369369
@@ -389,7 +389,7 @@ namespace patchestry::ast {
389389 {}
390390
391391 clang::Expr *value () const { return value_; }
392- void setValue (clang::Expr *e) { value_ = e; }
392+ void set_value (clang::Expr *e) { value_ = e; }
393393
394394 static bool classof (const SNode *n) { return n->kind () == SNodeKind::RETURN; }
395395
0 commit comments