source: src/SymTab/FixFunction.cc @ 0a86a30

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 0a86a30 was 0a86a30, checked in by Rob Schluntz <rschlunt@…>, 5 years ago

fix dropping attributes in function pointer decay and function typedefs

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