Ignore:
Timestamp:
Sep 22, 2017, 1:50:00 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
b56c17c
Parents:
05807e9
Message:

Cleanup pass through several files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r05807e9 r8b11840  
    1616#include "Autogen.h"
    1717
    18 #include <cstddef>                 // for NULL
    1918#include <algorithm>               // for count_if
    2019#include <cassert>                 // for strict_dynamic_cast, assert, assertf
     
    3231#include "GenPoly/DeclMutator.h"   // for DeclMutator
    3332#include "GenPoly/ScopedSet.h"     // for ScopedSet, ScopedSet<>::iterator
     33#include "InitTweak/GenInit.h"     // for fixReturnStatements
     34#include "ResolvExpr/Resolver.h"   // for resolveDecl
    3435#include "SymTab/Mangler.h"        // for Mangler
    3536#include "SynTree/Attribute.h"     // For Attribute
     
    108109
    109110        bool isUnnamedBitfield( ObjectDecl * obj ) {
    110                 return obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL;
     111                return obj != nullptr && obj->get_name() == "" && obj->get_bitfieldWidth() != nullptr;
    111112        }
    112113
     
    115116                FunctionDecl * decl = functionDecl->clone();
    116117                delete decl->get_statements();
    117                 decl->set_statements( NULL );
     118                decl->set_statements( nullptr );
    118119                declsToAdd.push_back( decl );
    119120                decl->fixUniqueId();
     
    326327                                assert( ! func->get_functionType()->get_parameters().empty() );
    327328                                ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().front() );
    328                                 ObjectDecl * srcParam = NULL;
     329                                ObjectDecl * srcParam = nullptr;
    329330                                if ( func->get_functionType()->get_parameters().size() == 2 ) {
    330331                                        srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().back() );
     
    333334                                assert( dstParam );
    334335
    335                                 Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL;
     336                                Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : nullptr;
    336337                                makeStructMemberOp( dstParam, srcselect, field, func, forward );
    337338                        } // if
     
    372373                                } else {
    373374                                        // no matching parameter, initialize field with default ctor
    374                                         makeStructMemberOp( dstParam, NULL, field, func );
     375                                        makeStructMemberOp( dstParam, nullptr, field, func );
    375376                                }
    376377                        }
     
    388389        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) {
    389390                // Builtins do not use autogeneration.
    390                 if ( aggregateDecl->get_linkage() == LinkageSpec::BuiltinCFA ||
    391                          aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) {
     391                if ( LinkageSpec::isBuiltin( aggregateDecl->get_linkage() ) ) {
    392392                        return;
    393393                }
    394394
    395395                // Make function polymorphic in same parameters as generic struct, if applicable
    396                 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
     396                const std::list< TypeDecl * > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    397397
    398398                // generate each of the functions based on the supplied FuncData objects
     
    565565        }
    566566
    567         void AutogenerateRoutines::previsit( EnumDecl *enumDecl ) {
     567        void AutogenerateRoutines::previsit( EnumDecl * enumDecl ) {
    568568                visit_children = false;
    569569                if ( ! enumDecl->get_members().empty() ) {
     
    574574        }
    575575
    576         void AutogenerateRoutines::previsit( StructDecl *structDecl ) {
     576        void AutogenerateRoutines::previsit( StructDecl * structDecl ) {
    577577                visit_children = false;
    578                 if ( structDecl->has_body() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
    579                         StructInstType structInst( Type::Qualifiers(), structDecl->get_name() );
    580                         for ( TypeDecl * typeDecl : structDecl->get_parameters() ) {
     578                if ( structDecl->has_body() && structsDone.find( structDecl->name ) == structsDone.end() ) {
     579                        StructInstType structInst( Type::Qualifiers(), structDecl->name );
     580                        for ( TypeDecl * typeDecl : structDecl->parameters ) {
    581581                                // need to visit assertions so that they are added to the appropriate maps
    582                                 acceptAll( typeDecl->get_assertions(), *visitor );
    583                                 structInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
     582                                acceptAll( typeDecl->assertions, *visitor );
     583                                structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
    584584                        }
    585585                        structInst.set_baseStruct( structDecl );
    586586                        makeStructFunctions( structDecl, &structInst, functionNesting, declsToAddAfter, data );
    587                         structsDone.insert( structDecl->get_name() );
     587                        structsDone.insert( structDecl->name );
    588588                } // if
    589589        }
    590590
    591         void AutogenerateRoutines::previsit( UnionDecl *unionDecl ) {
     591        void AutogenerateRoutines::previsit( UnionDecl * unionDecl ) {
    592592                visit_children = false;
    593593                if ( ! unionDecl->get_members().empty() ) {
     
    609609
    610610        // generate ctor/dtors/assign for typedecls, e.g., otype T = int *;
    611         void AutogenerateRoutines::previsit( TypeDecl *typeDecl ) {
     611        void AutogenerateRoutines::previsit( TypeDecl * typeDecl ) {
    612612                visit_children = false;
    613613                if ( ! typeDecl->base ) return;
     
    678678                insert( functionDecl, destructable, InitTweak::isDestructor );
    679679
    680                 maybeAccept( functionDecl->get_functionType(), *visitor );
     680                maybeAccept( functionDecl->type, *visitor );
    681681                functionNesting += 1;
    682                 maybeAccept( functionDecl->get_statements(), *visitor );
     682                maybeAccept( functionDecl->statements, *visitor );
    683683                functionNesting -= 1;
    684684        }
Note: See TracChangeset for help on using the changeset viewer.