source: src/InitTweak/InitTweak.h @ 08ac489

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

add gcc attributes to ObjectDecl?, hoist destructed static variables, add breaks to end of generated switch

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[2b46a13]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// RemoveInit.h --
8//
9// Author           : Rob Schluntz
10// Created On       : Fri May 13 11:26:36 2016
11// Last Modified By : Rob Schluntz
12// Last Modified On : Fri May 13 11:35:36 2016
13// Update Count     : 3
14//
15
16#ifndef INIT_TWEAK_H
17#define INIT_TWEAK_H
18
19#include <string>
20#include <list>
21
22#include "SynTree/SynTree.h"
23#include "SynTree/Declaration.h"
24#include "SynTree/Mutator.h"
25
26// helper functions for initialization
27namespace InitTweak {
[b81adcc4]28        /// transform Initializer into an argument list that can be passed to a call expression
29        std::list< Expression * > makeInitList( Initializer * init );
[2b46a13]30
[b81adcc4]31        /// True if the resolver should try to construct objDecl
32        bool tryConstruct( ObjectDecl * objDecl );
[2b46a13]33
[b81adcc4]34        /// True if the Initializer contains designations
35        bool isDesignated( Initializer * init );
[2b46a13]36
[aedfd91]37  /// Non-Null if expr is a call expression whose target function is intrinsic
38  ApplicationExpr * isIntrinsicCallExpr( Expression * expr );
39
[b81adcc4]40        /// True if stmt is a call statement where the function called is intrinsic and takes one parameter.
41        /// Intended to be used for default ctor/dtor calls, but might have use elsewhere.
42        /// Currently has assertions that make it less than fully general.
[f9cebb5]43        bool isIntrinsicSingleArgCallStmt( Statement * expr );
[70f89d00]44
[4d2434a]45        /// get all Ctor/Dtor call expressions from a Statement
46        void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches );
47
[b81adcc4]48        /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call
49        Expression * getCtorDtorCall( Statement * stmt );
[f1b1e4c]50
[b81adcc4]51        /// returns the name of the function being called
52        std::string getFunctionName( Expression * expr );
[f1b1e4c]53
[b81adcc4]54        /// returns the argument to a call expression in position N indexed from 0
55        Expression *& getCallArg( Expression * callExpr, unsigned int pos );
[10a7775]56
[b81adcc4]57        /// returns the base type of a PointerType or ArrayType, else returns NULL
58        Type * getPointerBase( Type * );
[64071c2]59
[b81adcc4]60        /// returns the argument if it is a PointerType or ArrayType, else returns NULL
61        Type * isPointerType( Type * );
[5f98ce5]62
[b81adcc4]63        /// returns true if expr is trivially a compile-time constant
64        bool isConstExpr( Expression * expr );
65        bool isConstExpr( Initializer * init );
[39f84a4]66
67        class InitExpander {
68        public:
69                // expand by stepping through init to get each list of arguments
70                InitExpander( Initializer * init );
71
72                // always expand to expr
73                InitExpander( Expression * expr );
74
75                // iterator-like interface
76                std::list< Expression * > operator*();
77                InitExpander & operator++();
78
79                // builds statement which has the same semantics as a C-style list initializer
80                // (for array initializers) using callExpr as the base expression to perform initialization
81                Statement * buildListInit( UntypedExpr * callExpr );
82                void addArrayIndex( Expression * index, Expression * dimension );
[4d2434a]83                void clearArrayIndices();
[39f84a4]84
85                class ExpanderImpl;
86        private:
87                std::shared_ptr< ExpanderImpl > expander;
88                std::list< Expression * > cur;
89
90                // invariant: list of size 2N (elements come in pairs [index, dimension])
91                typedef std::list< Expression * > IndexList;
92                IndexList indices;
93        };
[2b46a13]94} // namespace
95
96#endif // INITTWEAK_GENINIT_H
97
98// Local Variables: //
99// tab-width: 4 //
100// mode: c++ //
101// compile-command: "make install" //
102// End: //
Note: See TracBrowser for help on using the repository browser.