@@ -282,10 +282,14 @@ raw_ostream &operator<<(raw_ostream &os, SymbolTable::Visibility visibility);
282
282
// / unnecessary tables.
283
283
class SymbolTableCollection {
284
284
public:
285
+ virtual ~SymbolTableCollection () = default ;
286
+
285
287
// / Look up a symbol with the specified name within the specified symbol table
286
288
// / operation, returning null if no such name exists.
287
- Operation *lookupSymbolIn (Operation *symbolTableOp, StringAttr symbol);
288
- Operation *lookupSymbolIn (Operation *symbolTableOp, SymbolRefAttr name);
289
+ virtual Operation *lookupSymbolIn (Operation *symbolTableOp,
290
+ StringAttr symbol);
291
+ virtual Operation *lookupSymbolIn (Operation *symbolTableOp,
292
+ SymbolRefAttr name);
289
293
template <typename T, typename NameT>
290
294
T lookupSymbolIn (Operation *symbolTableOp, NameT &&name) {
291
295
return dyn_cast_or_null<T>(
@@ -295,15 +299,18 @@ class SymbolTableCollection {
295
299
// / by a given SymbolRefAttr when resolved within the provided symbol table
296
300
// / operation. Returns failure if any of the nested references could not be
297
301
// / resolved.
298
- LogicalResult lookupSymbolIn (Operation *symbolTableOp, SymbolRefAttr name,
299
- SmallVectorImpl<Operation *> &symbols);
302
+ virtual LogicalResult lookupSymbolIn (Operation *symbolTableOp,
303
+ SymbolRefAttr name,
304
+ SmallVectorImpl<Operation *> &symbols);
300
305
301
306
// / Returns the operation registered with the given symbol name within the
302
307
// / closest parent operation of, or including, 'from' with the
303
308
// / 'OpTrait::SymbolTable' trait. Returns nullptr if no valid symbol was
304
309
// / found.
305
- Operation *lookupNearestSymbolFrom (Operation *from, StringAttr symbol);
306
- Operation *lookupNearestSymbolFrom (Operation *from, SymbolRefAttr symbol);
310
+ virtual Operation *lookupNearestSymbolFrom (Operation *from,
311
+ StringAttr symbol);
312
+ virtual Operation *lookupNearestSymbolFrom (Operation *from,
313
+ SymbolRefAttr symbol);
307
314
template <typename T>
308
315
T lookupNearestSymbolFrom (Operation *from, StringAttr symbol) {
309
316
return dyn_cast_or_null<T>(lookupNearestSymbolFrom (from, symbol));
@@ -314,14 +321,14 @@ class SymbolTableCollection {
314
321
}
315
322
316
323
// / Lookup, or create, a symbol table for an operation.
317
- SymbolTable &getSymbolTable (Operation *op);
324
+ virtual SymbolTable &getSymbolTable (Operation *op);
318
325
319
326
// / Invalidate the cached symbol table for an operation.
320
327
// / This is important when doing IR modifications that erase and also create
321
328
// / operations having the 'OpTrait::SymbolTable' trait. If a symbol table of
322
329
// / an erased operation is not invalidated, a new operation sharing the same
323
330
// / address would be associated with outdated, and wrong, information.
324
- void invalidateSymbolTable (Operation *op);
331
+ virtual void invalidateSymbolTable (Operation *op);
325
332
326
333
private:
327
334
friend class LockedSymbolTableCollection ;
@@ -348,13 +355,15 @@ class LockedSymbolTableCollection : public SymbolTableCollection {
348
355
349
356
// / Look up a symbol with the specified name within the specified symbol table
350
357
// / operation, returning null if no such name exists.
351
- Operation *lookupSymbolIn (Operation *symbolTableOp, StringAttr symbol);
358
+ Operation *lookupSymbolIn (Operation *symbolTableOp,
359
+ StringAttr symbol) override ;
352
360
// / Look up a symbol with the specified name within the specified symbol table
353
361
// / operation, returning null if no such name exists.
354
362
Operation *lookupSymbolIn (Operation *symbolTableOp, FlatSymbolRefAttr symbol);
355
363
// / Look up a potentially nested symbol within the specified symbol table
356
364
// / operation, returning null if no such symbol exists.
357
- Operation *lookupSymbolIn (Operation *symbolTableOp, SymbolRefAttr name);
365
+ Operation *lookupSymbolIn (Operation *symbolTableOp,
366
+ SymbolRefAttr name) override ;
358
367
359
368
// / Lookup a symbol of a particular kind within the specified symbol table,
360
369
// / returning null if the symbol was not found.
@@ -369,14 +378,14 @@ class LockedSymbolTableCollection : public SymbolTableCollection {
369
378
// / operation. Returns failure if any of the nested references could not be
370
379
// / resolved.
371
380
LogicalResult lookupSymbolIn (Operation *symbolTableOp, SymbolRefAttr name,
372
- SmallVectorImpl<Operation *> &symbols);
381
+ SmallVectorImpl<Operation *> &symbols) override ;
373
382
374
383
private:
375
384
// / Get the symbol table for the symbol table operation, constructing if it
376
385
// / does not exist. This function provides thread safety over `collection`
377
386
// / by locking when performing the lookup and when inserting
378
387
// / lazily-constructed symbol tables.
379
- SymbolTable &getSymbolTable (Operation *symbolTableOp);
388
+ SymbolTable &getSymbolTable (Operation *symbolTableOp) override ;
380
389
381
390
// / The symbol tables to manage.
382
391
SymbolTableCollection &collection;
0 commit comments