source: src/SymTab/Validate.cc @ 9cb8e88d

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 9cb8e88d was 9cb8e88d, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

validate constructors and destructors - ensure they return nothing, have at least one parameter, and take a pointer as the first parameter

  • Property mode set to 100644
File size: 40.9 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// Validate.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 21:50:04 2015
11// Last Modified By : Rob Schluntz
12// Last Modified On : Fri Dec 18 14:32:59 2015
13// Update Count     : 268
14//
15
16// The "validate" phase of translation is used to take a syntax tree and convert it into a standard form that aims to be
17// as regular in structure as possible.  Some assumptions can be made regarding the state of the tree after this pass is
18// complete, including:
19//
20// - No nested structure or union definitions; any in the input are "hoisted" to the level of the containing struct or
21//   union.
22//
23// - All enumeration constants have type EnumInstType.
24//
25// - The type "void" never occurs in lists of function parameter or return types; neither do tuple types.  A function
26//   taking no arguments has no argument types, and tuples are flattened.
27//
28// - No context instances exist; they are all replaced by the set of declarations signified by the context, instantiated
29//   by the particular set of type arguments.
30//
31// - Every declaration is assigned a unique id.
32//
33// - No typedef declarations or instances exist; the actual type is substituted for each instance.
34//
35// - Each type, struct, and union definition is followed by an appropriate assignment operator.
36//
37// - Each use of a struct or union is connected to a complete definition of that struct or union, even if that
38//   definition occurs later in the input.
39
40#include <list>
41#include <iterator>
42#include "Validate.h"
43#include "SynTree/Visitor.h"
44#include "SynTree/Mutator.h"
45#include "SynTree/Type.h"
46#include "SynTree/Statement.h"
47#include "SynTree/TypeSubstitution.h"
48#include "Indexer.h"
49#include "FixFunction.h"
50// #include "ImplementationType.h"
51#include "utility.h"
52#include "UniqueName.h"
53#include "AddVisit.h"
54#include "MakeLibCfa.h"
55#include "TypeEquality.h"
56#include "ResolvExpr/typeops.h"
57
58#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
59
60namespace SymTab {
61        class HoistStruct : public Visitor {
62          public:
63                /// Flattens nested struct types
64                static void hoistStruct( std::list< Declaration * > &translationUnit );
65
66                std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
67
68                virtual void visit( StructDecl *aggregateDecl );
69                virtual void visit( UnionDecl *aggregateDecl );
70
71                virtual void visit( CompoundStmt *compoundStmt );
72                virtual void visit( IfStmt *ifStmt );
73                virtual void visit( WhileStmt *whileStmt );
74                virtual void visit( ForStmt *forStmt );
75                virtual void visit( SwitchStmt *switchStmt );
76                virtual void visit( ChooseStmt *chooseStmt );
77                virtual void visit( CaseStmt *caseStmt );
78                virtual void visit( CatchStmt *catchStmt );
79          private:
80                HoistStruct();
81
82                template< typename AggDecl > void handleAggregate( AggDecl *aggregateDecl );
83
84                std::list< Declaration * > declsToAdd;
85                bool inStruct;
86        };
87
88        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers
89        class Pass1 : public Visitor {
90                typedef Visitor Parent;
91                virtual void visit( EnumDecl *aggregateDecl );
92                virtual void visit( FunctionType *func );
93        };
94
95        /// Associates forward declarations of aggregates with their definitions
96        class Pass2 : public Indexer {
97                typedef Indexer Parent;
98          public:
99                Pass2( bool doDebug, const Indexer *indexer );
100          private:
101                virtual void visit( StructInstType *structInst );
102                virtual void visit( UnionInstType *unionInst );
103                virtual void visit( ContextInstType *contextInst );
104                virtual void visit( StructDecl *structDecl );
105                virtual void visit( UnionDecl *unionDecl );
106                virtual void visit( TypeInstType *typeInst );
107
108                const Indexer *indexer;
109
110                typedef std::map< std::string, std::list< StructInstType * > > ForwardStructsType;
111                typedef std::map< std::string, std::list< UnionInstType * > > ForwardUnionsType;
112                ForwardStructsType forwardStructs;
113                ForwardUnionsType forwardUnions;
114        };
115
116        /// Replaces array and function types in forall lists by appropriate pointer type
117        class Pass3 : public Indexer {
118                typedef Indexer Parent;
119          public:
120                Pass3( const Indexer *indexer );
121          private:
122                virtual void visit( ObjectDecl *object );
123                virtual void visit( FunctionDecl *func );
124
125                const Indexer *indexer;
126        };
127
128        class AutogenerateRoutines : public Visitor {
129          public:
130                /// Generates assignment operators for aggregate types as required
131                static void autogenerateRoutines( std::list< Declaration * > &translationUnit );
132
133                std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
134
135                virtual void visit( EnumDecl *enumDecl );
136                virtual void visit( StructDecl *structDecl );
137                virtual void visit( UnionDecl *structDecl );
138                virtual void visit( TypeDecl *typeDecl );
139                virtual void visit( ContextDecl *ctxDecl );
140                virtual void visit( FunctionDecl *functionDecl );
141
142                virtual void visit( FunctionType *ftype );
143                virtual void visit( PointerType *ftype );
144
145                virtual void visit( CompoundStmt *compoundStmt );
146                virtual void visit( IfStmt *ifStmt );
147                virtual void visit( WhileStmt *whileStmt );
148                virtual void visit( ForStmt *forStmt );
149                virtual void visit( SwitchStmt *switchStmt );
150                virtual void visit( ChooseStmt *chooseStmt );
151                virtual void visit( CaseStmt *caseStmt );
152                virtual void visit( CatchStmt *catchStmt );
153
154                AutogenerateRoutines() : functionNesting( 0 ) {}
155          private:
156                template< typename StmtClass > void visitStatement( StmtClass *stmt );
157
158                std::list< Declaration * > declsToAdd;
159                std::set< std::string > structsDone;
160                unsigned int functionNesting;                   // current level of nested functions
161        };
162
163        class EliminateTypedef : public Mutator {
164          public:
165          EliminateTypedef() : scopeLevel( 0 ) {}
166            /// Replaces typedefs by forward declarations
167                static void eliminateTypedef( std::list< Declaration * > &translationUnit );
168          private:
169                virtual Declaration *mutate( TypedefDecl *typeDecl );
170                virtual TypeDecl *mutate( TypeDecl *typeDecl );
171                virtual DeclarationWithType *mutate( FunctionDecl *funcDecl );
172                virtual DeclarationWithType *mutate( ObjectDecl *objDecl );
173                virtual CompoundStmt *mutate( CompoundStmt *compoundStmt );
174                virtual Type *mutate( TypeInstType *aggregateUseType );
175                virtual Expression *mutate( CastExpr *castExpr );
176
177                virtual Declaration *mutate( StructDecl * structDecl );
178                virtual Declaration *mutate( UnionDecl * unionDecl );
179                virtual Declaration *mutate( EnumDecl * enumDecl );
180                virtual Declaration *mutate( ContextDecl * contextDecl );
181
182                template<typename AggDecl>
183                AggDecl *handleAggregate( AggDecl * aggDecl );
184
185                typedef std::map< std::string, std::pair< TypedefDecl *, int > > TypedefMap;
186                TypedefMap typedefNames;
187                int scopeLevel;
188        };
189
190        class VerifyCtorDtor : public Visitor {
191        public:
192                /// ensure that constructors and destructors have at least one
193                /// parameter, the first of which must be a pointer, and no
194                /// return values.
195                static void verify( std::list< Declaration * > &translationUnit );
196
197                // VerifyCtorDtor() {}
198
199                virtual void visit( FunctionDecl *funcDecl );
200        private:
201        };
202
203        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
204                Pass1 pass1;
205                Pass2 pass2( doDebug, 0 );
206                Pass3 pass3( 0 );
207                EliminateTypedef::eliminateTypedef( translationUnit );
208                HoistStruct::hoistStruct( translationUnit );
209                acceptAll( translationUnit, pass1 );
210                acceptAll( translationUnit, pass2 );
211                AutogenerateRoutines::autogenerateRoutines( translationUnit );
212                acceptAll( translationUnit, pass3 );
213                VerifyCtorDtor::verify( translationUnit );
214        }
215
216        void validateType( Type *type, const Indexer *indexer ) {
217                Pass1 pass1;
218                Pass2 pass2( false, indexer );
219                Pass3 pass3( indexer );
220                type->accept( pass1 );
221                type->accept( pass2 );
222                type->accept( pass3 );
223        }
224
225        template< typename Visitor >
226        void acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor, bool addBefore ) {
227                std::list< Declaration * >::iterator i = translationUnit.begin();
228                while ( i != translationUnit.end() ) {
229                        (*i)->accept( visitor );
230                        std::list< Declaration * >::iterator next = i;
231                        next++;
232                        if ( ! visitor.get_declsToAdd().empty() ) {
233                                translationUnit.splice( addBefore ? i : next, visitor.get_declsToAdd() );
234                        } // if
235                        i = next;
236                } // while
237        }
238
239        void HoistStruct::hoistStruct( std::list< Declaration * > &translationUnit ) {
240                HoistStruct hoister;
241                acceptAndAdd( translationUnit, hoister, true );
242        }
243
244        HoistStruct::HoistStruct() : inStruct( false ) {
245        }
246
247        void filter( std::list< Declaration * > &declList, bool (*pred)( Declaration * ), bool doDelete ) {
248                std::list< Declaration * >::iterator i = declList.begin();
249                while ( i != declList.end() ) {
250                        std::list< Declaration * >::iterator next = i;
251                        ++next;
252                        if ( pred( *i ) ) {
253                                if ( doDelete ) {
254                                        delete *i;
255                                } // if
256                                declList.erase( i );
257                        } // if
258                        i = next;
259                } // while
260        }
261
262        bool isStructOrUnion( Declaration *decl ) {
263                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
264        }
265
266        template< typename AggDecl >
267        void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) {
268                if ( inStruct ) {
269                        // Add elements in stack order corresponding to nesting structure.
270                        declsToAdd.push_front( aggregateDecl );
271                        Visitor::visit( aggregateDecl );
272                } else {
273                        inStruct = true;
274                        Visitor::visit( aggregateDecl );
275                        inStruct = false;
276                } // if
277                // Always remove the hoisted aggregate from the inner structure.
278                filter( aggregateDecl->get_members(), isStructOrUnion, false );
279        }
280
281        void HoistStruct::visit( StructDecl *aggregateDecl ) {
282                handleAggregate( aggregateDecl );
283        }
284
285        void HoistStruct::visit( UnionDecl *aggregateDecl ) {
286                handleAggregate( aggregateDecl );
287        }
288
289        void HoistStruct::visit( CompoundStmt *compoundStmt ) {
290                addVisit( compoundStmt, *this );
291        }
292
293        void HoistStruct::visit( IfStmt *ifStmt ) {
294                addVisit( ifStmt, *this );
295        }
296
297        void HoistStruct::visit( WhileStmt *whileStmt ) {
298                addVisit( whileStmt, *this );
299        }
300
301        void HoistStruct::visit( ForStmt *forStmt ) {
302                addVisit( forStmt, *this );
303        }
304
305        void HoistStruct::visit( SwitchStmt *switchStmt ) {
306                addVisit( switchStmt, *this );
307        }
308
309        void HoistStruct::visit( ChooseStmt *switchStmt ) {
310                addVisit( switchStmt, *this );
311        }
312
313        void HoistStruct::visit( CaseStmt *caseStmt ) {
314                addVisit( caseStmt, *this );
315        }
316
317        void HoistStruct::visit( CatchStmt *cathStmt ) {
318                addVisit( cathStmt, *this );
319        }
320
321        void Pass1::visit( EnumDecl *enumDecl ) {
322                // Set the type of each member of the enumeration to be EnumConstant
323
324                for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
325                        ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i );
326                        assert( obj );
327                        // obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) );
328                        BasicType * enumType = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
329                        obj->set_type( enumType ) ;
330                } // for
331                Parent::visit( enumDecl );
332        }
333
334        namespace {
335                template< typename DWTIterator >
336                void fixFunctionList( DWTIterator begin, DWTIterator end, FunctionType *func ) {
337                        // the only case in which "void" is valid is where it is the only one in the list; then it should be removed
338                        // entirely other fix ups are handled by the FixFunction class
339                        if ( begin == end ) return;
340                        FixFunction fixer;
341                        DWTIterator i = begin;
342                        *i = (*i )->acceptMutator( fixer );
343                        if ( fixer.get_isVoid() ) {
344                                DWTIterator j = i;
345                                ++i;
346                                func->get_parameters().erase( j );
347                                if ( i != end ) {
348                                        throw SemanticError( "invalid type void in function type ", func );
349                                } // if
350                        } else {
351                                ++i;
352                                for ( ; i != end; ++i ) {
353                                        FixFunction fixer;
354                                        *i = (*i )->acceptMutator( fixer );
355                                        if ( fixer.get_isVoid() ) {
356                                                throw SemanticError( "invalid type void in function type ", func );
357                                        } // if
358                                } // for
359                        } // if
360                }
361        }
362
363        void Pass1::visit( FunctionType *func ) {
364                // Fix up parameters and return types
365                fixFunctionList( func->get_parameters().begin(), func->get_parameters().end(), func );
366                fixFunctionList( func->get_returnVals().begin(), func->get_returnVals().end(), func );
367                Visitor::visit( func );
368        }
369
370        Pass2::Pass2( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {
371                if ( other_indexer ) {
372                        indexer = other_indexer;
373                } else {
374                        indexer = this;
375                } // if
376        }
377
378        void Pass2::visit( StructInstType *structInst ) {
379                Parent::visit( structInst );
380                StructDecl *st = indexer->lookupStruct( structInst->get_name() );
381                // it's not a semantic error if the struct is not found, just an implicit forward declaration
382                if ( st ) {
383                        assert( ! structInst->get_baseStruct() || structInst->get_baseStruct()->get_members().empty() || ! st->get_members().empty() );
384                        structInst->set_baseStruct( st );
385                } // if
386                if ( ! st || st->get_members().empty() ) {
387                        // use of forward declaration
388                        forwardStructs[ structInst->get_name() ].push_back( structInst );
389                } // if
390        }
391
392        void Pass2::visit( UnionInstType *unionInst ) {
393                Parent::visit( unionInst );
394                UnionDecl *un = indexer->lookupUnion( unionInst->get_name() );
395                // it's not a semantic error if the union is not found, just an implicit forward declaration
396                if ( un ) {
397                        unionInst->set_baseUnion( un );
398                } // if
399                if ( ! un || un->get_members().empty() ) {
400                        // use of forward declaration
401                        forwardUnions[ unionInst->get_name() ].push_back( unionInst );
402                } // if
403        }
404
405        void Pass2::visit( ContextInstType *contextInst ) {
406                Parent::visit( contextInst );
407                ContextDecl *ctx = indexer->lookupContext( contextInst->get_name() );
408                if ( ! ctx ) {
409                        throw SemanticError( "use of undeclared context " + contextInst->get_name() );
410                } // if
411                for ( std::list< TypeDecl * >::const_iterator i = ctx->get_parameters().begin(); i != ctx->get_parameters().end(); ++i ) {
412                        for ( std::list< DeclarationWithType * >::const_iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) {
413                                if ( ContextInstType *otherCtx = dynamic_cast< ContextInstType * >(*assert ) ) {
414                                        cloneAll( otherCtx->get_members(), contextInst->get_members() );
415                                } else {
416                                        contextInst->get_members().push_back( (*assert )->clone() );
417                                } // if
418                        } // for
419                } // for
420
421                if ( ctx->get_parameters().size() != contextInst->get_parameters().size() ) {
422                        throw SemanticError( "incorrect number of context parameters: ", contextInst );
423                } // if
424
425                applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) );
426        }
427
428        void Pass2::visit( StructDecl *structDecl ) {
429                if ( ! structDecl->get_members().empty() ) {
430                        ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->get_name() );
431                        if ( fwds != forwardStructs.end() ) {
432                                for ( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
433                                        (*inst )->set_baseStruct( structDecl );
434                                } // for
435                                forwardStructs.erase( fwds );
436                        } // if
437                } // if
438                Indexer::visit( structDecl );
439        }
440
441        void Pass2::visit( UnionDecl *unionDecl ) {
442                if ( ! unionDecl->get_members().empty() ) {
443                        ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->get_name() );
444                        if ( fwds != forwardUnions.end() ) {
445                                for ( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) {
446                                        (*inst )->set_baseUnion( unionDecl );
447                                } // for
448                                forwardUnions.erase( fwds );
449                        } // if
450                } // if
451                Indexer::visit( unionDecl );
452        }
453
454        void Pass2::visit( TypeInstType *typeInst ) {
455                if ( NamedTypeDecl *namedTypeDecl = lookupType( typeInst->get_name() ) ) {
456                        if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) {
457                                typeInst->set_isFtype( typeDecl->get_kind() == TypeDecl::Ftype );
458                        } // if
459                } // if
460        }
461
462        Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
463                if ( other_indexer ) {
464                        indexer = other_indexer;
465                } else {
466                        indexer = this;
467                } // if
468        }
469
470        /// Fix up assertions
471        void forallFixer( Type *func ) {
472                for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
473                        std::list< DeclarationWithType * > toBeDone, nextRound;
474                        toBeDone.splice( toBeDone.end(), (*type )->get_assertions() );
475                        while ( ! toBeDone.empty() ) {
476                                for ( std::list< DeclarationWithType * >::iterator assertion = toBeDone.begin(); assertion != toBeDone.end(); ++assertion ) {
477                                        if ( ContextInstType *ctx = dynamic_cast< ContextInstType * >( (*assertion )->get_type() ) ) {
478                                                for ( std::list< Declaration * >::const_iterator i = ctx->get_members().begin(); i != ctx->get_members().end(); ++i ) {
479                                                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *i );
480                                                        assert( dwt );
481                                                        nextRound.push_back( dwt->clone() );
482                                                }
483                                                delete ctx;
484                                        } else {
485                                                FixFunction fixer;
486                                                *assertion = (*assertion )->acceptMutator( fixer );
487                                                if ( fixer.get_isVoid() ) {
488                                                        throw SemanticError( "invalid type void in assertion of function ", func );
489                                                }
490                                                (*type )->get_assertions().push_back( *assertion );
491                                        } // if
492                                } // for
493                                toBeDone.clear();
494                                toBeDone.splice( toBeDone.end(), nextRound );
495                        } // while
496                } // for
497        }
498
499        void Pass3::visit( ObjectDecl *object ) {
500                forallFixer( object->get_type() );
501                if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
502                        forallFixer( pointer->get_base() );
503                } // if
504                Parent::visit( object );
505                object->fixUniqueId();
506        }
507
508        void Pass3::visit( FunctionDecl *func ) {
509                forallFixer( func->get_type() );
510                Parent::visit( func );
511                func->fixUniqueId();
512        }
513
514        static const std::list< std::string > noLabels;
515
516        void AutogenerateRoutines::autogenerateRoutines( std::list< Declaration * > &translationUnit ) {
517                AutogenerateRoutines visitor;
518                acceptAndAdd( translationUnit, visitor, false );
519        }
520
521        template< typename OutputIterator >
522        void makeScalarAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, OutputIterator out ) {
523                ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member );
524                // unnamed bit fields are not copied as they cannot be accessed
525                if ( obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL ) return;
526
527                UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) );
528
529                UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
530                derefExpr->get_args().push_back( new VariableExpr( dstParam ) );
531
532                // do something special for unnamed members
533                Expression *dstselect = new AddressExpr( new MemberExpr( member, derefExpr ) );
534                assignExpr->get_args().push_back( dstselect );
535
536                Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) );
537                assignExpr->get_args().push_back( srcselect );
538
539                *out++ = new ExprStmt( noLabels, assignExpr );
540        }
541
542        template< typename OutputIterator >
543        void makeArrayAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, DeclarationWithType *member, ArrayType *array, OutputIterator out ) {
544                static UniqueName indexName( "_index" );
545
546                // for a flexible array member nothing is done -- user must define own assignment
547                if ( ! array->get_dimension() ) return;
548
549                ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 );
550                *out++ = new DeclStmt( noLabels, index );
551
552                UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) );
553                init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
554                init->get_args().push_back( new NameExpr( "0" ) );
555                Statement *initStmt = new ExprStmt( noLabels, init );
556                std::list<Statement *> initList;
557                initList.push_back( initStmt );
558
559                UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) );
560                cond->get_args().push_back( new VariableExpr( index ) );
561                cond->get_args().push_back( array->get_dimension()->clone() );
562
563                UntypedExpr *inc = new UntypedExpr( new NameExpr( "++?" ) );
564                inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
565
566                UntypedExpr *assignExpr = new UntypedExpr( new NameExpr( "?=?" ) );
567
568                UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
569                derefExpr->get_args().push_back( new VariableExpr( dstParam ) );
570
571                Expression *dstselect = new MemberExpr( member, derefExpr );
572                UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?+?" ) );
573                dstIndex->get_args().push_back( dstselect );
574                dstIndex->get_args().push_back( new VariableExpr( index ) );
575                assignExpr->get_args().push_back( dstIndex );
576
577                Expression *srcselect = new MemberExpr( member, new VariableExpr( srcParam ) );
578                UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
579                srcIndex->get_args().push_back( srcselect );
580                srcIndex->get_args().push_back( new VariableExpr( index ) );
581                assignExpr->get_args().push_back( srcIndex );
582
583                *out++ = new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, assignExpr ) );
584        }
585
586        //E ?=?(E volatile*, int),
587        //  ?=?(E _Atomic volatile*, int);
588        void makeEnumAssignment( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
589                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
590
591                ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 );
592                assignType->get_returnVals().push_back( returnVal );
593
594                // need two assignment operators with different types
595                FunctionType * assignType2 = assignType->clone();
596
597                // E ?=?(E volatile *, E)
598                Type *etype = refType->clone();
599                // etype->get_qualifiers() += Type::Qualifiers(false, true, false, false, false, false);
600
601                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), etype ), 0 );
602                assignType->get_parameters().push_back( dstParam );
603
604                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, etype->clone(), 0 );
605                assignType->get_parameters().push_back( srcParam );
606
607                // E ?=?(E volatile *, int)
608                assignType2->get_parameters().push_back( dstParam->clone() );
609                BasicType * paramType = new BasicType(Type::Qualifiers(), BasicType::SignedInt);
610                ObjectDecl *srcParam2 = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, paramType, 0 );
611                assignType2->get_parameters().push_back( srcParam2 );
612
613                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
614                // because each unit generates copies of the default routines for each aggregate.
615
616                // since there is no definition, these should not be inline
617                // make these intrinsic so that the code generator does not make use of them
618                FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType, 0, false, false );
619                assignDecl->fixUniqueId();
620                FunctionDecl *assignDecl2 = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType2, 0, false, false );
621                assignDecl2->fixUniqueId();
622
623                // these should be built in the same way that the prelude
624                // functions are, so build a list containing the prototypes
625                // and allow MakeLibCfa to autogenerate the bodies.
626                std::list< Declaration * > assigns;
627                assigns.push_back( assignDecl );
628                assigns.push_back( assignDecl2 );
629
630                LibCfa::makeLibCfa( assigns );
631
632                // need to remove the prototypes, since this may be nested in a routine
633                for (int start = 0, end = assigns.size()/2; start < end; start++) {
634                        delete assigns.front();
635                        assigns.pop_front();
636                } // for
637
638                declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() );
639        }
640
641        /// Clones a reference type, replacing any parameters it may have with a clone of the provided list
642        template< typename GenericInstType >
643        GenericInstType *cloneWithParams( GenericInstType *refType, const std::list< Expression* >& params ) {
644                GenericInstType *clone = refType->clone();
645                clone->get_parameters().clear();
646                cloneAll( params, clone->get_parameters() );
647                return clone;
648        }
649
650        Declaration *makeStructAssignment( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting ) {
651                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
652
653                // Make function polymorphic in same parameters as generic struct, if applicable
654                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
655                std::list< Expression* > structParams;  // List of matching parameters to put on types
656                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
657                        TypeDecl *typeParam = (*param)->clone();
658                        assignType->get_forall().push_back( typeParam );
659                        structParams.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ) ) );
660                }
661
662                ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
663                assignType->get_returnVals().push_back( returnVal );
664
665                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, structParams ) ), 0 );
666                assignType->get_parameters().push_back( dstParam );
667
668                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
669                assignType->get_parameters().push_back( srcParam );
670
671                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
672                // because each unit generates copies of the default routines for each aggregate.
673                FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
674                assignDecl->fixUniqueId();
675
676                for ( std::list< Declaration * >::const_iterator member = aggregateDecl->get_members().begin(); member != aggregateDecl->get_members().end(); ++member ) {
677                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member ) ) {
678                                // query the type qualifiers of this field and skip assigning it if it is marked const.
679                                // If it is an array type, we need to strip off the array layers to find its qualifiers.
680                                Type * type = dwt->get_type();
681                                while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
682                                        type = at->get_base();
683                                }
684
685                                if ( type->get_qualifiers().isConst ) {
686                                        // don't assign const members
687                                        continue;
688                                }
689
690                                if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
691                                        makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );
692                                } else {
693                                        makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );
694                                } // if
695                        } // if
696                } // for
697                assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
698
699                return assignDecl;
700        }
701
702        Declaration *makeUnionAssignment( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting ) {
703                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
704
705                // Make function polymorphic in same parameters as generic union, if applicable
706                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
707                std::list< Expression* > unionParams;  // List of matching parameters to put on types
708                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
709                        TypeDecl *typeParam = (*param)->clone();
710                        assignType->get_forall().push_back( typeParam );
711                        unionParams.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ) ) );
712                }
713
714                ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
715                assignType->get_returnVals().push_back( returnVal );
716
717                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, unionParams ) ), 0 );
718                assignType->get_parameters().push_back( dstParam );
719
720                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
721                assignType->get_parameters().push_back( srcParam );
722
723                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
724                // because each unit generates copies of the default routines for each aggregate.
725                FunctionDecl *assignDecl = new FunctionDecl( "?=?",  functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false );
726                assignDecl->fixUniqueId();
727
728                UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );
729                copy->get_args().push_back( new VariableExpr( dstParam ) );
730                copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) );
731                copy->get_args().push_back( new SizeofExpr( cloneWithParams( refType, unionParams ) ) );
732
733                assignDecl->get_statements()->get_kids().push_back( new ExprStmt( noLabels, copy ) );
734                assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
735
736                return assignDecl;
737        }
738
739        void AutogenerateRoutines::visit( EnumDecl *enumDecl ) {
740                if ( ! enumDecl->get_members().empty() ) {
741                        EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
742                        // enumInst->set_baseEnum( enumDecl );
743                        // declsToAdd.push_back(
744                        makeEnumAssignment( enumDecl, enumInst, functionNesting, declsToAdd );
745                }
746        }
747
748        void AutogenerateRoutines::visit( StructDecl *structDecl ) {
749                if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
750                        StructInstType structInst( Type::Qualifiers(), structDecl->get_name() );
751                        structInst.set_baseStruct( structDecl );
752                        declsToAdd.push_back( makeStructAssignment( structDecl, &structInst, functionNesting ) );
753                        structsDone.insert( structDecl->get_name() );
754                } // if
755        }
756
757        void AutogenerateRoutines::visit( UnionDecl *unionDecl ) {
758                if ( ! unionDecl->get_members().empty() ) {
759                        UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
760                        unionInst.set_baseUnion( unionDecl );
761                        declsToAdd.push_back( makeUnionAssignment( unionDecl, &unionInst, functionNesting ) );
762                } // if
763        }
764
765        void AutogenerateRoutines::visit( TypeDecl *typeDecl ) {
766                CompoundStmt *stmts = 0;
767                TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
768                typeInst->set_baseType( typeDecl );
769                ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 );
770                ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );
771                if ( typeDecl->get_base() ) {
772                        stmts = new CompoundStmt( std::list< Label >() );
773                        UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
774                        assign->get_args().push_back( new CastExpr( new VariableExpr( dst ), new PointerType( Type::Qualifiers(), typeDecl->get_base()->clone() ) ) );
775                        assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) );
776                        stmts->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) );
777                } // if
778                FunctionType *type = new FunctionType( Type::Qualifiers(), false );
779                type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
780                type->get_parameters().push_back( dst );
781                type->get_parameters().push_back( src );
782                FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, false, false );
783                declsToAdd.push_back( func );
784        }
785
786        void addDecls( std::list< Declaration * > &declsToAdd, std::list< Statement * > &statements, std::list< Statement * >::iterator i ) {
787                for ( std::list< Declaration * >::iterator decl = declsToAdd.begin(); decl != declsToAdd.end(); ++decl ) {
788                        statements.insert( i, new DeclStmt( noLabels, *decl ) );
789                } // for
790                declsToAdd.clear();
791        }
792
793        void AutogenerateRoutines::visit( FunctionType *) {
794                // ensure that we don't add assignment ops for types defined as part of the function
795        }
796
797        void AutogenerateRoutines::visit( PointerType *) {
798                // ensure that we don't add assignment ops for types defined as part of the pointer
799        }
800
801        void AutogenerateRoutines::visit( ContextDecl *) {
802                // ensure that we don't add assignment ops for types defined as part of the context
803        }
804
805        template< typename StmtClass >
806        inline void AutogenerateRoutines::visitStatement( StmtClass *stmt ) {
807                std::set< std::string > oldStructs = structsDone;
808                addVisit( stmt, *this );
809                structsDone = oldStructs;
810        }
811
812        void AutogenerateRoutines::visit( FunctionDecl *functionDecl ) {
813                maybeAccept( functionDecl->get_functionType(), *this );
814                acceptAll( functionDecl->get_oldDecls(), *this );
815                functionNesting += 1;
816                maybeAccept( functionDecl->get_statements(), *this );
817                functionNesting -= 1;
818        }
819
820        void AutogenerateRoutines::visit( CompoundStmt *compoundStmt ) {
821                visitStatement( compoundStmt );
822        }
823
824        void AutogenerateRoutines::visit( IfStmt *ifStmt ) {
825                visitStatement( ifStmt );
826        }
827
828        void AutogenerateRoutines::visit( WhileStmt *whileStmt ) {
829                visitStatement( whileStmt );
830        }
831
832        void AutogenerateRoutines::visit( ForStmt *forStmt ) {
833                visitStatement( forStmt );
834        }
835
836        void AutogenerateRoutines::visit( SwitchStmt *switchStmt ) {
837                visitStatement( switchStmt );
838        }
839
840        void AutogenerateRoutines::visit( ChooseStmt *switchStmt ) {
841                visitStatement( switchStmt );
842        }
843
844        void AutogenerateRoutines::visit( CaseStmt *caseStmt ) {
845                visitStatement( caseStmt );
846        }
847
848        void AutogenerateRoutines::visit( CatchStmt *cathStmt ) {
849                visitStatement( cathStmt );
850        }
851
852        bool isTypedef( Declaration *decl ) {
853                return dynamic_cast< TypedefDecl * >( decl );
854        }
855
856        void EliminateTypedef::eliminateTypedef( std::list< Declaration * > &translationUnit ) {
857                EliminateTypedef eliminator;
858                mutateAll( translationUnit, eliminator );
859                filter( translationUnit, isTypedef, true );
860        }
861
862        Type *EliminateTypedef::mutate( TypeInstType * typeInst ) {
863                // instances of typedef types will come here. If it is an instance
864                // of a typdef type, link the instance to its actual type.
865                TypedefMap::const_iterator def = typedefNames.find( typeInst->get_name() );
866                if ( def != typedefNames.end() ) {
867                        Type *ret = def->second.first->get_base()->clone();
868                        ret->get_qualifiers() += typeInst->get_qualifiers();
869                        // place instance parameters on the typedef'd type
870                        if ( ! typeInst->get_parameters().empty() ) {
871                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
872                                if ( ! rtt ) {
873                                        throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name());
874                                }
875                                rtt->get_parameters().clear();
876                                cloneAll(typeInst->get_parameters(), rtt->get_parameters());
877                        } // if
878                        delete typeInst;
879                        return ret;
880                } // if
881                return typeInst;
882        }
883
884        Declaration *EliminateTypedef::mutate( TypedefDecl * tyDecl ) {
885                Declaration *ret = Mutator::mutate( tyDecl );
886                if ( typedefNames.count( tyDecl->get_name() ) == 1 && typedefNames[ tyDecl->get_name() ].second == scopeLevel ) {
887                        // typedef to the same name from the same scope
888                        // must be from the same type
889
890                        Type * t1 = tyDecl->get_base();
891                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
892                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
893                                throw SemanticError( "cannot redefine typedef: " + tyDecl->get_name() );
894                        }
895                } else {
896                        typedefNames[ tyDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
897                } // if
898
899                // When a typedef is a forward declaration:
900                //    typedef struct screen SCREEN;
901                // the declaration portion must be retained:
902                //    struct screen;
903                // because the expansion of the typedef is:
904                //    void rtn( SCREEN *p ) => void rtn( struct screen *p )
905                // hence the type-name "screen" must be defined.
906                // Note, qualifiers on the typedef are superfluous for the forward declaration.
907                if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) {
908                        return new StructDecl( aggDecl->get_name() );
909                } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) {
910                        return new UnionDecl( aggDecl->get_name() );
911                } else {
912                        return ret;
913                } // if
914        }
915
916        TypeDecl *EliminateTypedef::mutate( TypeDecl * typeDecl ) {
917                TypedefMap::iterator i = typedefNames.find( typeDecl->get_name() );
918                if ( i != typedefNames.end() ) {
919                        typedefNames.erase( i ) ;
920                } // if
921                return typeDecl;
922        }
923
924        DeclarationWithType *EliminateTypedef::mutate( FunctionDecl * funcDecl ) {
925                TypedefMap oldNames = typedefNames;
926                DeclarationWithType *ret = Mutator::mutate( funcDecl );
927                typedefNames = oldNames;
928                return ret;
929        }
930
931        DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
932                TypedefMap oldNames = typedefNames;
933                DeclarationWithType *ret = Mutator::mutate( objDecl );
934                typedefNames = oldNames;
935                // is the type a function?
936                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
937                        // replace the current object declaration with a function declaration
938                        return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() );
939                } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {
940                        throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );
941                } // if
942                return ret;
943        }
944
945        Expression *EliminateTypedef::mutate( CastExpr * castExpr ) {
946                TypedefMap oldNames = typedefNames;
947                Expression *ret = Mutator::mutate( castExpr );
948                typedefNames = oldNames;
949                return ret;
950        }
951
952        CompoundStmt *EliminateTypedef::mutate( CompoundStmt * compoundStmt ) {
953                TypedefMap oldNames = typedefNames;
954                scopeLevel += 1;
955                CompoundStmt *ret = Mutator::mutate( compoundStmt );
956                scopeLevel -= 1;
957                std::list< Statement * >::iterator i = compoundStmt->get_kids().begin();
958                while ( i != compoundStmt->get_kids().end() ) {
959                        std::list< Statement * >::iterator next = i+1;
960                        if ( DeclStmt *declStmt = dynamic_cast< DeclStmt * >( *i ) ) {
961                                if ( dynamic_cast< TypedefDecl * >( declStmt->get_decl() ) ) {
962                                        delete *i;
963                                        compoundStmt->get_kids().erase( i );
964                                } // if
965                        } // if
966                        i = next;
967                } // while
968                typedefNames = oldNames;
969                return ret;
970        }
971
972        // there may be typedefs nested within aggregates
973        // in order for everything to work properly, these
974        // should be removed as well
975        template<typename AggDecl>
976        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
977                std::list<Declaration *>::iterator it = aggDecl->get_members().begin();
978                for ( ; it != aggDecl->get_members().end(); ) {
979                        std::list< Declaration * >::iterator next = it+1;
980                        if ( dynamic_cast< TypedefDecl * >( *it ) ) {
981                                delete *it;
982                                aggDecl->get_members().erase( it );
983                        } // if
984                        it = next;
985                }
986                return aggDecl;
987        }
988
989        Declaration *EliminateTypedef::mutate( StructDecl * structDecl ) {
990                Mutator::mutate( structDecl );
991                return handleAggregate( structDecl );
992        }
993
994        Declaration *EliminateTypedef::mutate( UnionDecl * unionDecl ) {
995                Mutator::mutate( unionDecl );
996                return handleAggregate( unionDecl );
997        }
998
999        Declaration *EliminateTypedef::mutate( EnumDecl * enumDecl ) {
1000                Mutator::mutate( enumDecl );
1001                return handleAggregate( enumDecl );
1002        }
1003
1004                Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
1005                Mutator::mutate( contextDecl );
1006                return handleAggregate( contextDecl );
1007        }
1008
1009        void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {
1010                VerifyCtorDtor verifier;
1011                acceptAll( translationUnit, verifier );
1012        }
1013
1014        void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {
1015                FunctionType * funcType = funcDecl->get_functionType();
1016                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
1017                std::list< DeclarationWithType * > &params = funcType->get_parameters();
1018
1019                if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {
1020                        if ( params.size() == 0 ) {
1021                                throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );
1022                        }
1023                        if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {
1024                                throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );
1025                        }
1026                        if ( returnVals.size() != 0 ) {
1027                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
1028                        }
1029                }
1030
1031                Visitor::visit( funcDecl );
1032                // original idea: modify signature of ctor/dtors and insert appropriate return statements
1033                // to cause desired behaviour
1034                // new idea: add comma exprs to every ctor call to produce first parameter.
1035                // this requires some memoization of the first parameter, because it can be a
1036                // complicated expression with side effects (see: malloc). idea: add temporary variable
1037                // that is assigned address of constructed object in ctor argument position and
1038                // return the temporary. It should also be done after all implicit ctors are
1039                // added, so not in this pass!
1040        }
1041} // namespace SymTab
1042
1043// Local Variables: //
1044// tab-width: 4 //
1045// mode: c++ //
1046// compile-command: "make install" //
1047// End: //
Note: See TracBrowser for help on using the repository browser.