Changeset 4eb43fa


Ignore:
Timestamp:
Jul 22, 2019, 4:23:33 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
96ac72c
Parents:
f53acdf8 (diff), f6cc734e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'new-ast' of plg.uwaterloo.ca:software/cfa/cfa-cc into new-ast

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Attribute.hpp

    rf53acdf8 r4eb43fa  
    5151        template<typename node_t>
    5252        friend node_t * mutate(const node_t * node);
     53        template<typename node_t>
     54    friend node_t * shallowCopy(const node_t * node);
    5355};
    5456
  • src/AST/Convert.cpp

    rf53acdf8 r4eb43fa  
    608608
    609609                tgt->result = get<Type>().accept1(src->result);
     610                // Unconditionally use a clone of the result type.
     611                // We know this will leak some objects: much of the immediate conversion result.
     612                // In some cases, using the conversion result directly gives unintended object sharing.
     613                // A parameter (ObjectDecl, a child of a FunctionType) is shared by the weak-ref cache.
     614                // But tgt->result must be fully owned privately by tgt.
     615                // Applying these conservative copies here means
     616                // - weak references point at the declaration's copy, not these expr.result copies (good)
     617                // - we copy more objects than really needed (bad, tolerated)
     618                if (tgt->result) {
     619                        tgt->result = tgt->result->clone();
     620                }
    610621                return visitBaseExpr_skipResultType(src, tgt);
    611622        }
  • src/AST/Copy.hpp

    rf53acdf8 r4eb43fa  
    2323
    2424template<typename node_t>
    25 const node_t * shallowCopy( const node_t * node ) {
     25node_t * shallowCopy( const node_t * node );
    2626/* Create a shallow copy of the node given.
    2727 *
     
    3131
    3232template<typename node_t>
    33 node_t * deepCopy( node_t const * localRoot );
     33node_t * deepCopy( const node_t * localRoot );
    3434/* Create a deep copy of the tree rooted at localRoot.
    3535 *
     
    106106
    107107template<typename node_t>
    108 node_t * shallowCopy( node_t const * localRoot ) {
     108node_t * shallowCopy( const node_t * localRoot ) {
    109109        return localRoot->clone();
    110110}
    111111
    112112template<typename node_t>
    113 node_t * deepCopy( node_t const * localRoot ) {
     113node_t * deepCopy( const node_t * localRoot ) {
    114114        Pass< DeepCopyCore > dc;
    115115        node_t const * newRoot = localRoot->accept( dc );
  • src/AST/Decl.hpp

    rf53acdf8 r4eb43fa  
    3232
    3333// Must be included in *all* AST classes; should be #undef'd at the end of the file
    34 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     34#define MUTATE_FRIEND \
     35    template<typename node_t> friend node_t * mutate(const node_t * node); \
     36        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3537
    3638namespace ast {
  • src/AST/Expr.hpp

    rf53acdf8 r4eb43fa  
    3030
    3131// Must be included in *all* AST classes; should be #undef'd at the end of the file
    32 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     32#define MUTATE_FRIEND \
     33    template<typename node_t> friend node_t * mutate(const node_t * node); \
     34        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
     35
    3336
    3437class ConverterOldToNew;
  • src/AST/Init.hpp

    rf53acdf8 r4eb43fa  
    2525
    2626// Must be included in *all* AST classes; should be #undef'd at the end of the file
    27 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     27#define MUTATE_FRIEND \
     28    template<typename node_t> friend node_t * mutate(const node_t * node); \
     29        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    2830
    2931namespace ast {
  • src/AST/Node.hpp

    rf53acdf8 r4eb43fa  
    5757        template<typename node_t>
    5858        friend node_t * mutate(const node_t * node);
     59        template<typename node_t>
     60        friend node_t * shallowCopy(const node_t * node);
    5961
    6062        mutable size_t strong_count = 0;
  • src/AST/Stmt.hpp

    rf53acdf8 r4eb43fa  
    2727
    2828// Must be included in *all* AST classes; should be #undef'd at the end of the file
    29 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     29#define MUTATE_FRIEND \
     30    template<typename node_t> friend node_t * mutate(const node_t * node); \
     31        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3032
    3133namespace ast {
  • src/AST/Type.hpp

    rf53acdf8 r4eb43fa  
    3030
    3131// Must be included in *all* AST classes; should be #undef'd at the end of the file
    32 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     32#define MUTATE_FRIEND \
     33    template<typename node_t> friend node_t * mutate(const node_t * node); \
     34        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3335
    3436namespace ast {
  • src/ResolvExpr/RenameVars.cc

    rf53acdf8 r4eb43fa  
    3030#include "SynTree/Type.h"          // for Type, TypeInstType, TraitInstType
    3131#include "SynTree/Visitor.h"       // for acceptAll, maybeAccept
     32
     33#include "AST/Copy.hpp"
    3234
    3335namespace ResolvExpr {
     
    172174
    173175const ast::Type * renameTyVars( const ast::Type * t ) {
     176        ast::Type *tc = ast::deepCopy(t);
    174177        ast::Pass<RenameVars_new> renamer;
    175         return t->accept( renamer );
     178//      return t->accept( renamer );
     179        return tc->accept( renamer );
    176180}
    177181
Note: See TracChangeset for help on using the changeset viewer.