source: src/InitTweak/InitTweak.h@ 85517ddb

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new stuck-waitfor-destruct with_gc
Last change on this file since 85517ddb was 4d4882a, checked in by Rob Schluntz <rschlunt@…>, 10 years ago

implicitly insert missing copy constructors when appropriate, update test output

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