source: src/SymTab/Validate.cc@ 4789f44

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 4789f44 was ae8b942, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

Merge branch 'master' of plg2:software/cfa/cfa-cc

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