Changes in src/InitTweak/InitTweak.cc [13d326ec:720f2fe2]
- File:
-
- 1 edited
-
src/InitTweak/InitTweak.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
r13d326ec r720f2fe2 27 27 #include "AST/Stmt.hpp" 28 28 #include "AST/Type.hpp" 29 #include "CodeGen/OperatorTable.h" // for isConstructor, isDestructor, isCto...30 29 #include "Common/PassVisitor.h" 31 30 #include "Common/SemanticError.h" // for SemanticError … … 771 770 std::list< Expression * > callExprs; 772 771 collectCtorDtorCalls( stmt, callExprs ); 772 // if ( callExprs.empty() ) return false; // xxx - do I still need this check? 773 773 return std::all_of( callExprs.begin(), callExprs.end(), pred); 774 774 } … … 901 901 } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) { 902 902 return varExpr->get_var()->get_name(); 903 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {903 } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) { 904 904 return funcName( castExpr->get_arg() ); 905 905 } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) { … … 923 923 } else if ( const ast::VariableExpr * varExpr = dynamic_cast< const ast::VariableExpr * >( func ) ) { 924 924 return varExpr->var->name; 925 } else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) {925 } else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) { 926 926 return funcName( castExpr->arg ); 927 927 } else if ( const ast::MemberExpr * memberExpr = dynamic_cast< const ast::MemberExpr * >( func ) ) { … … 991 991 992 992 Type * isPointerType( Type * type ) { 993 return getPointerBase( type ) ? type : nullptr; 993 if ( getPointerBase( type ) ) return type; 994 else return nullptr; 994 995 } 995 996 … … 1013 1014 src = new AddressExpr( src ); 1014 1015 } 1016 // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) ); 1015 1017 } 1016 1018 return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } ); … … 1165 1167 } 1166 1168 1169 bool isConstructor( const std::string & str ) { return str == "?{}"; } 1170 bool isDestructor( const std::string & str ) { return str == "^?{}"; } 1171 bool isAssignment( const std::string & str ) { return str == "?=?"; } 1172 bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); } 1173 bool isCtorDtorAssign( const std::string & str ) { return isCtorDtor( str ) || isAssignment( str ); } 1174 1167 1175 const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname ) { 1168 1176 const FunctionDecl * function = dynamic_cast< const FunctionDecl * >( decl ); … … 1184 1192 1185 1193 bool isAssignment( const ast::FunctionDecl * decl ) { 1186 return CodeGen::isAssignment( decl->name ) && isCopyFunction( decl );1194 return isAssignment( decl->name ) && isCopyFunction( decl ); 1187 1195 } 1188 1196 1189 1197 bool isDestructor( const ast::FunctionDecl * decl ) { 1190 return CodeGen::isDestructor( decl->name );1198 return isDestructor( decl->name ); 1191 1199 } 1192 1200 1193 1201 bool isDefaultConstructor( const ast::FunctionDecl * decl ) { 1194 return CodeGen::isConstructor( decl->name ) && 1 == decl->params.size();1202 return isConstructor( decl->name ) && 1 == decl->params.size(); 1195 1203 } 1196 1204 1197 1205 bool isCopyConstructor( const ast::FunctionDecl * decl ) { 1198 return CodeGen::isConstructor( decl->name ) && 2 == decl->params.size();1206 return isConstructor( decl->name ) && 2 == decl->params.size(); 1199 1207 } 1200 1208 … … 1214 1222 } 1215 1223 const FunctionDecl * isDestructor( const Declaration * decl ) { 1216 if ( CodeGen::isDestructor( decl->name ) ) {1224 if ( isDestructor( decl->name ) ) { 1217 1225 return dynamic_cast< const FunctionDecl * >( decl ); 1218 1226 } … … 1220 1228 } 1221 1229 const FunctionDecl * isDefaultConstructor( const Declaration * decl ) { 1222 if ( CodeGen::isConstructor( decl->name ) ) {1230 if ( isConstructor( decl->name ) ) { 1223 1231 if ( const FunctionDecl * func = dynamic_cast< const FunctionDecl * >( decl ) ) { 1224 1232 if ( func->type->parameters.size() == 1 ) {
Note:
See TracChangeset
for help on using the changeset viewer.