source: src/ResolvExpr/Resolver.cc @ 8f9cc50

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 8f9cc50 was 8f9cc50, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Merge branch 'master' into tuples

  • Property mode set to 100644
File size: 20.8 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Resolver.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 12:17:01 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Jul 12 17:45:42 2016
13// Update Count     : 204
14//
15
16#include "Resolver.h"
17#include "AlternativeFinder.h"
18#include "Alternative.h"
19#include "RenameVars.h"
20#include "ResolveTypeof.h"
21#include "typeops.h"
22#include "SynTree/Statement.h"
23#include "SynTree/Type.h"
24#include "SynTree/Expression.h"
25#include "SynTree/Initializer.h"
26#include "SymTab/Indexer.h"
27#include "SymTab/Autogen.h"
28#include "Common/utility.h"
29#include "InitTweak/InitTweak.h"
30
31#include <iostream>
32using namespace std;
33
34namespace ResolvExpr {
35        class Resolver final : public SymTab::Indexer {
36          public:
37                Resolver() : SymTab::Indexer( false ) {}
38
39                using SymTab::Indexer::visit;
40                virtual void visit( FunctionDecl *functionDecl ) override;
41                virtual void visit( ObjectDecl *functionDecl ) override;
42                virtual void visit( TypeDecl *typeDecl ) override;
43                virtual void visit( EnumDecl * enumDecl ) override;
44
45                virtual void visit( ArrayType * at ) override;
46                virtual void visit( PointerType * at ) override;
47
48                virtual void visit( ExprStmt *exprStmt ) override;
49                virtual void visit( AsmExpr *asmExpr ) override;
50                virtual void visit( AsmStmt *asmStmt ) override;
51                virtual void visit( IfStmt *ifStmt ) override;
52                virtual void visit( WhileStmt *whileStmt ) override;
53                virtual void visit( ForStmt *forStmt ) override;
54                virtual void visit( SwitchStmt *switchStmt ) override;
55                virtual void visit( CaseStmt *caseStmt ) override;
56                virtual void visit( BranchStmt *branchStmt ) override;
57                virtual void visit( ReturnStmt *returnStmt ) override;
58
59                virtual void visit( SingleInit *singleInit ) override;
60                virtual void visit( ListInit *listInit ) override;
61                virtual void visit( ConstructorInit *ctorInit ) override;
62          private:
63        typedef std::list< Initializer * >::iterator InitIterator;
64
65                template< typename PtrType >
66                void handlePtrType( PtrType * type );
67
68          void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & );
69          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub );
70          void fallbackInit( ConstructorInit * ctorInit );
71
72                Type * functionReturn = nullptr;
73                Type *initContext = nullptr;
74                bool inEnumDecl = false;
75        };
76
77        void resolve( std::list< Declaration * > translationUnit ) {
78                Resolver resolver;
79                acceptAll( translationUnit, resolver );
80#if 0
81                resolver.print( cerr );
82                for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
83                        (*i)->print( std::cerr );
84                        (*i)->accept( resolver );
85                } // for
86#endif
87        }
88
89        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
90                TypeEnvironment env;
91                return resolveInVoidContext( expr, indexer, env );
92        }
93
94
95        namespace {
96                void finishExpr( Expression *expr, const TypeEnvironment &env ) {
97                        expr->set_env( new TypeSubstitution );
98                        env.makeSubstitution( *expr->get_env() );
99                }
100        } // namespace
101
102        Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
103                global_renamer.reset();
104                TypeEnvironment env;
105                Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
106                finishExpr( newExpr, env );
107                return newExpr;
108        }
109
110        namespace {
111                Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
112                        TypeEnvironment env;
113                        AlternativeFinder finder( indexer, env );
114                        finder.find( untyped );
115#if 0
116                        if ( finder.get_alternatives().size() != 1 ) {
117                                std::cout << "untyped expr is ";
118                                untyped->print( std::cout );
119                                std::cout << std::endl << "alternatives are:";
120                                for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
121                                        i->print( std::cout );
122                                } // for
123                        } // if
124#endif
125                        assert( finder.get_alternatives().size() == 1 );
126                        Alternative &choice = finder.get_alternatives().front();
127                        Expression *newExpr = choice.expr->clone();
128                        finishExpr( newExpr, choice.env );
129                        return newExpr;
130                }
131
132                bool isIntegralType( Type *type ) {
133                        if ( dynamic_cast< EnumInstType * >( type ) ) {
134                                return true;
135                        } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
136                                return bt->isInteger();
137                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
138                                return true;
139                        } else {
140                                return false;
141                        } // if
142                }
143
144                Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
145                        TypeEnvironment env;
146                        AlternativeFinder finder( indexer, env );
147                        finder.find( untyped );
148#if 0
149                        if ( finder.get_alternatives().size() != 1 ) {
150                                std::cout << "untyped expr is ";
151                                untyped->print( std::cout );
152                                std::cout << std::endl << "alternatives are:";
153                                for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
154                                        i->print( std::cout );
155                                } // for
156                        } // if
157#endif
158                        Expression *newExpr = 0;
159                        const TypeEnvironment *newEnv = 0;
160                        for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
161                                if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {
162                                        if ( newExpr ) {
163                                                throw SemanticError( "Too many interpretations for case control expression", untyped );
164                                        } else {
165                                                newExpr = i->expr->clone();
166                                                newEnv = &i->env;
167                                        } // if
168                                } // if
169                        } // for
170                        if ( ! newExpr ) {
171                                throw SemanticError( "No interpretations for case control expression", untyped );
172                        } // if
173                        finishExpr( newExpr, *newEnv );
174                        return newExpr;
175                }
176
177        }
178
179        void Resolver::visit( ObjectDecl *objectDecl ) {
180                Type *new_type = resolveTypeof( objectDecl->get_type(), *this );
181                objectDecl->set_type( new_type );
182                // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that class-variable
183                // initContext is changed multiple time because the LHS is analysed twice. The second analysis changes
184                // initContext because of a function type can contain object declarations in the return and parameter types. So
185                // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting
186                // the RHS.
187                Type *temp = initContext;
188                initContext = new_type;
189                if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
190                        // enumerator initializers should not use the enum type to initialize, since
191                        // the enum type is still incomplete at this point. Use signed int instead.
192                        initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
193                }
194                SymTab::Indexer::visit( objectDecl );
195                if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
196                        // delete newly created signed int type
197                        delete initContext;
198                }
199                initContext = temp;
200        }
201
202        template< typename PtrType >
203        void Resolver::handlePtrType( PtrType * type ) {
204                if ( type->get_dimension() ) {
205                        CastExpr *castExpr = new CastExpr( type->get_dimension(), SymTab::SizeType->clone() );
206                        Expression *newExpr = findSingleExpression( castExpr, *this );
207                        delete type->get_dimension();
208                        type->set_dimension( newExpr );
209                }
210        }
211
212        void Resolver::visit( ArrayType * at ) {
213                handlePtrType( at );
214                Visitor::visit( at );
215        }
216
217        void Resolver::visit( PointerType * pt ) {
218                handlePtrType( pt );
219                Visitor::visit( pt );
220        }
221
222        void Resolver::visit( TypeDecl *typeDecl ) {
223                if ( typeDecl->get_base() ) {
224                        Type *new_type = resolveTypeof( typeDecl->get_base(), *this );
225                        typeDecl->set_base( new_type );
226                } // if
227                SymTab::Indexer::visit( typeDecl );
228        }
229
230        void Resolver::visit( FunctionDecl *functionDecl ) {
231#if 0
232                std::cout << "resolver visiting functiondecl ";
233                functionDecl->print( std::cout );
234                std::cout << std::endl;
235#endif
236                Type *new_type = resolveTypeof( functionDecl->get_type(), *this );
237                functionDecl->set_type( new_type );
238                ValueGuard< Type * > oldFunctionReturn( functionReturn );
239                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
240                SymTab::Indexer::visit( functionDecl );
241        }
242
243        void Resolver::visit( EnumDecl * enumDecl ) {
244                // in case we decide to allow nested enums
245                bool oldInEnumDecl = inEnumDecl;
246                inEnumDecl = true;
247                SymTab::Indexer::visit( enumDecl );
248                inEnumDecl = oldInEnumDecl;
249        }
250
251        void Resolver::visit( ExprStmt *exprStmt ) {
252                if ( exprStmt->get_expr() ) {
253                        Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this );
254                        delete exprStmt->get_expr();
255                        exprStmt->set_expr( newExpr );
256                } // if
257        }
258
259        void Resolver::visit( AsmExpr *asmExpr ) {
260                Expression *newExpr = findVoidExpression( asmExpr->get_operand(), *this );
261                delete asmExpr->get_operand();
262                asmExpr->set_operand( newExpr );
263                if ( asmExpr->get_inout() ) {
264                        newExpr = findVoidExpression( asmExpr->get_inout(), *this );
265                        delete asmExpr->get_inout();
266                        asmExpr->set_inout( newExpr );
267                } // if
268        }
269
270        void Resolver::visit( AsmStmt *asmStmt ) {
271                acceptAll( asmStmt->get_input(), *this);
272                acceptAll( asmStmt->get_output(), *this);
273        }
274
275        void Resolver::visit( IfStmt *ifStmt ) {
276                Expression *newExpr = findSingleExpression( ifStmt->get_condition(), *this );
277                delete ifStmt->get_condition();
278                ifStmt->set_condition( newExpr );
279                Visitor::visit( ifStmt );
280        }
281
282        void Resolver::visit( WhileStmt *whileStmt ) {
283                Expression *newExpr = findSingleExpression( whileStmt->get_condition(), *this );
284                delete whileStmt->get_condition();
285                whileStmt->set_condition( newExpr );
286                Visitor::visit( whileStmt );
287        }
288
289        void Resolver::visit( ForStmt *forStmt ) {
290                SymTab::Indexer::visit( forStmt );
291
292                if ( forStmt->get_condition() ) {
293                        Expression * newExpr = findSingleExpression( forStmt->get_condition(), *this );
294                        delete forStmt->get_condition();
295                        forStmt->set_condition( newExpr );
296                } // if
297
298                if ( forStmt->get_increment() ) {
299                        Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this );
300                        delete forStmt->get_increment();
301                        forStmt->set_increment( newExpr );
302                } // if
303        }
304
305        template< typename SwitchClass >
306        void handleSwitchStmt( SwitchClass *switchStmt, SymTab::Indexer &visitor ) {
307                Expression *newExpr;
308                newExpr = findIntegralExpression( switchStmt->get_condition(), visitor );
309                delete switchStmt->get_condition();
310                switchStmt->set_condition( newExpr );
311
312                visitor.Visitor::visit( switchStmt );
313        }
314
315        void Resolver::visit( SwitchStmt *switchStmt ) {
316                handleSwitchStmt( switchStmt, *this );
317        }
318
319        void Resolver::visit( CaseStmt *caseStmt ) {
320                Visitor::visit( caseStmt );
321        }
322
323        void Resolver::visit( BranchStmt *branchStmt ) {
324                // must resolve the argument for a computed goto
325                if ( branchStmt->get_type() == BranchStmt::Goto ) { // check for computed goto statement
326                        if ( Expression * arg = branchStmt->get_computedTarget() ) {
327                                VoidType v = Type::Qualifiers();                // cast to void * for the alternative finder
328                                PointerType pt( Type::Qualifiers(), v.clone() );
329                                CastExpr * castExpr = new CastExpr( arg, pt.clone() );
330                                Expression * newExpr = findSingleExpression( castExpr, *this ); // find best expression
331                                branchStmt->set_target( newExpr );
332                        } // if
333                } // if
334        }
335
336        void Resolver::visit( ReturnStmt *returnStmt ) {
337                if ( returnStmt->get_expr() ) {
338                        CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() );
339                        Expression *newExpr = findSingleExpression( castExpr, *this );
340                        delete castExpr;
341                        returnStmt->set_expr( newExpr );
342                } // if
343        }
344
345        template< typename T >
346        bool isCharType( T t ) {
347                if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) {
348                        return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar ||
349                                bt->get_kind() == BasicType::UnsignedChar;
350                }
351                return false;
352        }
353
354        void Resolver::visit( SingleInit *singleInit ) {
355                if ( singleInit->get_value() ) {
356#if 0
357                        if (NameExpr * ne = dynamic_cast<NameExpr*>(singleInit->get_value())) {
358                                string n = ne->get_name();
359                                if (n == "0") {
360                                        initContext = new BasicType(Type::Qualifiers(),
361                                                                                                BasicType::SignedInt);
362                                } else {
363                                        DeclarationWithType * decl = lookupId( n );
364                                        initContext = decl->get_type();
365                                }
366                        } else if (ConstantExpr * e =
367                                           dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
368                                Constant *c = e->get_constant();
369                                initContext = c->get_type();
370                        } else {
371                                assert(0);
372                        }
373#endif
374                        CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
375                        Expression *newExpr = findSingleExpression( castExpr, *this );
376                        delete castExpr;
377                        singleInit->set_value( newExpr );
378
379                        // check if initializing type is char[]
380                        if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
381                                if ( isCharType( at->get_base() ) ) {
382                                        // check if the resolved type is char *
383                                        if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
384                                                if ( isCharType( pt->get_base() ) ) {
385                                                        // strip cast if we're initializing a char[] with a char *, e.g.  char x[] = "hello";
386                                                        CastExpr *ce = dynamic_cast< CastExpr * >( newExpr );
387                                                        singleInit->set_value( ce->get_arg() );
388                                                        ce->set_arg( NULL );
389                                                        delete ce;
390                                                }
391                                        }
392                                }
393                        }
394                } // if
395//      singleInit->get_value()->accept( *this );
396        }
397
398        template< typename AggrInst >
399        TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) {
400                std::list< TypeDecl * > baseParams = *inst->get_baseParameters();
401                std::list< Expression * > typeSubs = inst->get_parameters();
402                TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() );
403                return subs;
404        }
405
406        ReferenceToType * isStructOrUnion( Type * type ) {
407                if ( StructInstType * sit = dynamic_cast< StructInstType * >( type ) ) {
408                        return sit;
409                } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( type ) ) {
410                        return uit;
411                }
412                return nullptr;
413        }
414
415        void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd, TypeSubstitution sub ) {
416                DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl );
417                assert( dt );
418                // need to substitute for generic types, so that casts are to concrete types
419                initContext = dt->get_type()->clone();
420                sub.apply( initContext );
421
422                try {
423                        if ( init == initEnd ) return; // stop when there are no more initializers
424                        (*init)->accept( *this );
425                        ++init; // made it past an initializer
426                } catch( SemanticError & ) {
427                        // need to delve deeper, if you can
428                        if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
429                                resolveAggrInit( type, init, initEnd );
430                        } else {
431                                // member is not an aggregate type, so can't go any deeper
432
433                                // might need to rethink what is being thrown
434                                throw;
435                        } // if
436                }
437        }
438
439        void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) {
440
441                if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) {
442                        TypeSubstitution sub = makeGenericSubstitutuion( sit );
443                        StructDecl * st = sit->get_baseStruct();
444                        // want to resolve each initializer to the members of the struct,
445                        // but if there are more initializers than members we should stop
446                        list< Declaration * >::iterator it = st->get_members().begin();
447                        for ( ; it != st->get_members().end(); ++it) {
448                                resolveSingleAggrInit( *it, init, initEnd, sub );
449                        }
450                } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
451                        TypeSubstitution sub = makeGenericSubstitutuion( sit );
452                        UnionDecl * un = uit->get_baseUnion();
453                        // only resolve to the first member of a union
454                        resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub );
455                } // if
456        }
457
458        void Resolver::visit( ListInit * listInit ) {
459                InitIterator iter = listInit->begin();
460                InitIterator end = listInit->end();
461
462                if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) {
463                        // resolve each member to the base type of the array
464                        for ( ; iter != end; ++iter ) {
465                                initContext = at->get_base();
466                                (*iter)->accept( *this );
467                        } // for
468                } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) {
469                        for ( Type * t : *tt ) {
470                                if ( iter == end ) break;
471                                initContext = t;
472                                (*iter++)->accept( *this );
473                        }
474                } else if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
475                        resolveAggrInit( type, iter, end );
476                } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
477                        Type * base = tt->get_baseType()->get_base();
478                        if ( base ) {
479                                // know the implementation type, so try using that as the initContext
480                                initContext = base;
481                                visit( listInit );
482                        } else {
483                                // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
484                                Visitor::visit( listInit );
485                        }
486                } else {
487                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
488                                || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
489                        // basic types are handled here
490                        Visitor::visit( listInit );
491                }
492
493#if 0
494                if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) {
495                        std::list<Initializer *>::iterator iter( listInit->begin_initializers() );
496                        for ( ; iter != listInit->end_initializers(); ++iter ) {
497                                initContext = at->get_base();
498                                (*iter)->accept( *this );
499                        } // for
500                } else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) {
501                        StructDecl *baseStruct = st->get_baseStruct();
502                        std::list<Declaration *>::iterator iter1( baseStruct->get_members().begin() );
503                        std::list<Initializer *>::iterator iter2( listInit->begin_initializers() );
504                        for ( ; iter1 != baseStruct->get_members().end() && iter2 != listInit->end_initializers(); ++iter2 ) {
505                                if ( (*iter2)->get_designators().empty() ) {
506                                        DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *iter1 );
507                                        initContext = dt->get_type();
508                                        (*iter2)->accept( *this );
509                                        ++iter1;
510                                } else {
511                                        StructDecl *st = baseStruct;
512                                        iter1 = st->get_members().begin();
513                                        std::list<Expression *>::iterator iter3( (*iter2)->get_designators().begin() );
514                                        for ( ; iter3 != (*iter2)->get_designators().end(); ++iter3 ) {
515                                                NameExpr *key = dynamic_cast<NameExpr *>( *iter3 );
516                                                assert( key );
517                                                for ( ; iter1 != st->get_members().end(); ++iter1 ) {
518                                                        if ( key->get_name() == (*iter1)->get_name() ) {
519                                                                (*iter1)->print( cout );
520                                                                cout << key->get_name() << endl;
521                                                                ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
522                                                                assert( fred );
523                                                                StructInstType *mary = dynamic_cast<StructInstType*>( fred->get_type() );
524                                                                assert( mary );
525                                                                st = mary->get_baseStruct();
526                                                                iter1 = st->get_members().begin();
527                                                                break;
528                                                        } // if
529                                                }  // for
530                                        } // for
531                                        ObjectDecl *fred = dynamic_cast<ObjectDecl *>( *iter1 );
532                                        assert( fred );
533                                        initContext = fred->get_type();
534                                        (*listInit->begin_initializers())->accept( *this );
535                                } // if
536                        } // for
537                } else if ( UnionInstType *st = dynamic_cast<UnionInstType*>(initContext) ) {
538                        DeclarationWithType *dt = dynamic_cast<DeclarationWithType *>( *st->get_baseUnion()->get_members().begin() );
539                        initContext = dt->get_type();
540                        (*listInit->begin_initializers())->accept( *this );
541                } // if
542#endif
543        }
544
545        // ConstructorInit - fall back on C-style initializer
546        void Resolver::fallbackInit( ConstructorInit * ctorInit ) {
547                // could not find valid constructor, or found an intrinsic constructor
548                // fall back on C-style initializer
549                delete ctorInit->get_ctor();
550                ctorInit->set_ctor( NULL );
551                delete ctorInit->get_dtor();
552                ctorInit->set_dtor( NULL );
553                maybeAccept( ctorInit->get_init(), *this );
554        }
555
556        void Resolver::visit( ConstructorInit *ctorInit ) {
557                // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
558                maybeAccept( ctorInit->get_ctor(), *this );
559                maybeAccept( ctorInit->get_dtor(), *this );
560
561                // found a constructor - can get rid of C-style initializer
562                delete ctorInit->get_init();
563                ctorInit->set_init( NULL );
564
565                // intrinsic single parameter constructors and destructors do nothing. Since this was
566                // implicitly generated, there's no way for it to have side effects, so get rid of it
567                // to clean up generated code.
568                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {
569                        delete ctorInit->get_ctor();
570                        ctorInit->set_ctor( NULL );
571                }
572
573                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_dtor() ) ) {
574                        delete ctorInit->get_dtor();
575                        ctorInit->set_dtor( NULL );
576                }
577
578                // xxx - todo -- what about arrays?
579                // if ( dtor == NULL && InitTweak::isIntrinsicCallStmt( ctorInit->get_ctor() ) ) {
580                //      // can reduce the constructor down to a SingleInit using the
581                //      // second argument from the ctor call, since
582                //      delete ctorInit->get_ctor();
583                //      ctorInit->set_ctor( NULL );
584
585                //      Expression * arg =
586                //      ctorInit->set_init( new SingleInit( arg ) );
587                // }
588        }
589} // namespace ResolvExpr
590
591// Local Variables: //
592// tab-width: 4 //
593// mode: c++ //
594// compile-command: "make install" //
595// End: //
Note: See TracBrowser for help on using the repository browser.