source: src/SymTab/FixFunction.cc @ 11a2d9b

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

Cleanup pass through several files

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[0dd3a2f]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//
[40e636a]7// FixFunction.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 16:19:49 2015
11// Last Modified By : Peter A. Buhr
[a7c90d4]12// Last Modified On : Mon Mar  6 23:36:59 2017
13// Update Count     : 6
[0dd3a2f]14//
15
[51b7345]16#include "FixFunction.h"
[30f9072]17
18#include <list>                   // for list
19
20#include "Common/utility.h"       // for maybeClone
21#include "SynTree/Declaration.h"  // for FunctionDecl, ObjectDecl, Declarati...
[c3acf0aa]22#include "SynTree/Expression.h"   // for Expression
[30f9072]23#include "SynTree/Type.h"         // for ArrayType, PointerType, Type, Basic...
[51b7345]24
25namespace SymTab {
[a7c90d4]26        FixFunction::FixFunction() : isVoid( false ) {}
[51b7345]27
[0dd3a2f]28        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
[8b11840]29                // can't delete function type because it may contain assertions, so transfer ownership to new object
[0b150ec]30                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type() ), 0, functionDecl->get_attributes() );
[0a86a30]31                functionDecl->get_attributes().clear();
[8b11840]32                functionDecl->type = nullptr;
[0dd3a2f]33                delete functionDecl;
34                return pointer;
35        }
[51b7345]36
[0dd3a2f]37        Type * FixFunction::mutate(VoidType *voidType) {
38                isVoid = true;
39                return voidType;
40        }
[51b7345]41
[0dd3a2f]42        Type * FixFunction::mutate(BasicType *basicType) {
43                return basicType;
44        }
[51b7345]45
[0dd3a2f]46        Type * FixFunction::mutate(PointerType *pointerType) {
47                return pointerType;
48        }
[51b7345]49
[0dd3a2f]50        Type * FixFunction::mutate(ArrayType *arrayType) {
[40e636a]51                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
52                PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() );
[0dd3a2f]53                delete arrayType;
54                return pointerType;
55        }
[51b7345]56
[0dd3a2f]57        Type * FixFunction::mutate(StructInstType *aggregateUseType) {
58                return aggregateUseType;
59        }
[51b7345]60
[0dd3a2f]61        Type * FixFunction::mutate(UnionInstType *aggregateUseType) {
62                return aggregateUseType;
63        }
[51b7345]64
[0dd3a2f]65        Type * FixFunction::mutate(EnumInstType *aggregateUseType) {
66                return aggregateUseType;
67        }
[51b7345]68
[4040425]69        Type * FixFunction::mutate(TraitInstType *aggregateUseType) {
[0dd3a2f]70                return aggregateUseType;
71        }
[51b7345]72
[0dd3a2f]73        Type * FixFunction::mutate(TypeInstType *aggregateUseType) {
74                return aggregateUseType;
75        }
[51b7345]76
[0dd3a2f]77        Type * FixFunction::mutate(TupleType *tupleType) {
78                return tupleType;
79        }
[44b7088]80
81        Type * FixFunction::mutate(VarArgsType *varArgsType) {
82                return varArgsType;
83        }
[89e6ffc]84
85        Type * FixFunction::mutate(ZeroType *zeroType) {
86                return zeroType;
87        }
88
89        Type * FixFunction::mutate(OneType *oneType) {
90                return oneType;
91        }
[51b7345]92} // namespace SymTab
[0dd3a2f]93
94// Local Variables: //
95// tab-width: 4 //
96// mode: c++ //
97// compile-command: "make install" //
98// End: //
Note: See TracBrowser for help on using the repository browser.