- Timestamp:
- Feb 23, 2024, 11:41:10 PM (11 months ago)
- Branches:
- master
- Children:
- 0a9b5c1, 1e93617
- Parents:
- 3d5a8cb (diff), 1761046 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Peter A. Buhr <pabuhr@…> (02/23/24 18:54:24)
- git-committer:
- Peter A. Buhr <pabuhr@…> (02/23/24 23:41:10)
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cpp
r3d5a8cb r46aa60e 1109 1109 ); 1110 1110 1111 for ( auto group : group_iterate( realType->assertions, 1112 adapterType->assertions, adaptee->assertions ) ) { 1113 auto assertArg = std::get<0>( group ); 1114 auto assertParam = std::get<1>( group ); 1115 auto assertReal = std::get<2>( group ); 1111 for ( auto const & [assertArg, assertParam, assertReal] : group_iterate( 1112 realType->assertions, adapterType->assertions, adaptee->assertions ) ) { 1116 1113 adapteeApp->args.push_back( makeAdapterArg( 1117 1114 assertParam->var, assertArg->var->get_type(), … … 1970 1967 bool hasDynamicLayout = false; 1971 1968 1972 for ( auto pair : group_iterate( baseParams, typeParams ) ) { 1973 auto baseParam = std::get<0>( pair ); 1974 auto typeParam = std::get<1>( pair ); 1969 for ( auto const & [baseParam, typeParam] : group_iterate( 1970 baseParams, typeParams ) ) { 1975 1971 if ( !baseParam->isComplete() ) continue; 1976 1972 ast::TypeExpr const * typeExpr = typeParam.as<ast::TypeExpr>(); -
src/InitTweak/FixInit.cpp
r3d5a8cb r46aa60e 1134 1134 ast::Expr * thisExpr = new ast::CastExpr(funcDecl->location, new ast::VariableExpr(funcDecl->location, thisParam ), thisParam->get_type()->stripReferences()); 1135 1135 ast::Expr * memberDest = new ast::MemberExpr(funcDecl->location, field, thisExpr ); 1136 ast::ptr<ast::Stmt>callStmt = SymTab::genImplicitCall( srcParam, memberDest, loc, function->name, field, static_cast<SymTab::LoopDirection>(isCtor) );1136 const ast::Stmt * callStmt = SymTab::genImplicitCall( srcParam, memberDest, loc, function->name, field, static_cast<SymTab::LoopDirection>(isCtor) ); 1137 1137 1138 1138 if ( callStmt ) { -
src/InitTweak/GenInit.cc
r3d5a8cb r46aa60e 239 239 if ( varExpr->var == retVal ) return stmt; 240 240 } 241 ast::ptr<ast::Stmt>ctorStmt = genCtorDtor(241 const ast::Stmt * ctorStmt = genCtorDtor( 242 242 retVal->location, "?{}", retVal, stmt->expr ); 243 243 assertf( ctorStmt, … … 327 327 void ManagedTypes::endScope() { managedTypes.endScope(); } 328 328 329 ast::ptr<ast::Stmt> genCtorDtor (const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg) {329 const ast::Stmt * genCtorDtor( const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg ) { 330 330 assertf(objDecl, "genCtorDtor passed null objDecl"); 331 331 InitExpander srcParam(arg); -
src/InitTweak/GenInit.h
r3d5a8cb r46aa60e 33 33 34 34 /// generates a single ctor/dtor statement using objDecl as the 'this' parameter and arg as the optional argument 35 ast::ptr<ast::Stmt> genCtorDtor (const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg = nullptr);35 const ast::Stmt * genCtorDtor( const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg = nullptr ); 36 36 37 37 /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer -
src/Parser/parser.yy
r3d5a8cb r46aa60e 1081 1081 | logical_OR_expression '?' comma_expression ':' conditional_expression 1082 1082 { $$ = new ExpressionNode( build_cond( yylloc, $1, $3, $5 ) ); } 1083 // FIX ME: computes $1 twice1084 1083 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 1085 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1->clone(), $4 ) ); }1084 { $$ = new ExpressionNode( build_cond( yylloc, $1, nullptr, $4 ) ); } 1086 1085 ; 1087 1086 -
src/ResolvExpr/CandidateFinder.cpp
r3d5a8cb r46aa60e 1512 1512 void Finder::postvisit( const ast::ConditionalExpr * conditionalExpr ) { 1513 1513 // candidates for condition 1514 ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 ); 1514 1515 CandidateFinder finder1( context, tenv ); 1515 ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );1516 1516 finder1.find( arg1, ResolveMode::withAdjustment() ); 1517 1517 if ( finder1.candidates.empty() ) return; 1518 1518 1519 1519 // candidates for true result 1520 // FIX ME: resolves and runs arg1 twice when arg2 is missing. 1521 ast::Expr const * arg2 = conditionalExpr->arg2; 1522 arg2 = arg2 ? arg2 : conditionalExpr->arg1.get(); 1520 1523 CandidateFinder finder2( context, tenv ); 1521 1524 finder2.allowVoid = true; 1522 finder2.find( conditionalExpr->arg2, ResolveMode::withAdjustment() );1525 finder2.find( arg2, ResolveMode::withAdjustment() ); 1523 1526 if ( finder2.candidates.empty() ) return; 1524 1527 -
src/SymTab/GenImplicitCall.cpp
r3d5a8cb r46aa60e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenImplicitCall. hpp --7 // GenImplicitCall.cpp -- Generate code for implicit operator calls. 8 8 // 9 9 // Author : Andrew Beach … … 31 31 namespace { 32 32 33 template< typename OutIter > 33 using Inserter = std::back_insert_iterator<std::list<ast::ptr<ast::Stmt>>>; 34 34 35 ast::ptr< ast::Stmt > genCall( 35 36 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 36 const CodeLocation & loc, const std::string & fname, OutIter && out,37 const CodeLocation & loc, const std::string & fname, Inserter && out, 37 38 const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward ); 38 39 … … 41 42 /// optionally returns a statement which must be inserted prior to the containing loop, if 42 43 /// there is one 43 template< typename OutIter >44 44 ast::ptr< ast::Stmt > genScalarCall( 45 45 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 46 const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type,46 const CodeLocation & loc, std::string fname, Inserter && out, const ast::Type * type, 47 47 const ast::Type * addCast = nullptr 48 48 ) { … … 97 97 /// Store in out a loop which calls fname on each element of the array with srcParam and 98 98 /// dstParam as arguments. If forward is true, loop goes from 0 to N-1, else N-1 to 0 99 template< typename OutIter >100 99 void genArrayCall( 101 100 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 102 const CodeLocation & loc, const std::string & fname, OutIter && out,101 const CodeLocation & loc, const std::string & fname, Inserter && out, 103 102 const ast::ArrayType * array, const ast::Type * addCast = nullptr, 104 103 LoopDirection forward = LoopForward … … 166 165 } 167 166 168 template< typename OutIter >169 167 ast::ptr< ast::Stmt > genCall( 170 168 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 171 const CodeLocation & loc, const std::string & fname, OutIter && out,169 const CodeLocation & loc, const std::string & fname, Inserter && out, 172 170 const ast::Type * type, const ast::Type * addCast, LoopDirection forward 173 171 ) { 174 172 if ( auto at = dynamic_cast< const ast::ArrayType * >( type ) ) { 175 173 genArrayCall( 176 srcParam, dstParam, loc, fname, std::forward< OutIter >(out), at, addCast,174 srcParam, dstParam, loc, fname, std::forward< Inserter&& >( out ), at, addCast, 177 175 forward ); 178 176 return {}; 179 177 } else { 180 178 return genScalarCall( 181 srcParam, dstParam, loc, fname, std::forward< OutIter>( out ), type, addCast );179 srcParam, dstParam, loc, fname, std::forward< Inserter&& >( out ), type, addCast ); 182 180 } 183 181 } … … 185 183 } // namespace 186 184 187 ast::ptr< ast::Stmt >genImplicitCall(185 const ast::Stmt * genImplicitCall( 188 186 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 189 187 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, … … 191 189 ) { 192 190 // unnamed bit fields are not copied as they cannot be accessed 193 if ( isUnnamedBitfield( obj ) ) return {};191 if ( isUnnamedBitfield( obj ) ) return nullptr; 194 192 195 193 ast::ptr< ast::Type > addCast; … … 199 197 } 200 198 201 std:: vector< ast::ptr< ast::Stmt > > stmts;199 std::list< ast::ptr< ast::Stmt > > stmts; 202 200 genCall( 203 201 srcParam, dstParam, loc, fname, back_inserter( stmts ), obj->type, addCast, forward ); 204 202 205 if ( stmts.empty() ) { 206 return {}; 207 } else if ( stmts.size() == 1 ) { 208 const ast::Stmt * callStmt = stmts.front(); 209 if ( addCast ) { 210 // implicitly generated ctor/dtor calls should be wrapped so that later passes are 211 // aware they were generated. 212 callStmt = new ast::ImplicitCtorDtorStmt( callStmt->location, callStmt ); 213 } 214 return callStmt; 215 } else { 216 assert( false ); 217 return {}; 218 } 203 if ( stmts.empty() ) return nullptr; 204 assert( stmts.size() == 1 ); 205 206 const ast::Stmt * callStmt = stmts.front().release(); 207 // Implicitly generated ctor/dtor calls should be wrapped so that 208 // later passes are aware they were generated. 209 if ( addCast ) { 210 callStmt = new ast::ImplicitCtorDtorStmt( callStmt->location, callStmt ); 211 } 212 return callStmt; 219 213 } 220 214 … … 226 220 // compile-command: "make install" // 227 221 // End: // 228 229 -
src/SymTab/GenImplicitCall.hpp
r3d5a8cb r46aa60e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenImplicitCall.hpp -- 7 // GenImplicitCall.hpp -- Generate code for implicit operator calls. 8 8 // 9 9 // Author : Andrew Beach … … 25 25 /// Returns a generated call expression to function fname with srcParam and 26 26 /// dstParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 27 ast::ptr<ast::Stmt>genImplicitCall(27 const ast::Stmt * genImplicitCall( 28 28 InitTweak::InitExpander & srcParam, const ast::Expr * dstParam, 29 29 const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj, -
src/Validate/Autogen.cpp
r3d5a8cb r46aa60e 133 133 /// Generates a single struct member operation. 134 134 /// (constructor call, destructor call, assignment call) 135 // This is managed because it uses another helper that returns a ast::ptr. 136 ast::ptr<ast::Stmt> makeMemberOp( 135 const ast::Stmt * makeMemberOp( 137 136 const CodeLocation& location, 138 137 const ast::ObjectDecl * dstParam, const ast::Expr * src, … … 524 523 } 525 524 526 ast::ptr<ast::Stmt>StructFuncGenerator::makeMemberOp(525 const ast::Stmt * StructFuncGenerator::makeMemberOp( 527 526 const CodeLocation& location, const ast::ObjectDecl * dstParam, 528 527 const ast::Expr * src, const ast::ObjectDecl * field, … … 539 538 ) 540 539 ); 541 autostmt = genImplicitCall(540 const ast::Stmt * stmt = genImplicitCall( 542 541 srcParam, dstSelect, location, func->name, 543 542 field, direction … … 597 596 location, field, new ast::VariableExpr( location, srcParam ) 598 597 ) : nullptr; 599 ast::ptr<ast::Stmt>stmt =598 const ast::Stmt * stmt = 600 599 makeMemberOp( location, dstParam, srcSelect, field, func, direction ); 601 600 602 601 if ( nullptr != stmt ) { 603 stmts->kids. push_back( stmt );602 stmts->kids.emplace_back( stmt ); 604 603 } 605 604 } … … 622 621 for ( auto param = params.begin() + 1 ; current != end ; ++current ) { 623 622 const ast::ptr<ast::Decl> & member = *current; 624 ast::ptr<ast::Stmt>stmt = nullptr;623 const ast::Stmt * stmt = nullptr; 625 624 auto field = member.as<ast::ObjectDecl>(); 626 625 // Not sure why it could be null. … … 640 639 641 640 if ( nullptr != stmt ) { 642 stmts->kids. push_back( stmt );641 stmts->kids.emplace_back( stmt ); 643 642 } 644 643 }
Note: See TracChangeset
for help on using the changeset viewer.