Changeset f326f99


Ignore:
Timestamp:
Apr 11, 2016, 4:56:43 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
f77f12e2
Parents:
eab39cd
Message:

add integer suffix to mangled names so that shadowed variables are accessable (needed for destructors to work correctly)

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    reab39cd rf326f99  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 04 17:08:06 2016
     12// Last Modified On : Mon Apr 11 15:30:52 2016
    1313// Update Count     : 255
    1414//
     
    6767        string mangleName( DeclarationWithType *decl ) {
    6868                if ( decl->get_mangleName() != "" ) {
    69                         return decl->get_mangleName();
     69                        // need to incorporate scope level in order to differentiate names for destructors
     70                        return decl->get_scopedMangleName();
    7071                } else {
    7172                        return decl->get_name();
  • src/CodeGen/FixNames.cc

    reab39cd rf326f99  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FixNames.cc -- 
     7// FixNames.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:36:42 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Apr 11 15:38:10 2016
    1313// Update Count     : 1
    1414//
     
    2626                virtual void visit( ObjectDecl *objectDecl );
    2727                virtual void visit( FunctionDecl *functionDecl );
     28
     29                virtual void visit( CompoundStmt *compoundStmt );
     30
     31          private:
     32                int scopeLevel = 1;
     33
     34                void fixDWT( DeclarationWithType *dwt );
    2835        };
    2936
     
    3340        }
    3441
    35         void fixDWT( DeclarationWithType *dwt ) {
     42        void FixNames::fixDWT( DeclarationWithType *dwt ) {
    3643                if ( dwt->get_name() != "" ) {
    3744                        if ( LinkageSpec::isDecoratable( dwt->get_linkage() ) ) {
    3845                                dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) );
     46                                dwt->set_scopeLevel( scopeLevel );
    3947                        } // if
    4048                } // if
     
    5058                fixDWT( functionDecl );
    5159        }
     60
     61        void FixNames::visit( CompoundStmt *compoundStmt ) {
     62                scopeLevel++;
     63                Visitor::visit( compoundStmt );
     64                scopeLevel--;
     65        }
    5266} // namespace CodeGen
    5367
  • src/SynTree/Declaration.h

    reab39cd rf326f99  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 04 17:14:00 2016
     12// Last Modified On : Mon Apr 11 16:55:12 2016
    1313// Update Count     : 36
    1414//
     
    2222#include "Parser/LinkageSpec.h"
    2323#include "Parser/ParseNode.h"
     24#include <string>
    2425
    2526class Declaration {
     
    6768        void set_mangleName( std::string newValue ) { mangleName = newValue; }
    6869
     70        std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
     71
     72        int get_scopeLevel() const { return scopeLevel; }
     73        void set_scopeLevel( int newValue ) { scopeLevel = newValue; }
     74
    6975        virtual DeclarationWithType *clone() const = 0;
    7076        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     
    7581        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    7682        std::string mangleName;
     83        // need to remember the scope level at which the variable was declared, so that
     84        // shadowed identifiers can be accessed
     85        int scopeLevel = 0;
    7786};
    7887
  • src/SynTree/DeclarationWithType.cc

    reab39cd rf326f99  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // DeclarationWithType.cc -- 
     7// DeclarationWithType.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 08:08:07 2015
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Apr 11 15:35:27 2016
    1313// Update Count     : 3
    1414//
     
    2323
    2424DeclarationWithType::DeclarationWithType( const DeclarationWithType &other )
    25                 : Declaration( other ), mangleName( other.mangleName ) {
     25                : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) {
    2626}
    2727
  • src/libcfa/Makefile.am

    reab39cd rf326f99  
    6767include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
    6868
     69CLEANFILES = libcfa-prelude.c
    6970MAINTAINERCLEANFILES += ${includedir}/*
  • src/libcfa/Makefile.in

    reab39cd rf326f99  
    218218cfaheaders = limits
    219219include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders}
     220CLEANFILES = libcfa-prelude.c
    220221all: all-am
    221222
     
    453454
    454455clean-generic:
     456        -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
    455457
    456458distclean-generic:
Note: See TracChangeset for help on using the changeset viewer.