source: src/InitTweak/InitTweak.h @ f51ef6f

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 f51ef6f was 207c7e1d, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

disable autogeneration of ctor/dtor/assign when a member's corresponding operation is missing

  • Property mode set to 100644
File size: 4.2 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 {
[79970ed]28        bool isConstructor( const std::string & );
29        bool isDestructor( const std::string & );
[ee1635c8]30        bool isAssignment( const std::string & );
[79970ed]31        bool isCtorDtor( const std::string & );
[ee1635c8]32        bool isCtorDtorAssign( const std::string & );
[79970ed]33
[207c7e1d]34        FunctionDecl * isAssignment( Declaration * decl );
35        FunctionDecl * isDestructor( Declaration * decl );
36        FunctionDecl * isDefaultConstructor( Declaration * decl );
[4d4882a]37        FunctionDecl * isCopyConstructor( Declaration * decl );
[ee1635c8]38        FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname );
[4d4882a]39
[b81adcc4]40        /// transform Initializer into an argument list that can be passed to a call expression
41        std::list< Expression * > makeInitList( Initializer * init );
[2b46a13]42
[b81adcc4]43        /// True if the resolver should try to construct objDecl
44        bool tryConstruct( ObjectDecl * objDecl );
[2b46a13]45
[b81adcc4]46        /// True if the Initializer contains designations
47        bool isDesignated( Initializer * init );
[2b46a13]48
[dcd73d1]49        /// True if the ObjectDecl's Initializer nesting level is not deeper than the depth of its
50        /// type, where the depth of its type is the number of nested ArrayTypes + 1
51        bool checkInitDepth( ObjectDecl * objDecl );
52
[aedfd91]53  /// Non-Null if expr is a call expression whose target function is intrinsic
54  ApplicationExpr * isIntrinsicCallExpr( Expression * expr );
55
[b81adcc4]56        /// True if stmt is a call statement where the function called is intrinsic and takes one parameter.
57        /// Intended to be used for default ctor/dtor calls, but might have use elsewhere.
58        /// Currently has assertions that make it less than fully general.
[a465caf]59        bool isIntrinsicSingleArgCallStmt( Statement * stmt );
60
61        /// True if stmt is a call statement where the function called is intrinsic.
62        bool isIntrinsicCallStmt( Statement * stmt );
[70f89d00]63
[4d2434a]64        /// get all Ctor/Dtor call expressions from a Statement
65        void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches );
66
[b81adcc4]67        /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call
68        Expression * getCtorDtorCall( Statement * stmt );
[f1b1e4c]69
[b81adcc4]70        /// returns the name of the function being called
71        std::string getFunctionName( Expression * expr );
[f1b1e4c]72
[b81adcc4]73        /// returns the argument to a call expression in position N indexed from 0
74        Expression *& getCallArg( Expression * callExpr, unsigned int pos );
[10a7775]75
[b81adcc4]76        /// returns the base type of a PointerType or ArrayType, else returns NULL
77        Type * getPointerBase( Type * );
[64071c2]78
[b81adcc4]79        /// returns the argument if it is a PointerType or ArrayType, else returns NULL
80        Type * isPointerType( Type * );
[5f98ce5]81
[b81adcc4]82        /// returns true if expr is trivially a compile-time constant
83        bool isConstExpr( Expression * expr );
84        bool isConstExpr( Initializer * init );
[39f84a4]85
86        class InitExpander {
87        public:
88                // expand by stepping through init to get each list of arguments
89                InitExpander( Initializer * init );
90
91                // always expand to expr
92                InitExpander( Expression * expr );
93
94                // iterator-like interface
95                std::list< Expression * > operator*();
96                InitExpander & operator++();
97
98                // builds statement which has the same semantics as a C-style list initializer
99                // (for array initializers) using callExpr as the base expression to perform initialization
100                Statement * buildListInit( UntypedExpr * callExpr );
101                void addArrayIndex( Expression * index, Expression * dimension );
[4d2434a]102                void clearArrayIndices();
[39f84a4]103
104                class ExpanderImpl;
[62e5546]105                typedef std::list< Expression * > IndexList;
[39f84a4]106        private:
107                std::shared_ptr< ExpanderImpl > expander;
108                std::list< Expression * > cur;
109
110                // invariant: list of size 2N (elements come in pairs [index, dimension])
111                IndexList indices;
112        };
[2b46a13]113} // namespace
114
115#endif // INITTWEAK_GENINIT_H
116
117// Local Variables: //
118// tab-width: 4 //
119// mode: c++ //
120// compile-command: "make install" //
121// End: //
Note: See TracBrowser for help on using the repository browser.