Changeset 4c868cb2


Ignore:
Timestamp:
Sep 14, 2020, 1:36:21 PM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7a8f62c3
Parents:
9a05b81
Message:

fix a potential issue with pure function interface

this makes pure passes no longer exactly pure, however
most likely required to make patterns like RenameVars?
work without deep copying. truly pure passes should not
overwrite decl nodes so there should be no effect.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r9a05b81 r4c868cb2  
    6767                }
    6868
     69                /// mutate should NEVER create new decl since it risks invalidating weak refs
     70                /// called by visit template with correct type information so static type checking should suffice
    6971                template< typename core_t, typename node_t >
    7072                static inline node_t* mutate(const node_t *node) {
    71                         return std::is_base_of<PureVisitor, core_t>::value ? ::ast::shallowCopy(node) : ::ast::mutate(node);
     73                        // force copying non-decl nodes as a pure function
     74                        return std::is_base_of<PureVisitor, core_t>::value && !std::is_base_of<ast::Decl, node_t>::value
     75                        ? ::ast::shallowCopy(node) : ::ast::mutate(node);
    7276                }
    7377
Note: See TracChangeset for help on using the changeset viewer.