Changes in / [f45772e:2261bcc]
- Files:
-
- 2 deleted
- 23 edited
-
Jenkins/FullBuild (modified) (1 diff)
-
Jenkins/TestRegen (modified) (1 diff)
-
libcfa/src/collections/string_res.cfa (modified) (3 diffs)
-
libcfa/src/iostream.cfa (modified) (5 diffs)
-
src/CodeGen/LinkOnce.cc (modified) (5 diffs)
-
src/CodeGen/LinkOnce.h (modified) (2 diffs)
-
src/GenPoly/BoxNew.cpp (modified) (25 diffs)
-
src/GenPoly/InstantiateGeneric.h (modified) (2 diffs)
-
src/GenPoly/InstantiateGenericNew.cpp (modified) (1 diff)
-
src/Validate/NoIdSymbolTable.hpp (modified) (1 diff)
-
src/main.cc (modified) (1 diff)
-
tests/collections/.expect/string-istream-manip.txt (modified) (3 diffs)
-
tests/collections/.in/string-istream-manip.txt (modified) (1 diff)
-
tests/collections/string-istream-manip.cfa (modified) (3 diffs)
-
tests/errors/.expect/scope-type.txt (deleted)
-
tests/errors/.expect/scope.txt (modified) (1 diff)
-
tests/errors/scope-type.cfa (deleted)
-
tests/errors/scope.cfa (modified) (1 diff)
-
tests/io/.expect/manipulatorsInput.arm64.txt (modified) (3 diffs)
-
tests/io/.expect/manipulatorsInput.x64.txt (modified) (3 diffs)
-
tests/io/.expect/manipulatorsInput.x86.txt (modified) (3 diffs)
-
tests/io/.in/manipulatorsInput.txt (modified) (1 diff)
-
tests/io/manipulatorsInput.cfa (modified) (3 diffs)
-
tests/test.py (modified) (1 diff)
-
tools/build/cfa.m4 (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
rf45772e r2261bcc 25 25 gcc_08_x64_new: { trigger_build( 'gcc-8', 'x64', false ) }, 26 26 gcc_07_x64_new: { trigger_build( 'gcc-7', 'x64', false ) }, 27 gcc_11_arm64_new: { trigger_build( 'gcc-11', 'arm64', false ) }, 28 gcc_10_arm64_new: { trigger_build( 'gcc-10', 'arm64', false ) }, 29 gcc_09_arm64_new: { trigger_build( 'gcc-9', 'arm64', false ) }, 30 // gcc_06_arm64_new: { trigger_build( 'gcc-6', 'arm64', false ) }, 27 // gcc_06_x64_new: { trigger_build( 'gcc-6', 'x64', false ) }, 31 28 clang_x64_new: { trigger_build( 'clang', 'x64', true ) }, 32 29 ) -
Jenkins/TestRegen
rf45772e r2261bcc 24 24 stage('Building x64') { 25 25 regen_tests('x86_64') 26 }27 28 stage('Building arm64') {29 regen_tests('arm64')30 26 } 31 27 -
libcfa/src/collections/string_res.cfa
rf45772e r2261bcc 218 218 // Read in chunks. Often, one chunk is enough. Keep the string that accumulates chunks last in the heap, 219 219 // so available room is rest of heap. When a chunk fills the heap, force growth then take the next chunk. 220 for (bool cont = true; cont; ) { 221 cont = false; 222 220 for (;;) { 223 221 // Append dummy content to temp, forcing expansion when applicable (occurs always on subsequent loops) 224 222 // length 2 ensures room for at least one real char, plus scanf/pipe-cstr's null terminator … … 230 228 temp.Handle.ulink->EndVbyte -= 2; 231 229 232 // rest of heap is available to read into233 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte ;234 assert (lenReadable >= 2);230 // rest of heap, less 1 byte for null terminator, is available to read into 231 int lenReadable = (char*)temp.Handle.ulink->ExtVbyte - temp.Handle.ulink->EndVbyte - 1; 232 assert (lenReadable >= 1); 235 233 236 234 // get bytes 237 try { 238 in | wdi( lenReadable, temp.Handle.ulink->EndVbyte ); 239 } catch (cstring_length*) { 240 cont = true; 241 } 235 in | wdi( lenReadable + 1, lenReadable, temp.Handle.ulink->EndVbyte ); 242 236 int lenWasRead = strlen(temp.Handle.ulink->EndVbyte); 243 237 … … 245 239 temp.Handle.lnth += lenWasRead; 246 240 temp.Handle.ulink->EndVbyte += lenWasRead; 241 242 if (lenWasRead < lenReadable) break; 247 243 } 248 244 -
libcfa/src/iostream.cfa
rf45772e r2261bcc 22 22 #include <float.h> // DBL_DIG, LDBL_DIG 23 23 #include <complex.h> // creal, cimag 24 #include <ctype.h> // isspace25 24 //#include <stdio.h> 26 25 … … 30 29 extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 31 30 extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 32 extern char *strchr(const char *str, int ch);33 31 } // extern "C" 34 32 … … 962 960 istype & ?|?( istype & is, _Istream_Cskip f ) { 963 961 // printf( "skip %s %d\n", f.scanset, f.wd ); 964 if ( f.scanset ) { 965 int nscanset = strlen(f.scanset); 966 char fmtstr[ sizeof("%*[]") + nscanset ]; 967 int pos = 0; 968 fmtstr[pos] = '%'; pos += 1; 969 fmtstr[pos] = '*'; pos += 1; 970 fmtstr[pos] = '['; pos += 1; 971 strcpy( &fmtstr[pos], f.scanset ); pos += nscanset; 972 fmtstr[pos] = ']'; pos += 1; 973 fmtstr[pos] = '\0'; 974 fmt( is, fmtstr, (void*)0 ); // last arg is dummy: suppress gcc warning 975 } 962 if ( f.scanset ) fmt( is, f.scanset, "" ); // no input arguments 976 963 else for ( f.wd ) fmt( is, "%*c" ); 977 964 return is; … … 993 980 // wd is buffer bytes available (for input chars + null terminator) 994 981 // rwd is count of input chars 995 int rwd; 996 if (f.flags.rwd) { 997 verify (f.wd >= 0); 998 rwd = f.wd; 999 } else { 1000 verify (f.wd >= 1); 1001 rwd = f.wd - 1; 1002 } // if 982 int rwd = f.flags.rwd ? f.wd : (f.wd - 1); 1003 983 start += sprintf( &fmtstr[start], "%d", rwd ); 1004 984 } … … 1020 1000 1021 1001 int check = f.wd - 2; 1022 if (! f.flags.ignore ) { 1023 f.s[0] = '\0'; 1024 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1025 } 1002 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1026 1003 len = fmt( is, fmtstr, f.s ); 1027 1004 //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1028 1005 1029 if ( ! f.flags.ignore && ! f.flags.rwd && f.s[check] != '\0' ) { // sentinel overwritten ? 1030 // buffer filled, but would we have kept going? 1031 if ( ! eof( is ) ) { 1032 char peek; 1033 fmt( is, "%c", &peek ); 1034 ungetc( is, peek ); 1035 bool hasMore; 1036 if (f.flags.delimiter) { // getline 1037 hasMore = (peek != f.delimiter[0]); 1038 } else if (f.scanset) { // incl/excl 1039 bool peekMatch = strchr(f.scanset, peek) != 0p; 1040 hasMore = f.flags.inex ? (!peekMatch) : (peekMatch); 1041 } else { // %s 1042 hasMore = !isspace(peek); 1043 } 1044 if (hasMore) throw (cstring_length){ &cstring_length_vt }; 1045 } // if 1046 } // if 1006 if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1007 throw (cstring_length){ &cstring_length_vt }; 1047 1008 1048 1009 if ( f.flags.delimiter ) { // getline ? -
src/CodeGen/LinkOnce.cc
rf45772e r2261bcc 10 10 // Created On : Thur May 13 10:10:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Oct 4 10:52:00 202313 // Update Count : 112 // Last Modified On : Thur May 13 14:39:00 2021 13 // Update Count : 0 14 14 // 15 15 … … 18 18 #include <algorithm> 19 19 20 #include "AST/Attribute.hpp"21 #include "AST/Decl.hpp"22 #include "AST/Expr.hpp"23 #include "AST/Pass.hpp"24 20 #include "Common/PassVisitor.h" // for PassVisitor, WithShortCircuiting 25 21 26 22 namespace CodeGen { 27 23 28 namespace { 29 30 bool is_cfa_linkonce_old( Attribute const * attr ) { 24 static bool is_cfa_linkonce( Attribute const * attr ) { 31 25 return std::string("cfa_linkonce") == attr->name; 32 26 } 33 27 34 bool is_section_attribute_old( Attribute const * attr ) {28 static bool is_section_attribute( Attribute const * attr ) { 35 29 return std::string("section") == attr->name; 36 30 } … … 45 39 std::list< Attribute * > & attributes = decl->attributes; 46 40 // See if we can find the element: 47 auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce _old);41 auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce ); 48 42 if ( attributes.end() != found ) { 49 43 // Remove any other sections: 50 attributes.remove_if( is_section_attribute _old);44 attributes.remove_if( is_section_attribute ); 51 45 // Iterator to the cfa_linkonce attribute should still be valid. 52 46 Attribute * attribute = *found; … … 69 63 }; 70 64 71 bool is_cfa_linkonce( ast::Attribute const * attr ) {72 return "cfa_linkonce" == attr->name;73 }74 75 bool is_section_attribute( ast::Attribute const * attr ) {76 return "section" == attr->name;77 }78 79 struct LinkOnceCore : public ast::WithShortCircuiting {80 void previsit( ast::Decl const * ) {81 visit_children = false;82 }83 84 ast::DeclWithType const * postvisit( ast::DeclWithType const * decl ) {85 // Check to see if we have to mutate, because should be uncommon.86 {87 auto & attributes = decl->attributes;88 auto found = std::find_if( attributes.begin(), attributes.end(),89 is_cfa_linkonce );90 if ( attributes.end() == found ) return decl;91 }92 auto mutDecl = mutate( decl );93 auto & attributes = mutDecl->attributes;94 95 // Remove all conflicting section attributes.96 erase_if( attributes, is_section_attribute );97 98 // Get the attribute, and overwrite it as a section attribute.99 auto found = std::find_if( attributes.begin(), attributes.end(),100 is_cfa_linkonce );101 assert( attributes.end() != found );102 ast::Attribute * attribute = found->get_and_mutate();103 assert( attribute->params.empty() );104 assert( !decl->mangleName.empty() );105 106 attribute->name = "section";107 attribute->params.push_back(108 ast::ConstantExpr::from_string( mutDecl->location,109 ".gnu.linkonce." + decl->mangleName110 )111 );112 113 // Unconditionnaly add "visibility(default)" to anything with114 // .gnu.linkonce visibility is a mess otherwise.115 attributes.push_back( new ast::Attribute( "visibility", {116 ast::ConstantExpr::from_string( mutDecl->location, "default" )117 } ) );118 return mutDecl;119 }120 };121 122 } // namespace123 124 65 void translateLinkOnce( std::list< Declaration *> & translationUnit ) { 125 66 PassVisitor<LinkOnceVisitorCore> translator; … … 127 68 } 128 69 129 void translateLinkOnce( ast::TranslationUnit & translationUnit ) {130 ast::Pass<LinkOnceCore>::run( translationUnit );131 70 } 132 133 } // namespace CodeGen -
src/CodeGen/LinkOnce.h
rf45772e r2261bcc 10 10 // Created On : Thur May 13 10:06:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Oct 4 10:52:00 202313 // Update Count : 112 // Last Modified On : Thur May 13 14:38:00 2021 13 // Update Count : 0 14 14 // 15 15 … … 23 23 24 24 class Declaration; 25 namespace ast {26 class TranslationUnit;27 }28 25 29 26 namespace CodeGen { 30 27 31 28 void translateLinkOnce( std::list< Declaration *> & translationUnit ); 32 void translateLinkOnce( ast::TranslationUnit & translationUnit );33 29 /* Convert the cfa_linkonce attribute on top level declaration into 34 30 * a special section declaration (.gnu.linkonce) so that it may be defined -
src/GenPoly/BoxNew.cpp
rf45772e r2261bcc 77 77 }; 78 78 79 // Formally takeOtypeOnly 79 80 /// Get all sized type declarations; those that affect a layout function. 80 81 ast::vector<ast::TypeDecl> takeSizedParams( … … 509 510 ast::FunctionType const * function, 510 511 TypeVarMap const & typeVars ) { 512 // TODO 513 // NOTE: This function previously used isPolyObj, which failed to produce 514 // the correct thing in some situations. It's not clear to [Rob Schluntz] 515 // why this wasn't working. 516 511 517 // If the return type or a parameter type involved polymorphic types, 512 518 // then the adapter will need to take those polymorphic types as pointers. … … 581 587 ast::FunctionType const * type = decl->type; 582 588 if ( isDynRet( type ) && decl->linkage != ast::Linkage::C ) { 589 //retval = type->returns.front(); 583 590 retval = decl->returns.front(); 584 591 … … 741 748 ast::Expr const * CallAdapter::postvisit( ast::UntypedExpr const * expr ) { 742 749 if ( isPolyDeref( expr, scopeTypeVars, typeSubs ) ) { 750 // TODO Pretty sure this is just a memory management change. 751 // Also, I don't understand what this is doing. 752 //ast::Expr const * ret = expr->args.front(); 753 //expr->args.clear(); 754 //return ret; 743 755 return expr->args.front(); 744 756 } … … 1051 1063 ast::ptr<ast::Type> newType = ast::deepCopy( param ); 1052 1064 if ( typeSubs ) typeSubs->apply( newType ); 1065 // TODO: Is this right? (Why wouldn't it be?) 1066 // I think this is to make sure we can write to the temporary. 1067 //newType.get_and_mutate()->qt = ast::CV::Qualifiers(); 1068 //reset_qualifiers( newType ); 1053 1069 ast::ObjectDecl * newObj = makeTemporary( location, newType ); 1054 1070 auto assign = ast::UntypedExpr::createCall( location, "?=?", { … … 1229 1245 } 1230 1246 return new ast::ObjectDecl( location, pNamer.newName(), param ); 1231 } ), 1247 } ), // params 1232 1248 map_range<ast::vector<ast::DeclWithType>>( adapterType->returns, 1233 1249 [&rNamer, &location]( ast::ptr<ast::Type> const & retval ) { 1234 1250 return new ast::ObjectDecl( location, rNamer.newName(), retval ); 1235 } ), 1251 } ), // returns 1236 1252 nullptr, // stmts 1237 {}, // storage 1238 ast::Linkage::C 1253 ast::Storage::Classes(), // storage 1254 ast::Linkage::C // linkage 1255 // attrs 1256 // fs 1257 // isVarArgs 1239 1258 ); 1240 1259 … … 1295 1314 // Returns a polymorphic type. 1296 1315 } else if ( isDynType( adaptee->returns.front(), typeVars ) ) { 1316 if ( "" == (*paramDecl)->name ) { 1317 // TODO: Is it easier to make sure it has a name in the first 1318 // place? - I believe this is done, however, I could remove the 1319 // condition and just rename for clarity. 1320 assertf( false, "Wasn't expecting to get here." ); 1321 auto mutParam = paramDecl->get_and_mutate(); 1322 mutParam->name = "_ret"; 1323 mutParam->linkage = ast::Linkage::C; 1324 } 1297 1325 ast::UntypedExpr * assign = new ast::UntypedExpr( location, 1298 1326 new ast::NameExpr( location, "?=?" ) ); … … 1518 1546 1519 1547 // -------------------------------------------------------------------------- 1520 /// Modifies declarations to accept implicit parameters.1548 /// Creates the adapter functions. TODO 1521 1549 /// * Move polymorphic returns in function types to pointer-type parameters. 1522 1550 /// * Adds type size and assertion parameters to parameter lists. 1523 struct DeclAdapter final { 1551 struct DeclAdapter final : 1552 public BoxPass, 1553 public ast::WithGuards { 1554 void handleAggrDecl(); 1555 1556 void previsit( ast::StructDecl const * decl ); 1557 void previsit( ast::UnionDecl const * decl ); 1558 void previsit( ast::TraitDecl const * decl ); 1559 void previsit( ast::TypeDecl const * decl ); 1560 void previsit( ast::PointerType const * type ); 1561 void previsit( ast::FunctionType const * type ); 1524 1562 ast::FunctionDecl const * previsit( ast::FunctionDecl const * decl ); 1525 ast::FunctionDecl const * postvisit( ast::FunctionDecl const * decl ); 1563 ast::DeclWithType const * postvisit( ast::FunctionDecl const * decl ); 1564 void previsit( ast::CompoundStmt const * stmt ); 1526 1565 private: 1527 void addAdapters( ast::FunctionDecl * decl, TypeVarMap & localTypeVars ); 1566 ast::FunctionDecl * addAdapters( ast::FunctionDecl * decl ); 1567 1568 std::map<UniqueId, std::string> adapterName; 1528 1569 }; 1529 1570 1530 // size/align/offset parameters may not be used, so add the unused attribute. 1531 ast::ObjectDecl * makeObj( 1532 CodeLocation const & location, std::string const & name ) { 1533 return new ast::ObjectDecl( location, name, 1534 makeSizeAlignType(), 1535 nullptr, ast::Storage::Classes(), ast::Linkage::C, nullptr, 1536 { new ast::Attribute( "unused" ) } ); 1537 } 1538 1539 ast::ObjectDecl * makePtr( 1540 CodeLocation const & location, std::string const & name ) { 1541 return new ast::ObjectDecl( location, name, 1542 new ast::PointerType( makeSizeAlignType() ), 1543 nullptr, ast::Storage::Classes(), ast::Linkage::C, nullptr ); 1571 // at must point within [dst.begin(), dst.end()]. 1572 template< typename T > 1573 void spliceAt( std::vector< T > & dst, typename std::vector< T >::iterator at, 1574 std::vector< T > & src ) { 1575 std::vector< T > tmp; 1576 tmp.reserve( dst.size() + src.size() ); 1577 typename std::vector< T >::iterator it = dst.begin(); 1578 while ( it != at ) { 1579 assert( it != dst.end() ); 1580 tmp.emplace_back( std::move( *it ) ); 1581 ++it; 1582 } 1583 for ( T & x : src ) { tmp.emplace_back( std::move( x ) ); } 1584 while ( it != dst.end() ) { 1585 tmp.emplace_back( std::move( *it ) ); 1586 ++it; 1587 } 1588 1589 dst.clear(); 1590 src.clear(); 1591 tmp.swap( dst ); 1592 } 1593 1594 void DeclAdapter::previsit( ast::StructDecl const * ) { 1595 // Prevent type vars from leaking into the containing scope. 1596 GuardScope( scopeTypeVars ); 1597 } 1598 1599 void DeclAdapter::previsit( ast::UnionDecl const * ) { 1600 // Prevent type vars from leaking into the containing scope. 1601 GuardScope( scopeTypeVars ); 1602 } 1603 1604 void DeclAdapter::previsit( ast::TraitDecl const * ) { 1605 // Prevent type vars from leaking into the containing scope. 1606 GuardScope( scopeTypeVars ); 1607 } 1608 1609 void DeclAdapter::previsit( ast::TypeDecl const * decl ) { 1610 addToTypeVarMap( decl, scopeTypeVars ); 1611 } 1612 1613 void DeclAdapter::previsit( ast::PointerType const * type ) { 1614 GuardScope( scopeTypeVars ); 1615 makeTypeVarMap( type, scopeTypeVars ); 1616 } 1617 1618 // TODO: I think this code is redundent. 1619 void DeclAdapter::previsit( ast::FunctionType const * type ) { 1620 GuardScope( scopeTypeVars ); 1621 makeTypeVarMap( type, scopeTypeVars ); 1544 1622 } 1545 1623 1546 1624 ast::FunctionDecl const * DeclAdapter::previsit( ast::FunctionDecl const * decl ) { 1547 TypeVarMap localTypeVars = { ast::TypeData() };1548 makeTypeVarMap( decl, localTypeVars );1625 GuardScope( scopeTypeVars ); 1626 makeTypeVarMap( decl, scopeTypeVars ); 1549 1627 1550 1628 auto mutDecl = mutate( decl ); … … 1561 1639 1562 1640 // Add size/align and assertions for type parameters to parameter list. 1563 ast::vector<ast::DeclWithType> inferredParams; 1564 ast::vector<ast::DeclWithType> layoutParams; 1641 std::vector<ast::ptr<ast::DeclWithType>>::iterator last = mutDecl->params.begin(); 1642 std::vector<ast::ptr<ast::DeclWithType>> inferredParams; 1643 // size/align/offset parameters may not be used in body, pass along with unused attribute. 1644 // TODO: These should be created with proper location and name. 1645 // TODO: makeSizeAlign[Out]Type are the same as these types, but they may 1646 // be logically different. 1647 ast::ObjectDecl newObj( mutDecl->location, "", 1648 new ast::BasicType( ast::BasicType::LongUnsignedInt ), 1649 nullptr, ast::Storage::Classes(), ast::Linkage::C, nullptr, 1650 { new ast::Attribute( "unused" ) } ); 1651 ast::ObjectDecl newPtr( mutDecl->location, "", 1652 new ast::PointerType( new ast::BasicType( ast::BasicType::LongUnsignedInt ) ), 1653 nullptr, ast::Storage::Classes(), ast::Linkage::C, nullptr ); 1565 1654 for ( ast::ptr<ast::TypeDecl> & typeParam : mutDecl->type_params ) { 1566 1655 auto mutParam = mutate( typeParam.get() ); 1567 1656 // Add all size and alignment parameters to parameter list. 1568 1657 if ( mutParam->isComplete() ) { 1658 //ast::TypeInstType paramType( typeParam->name, typeParam ); 1569 1659 ast::TypeInstType paramType( mutParam ); 1570 1660 std::string paramName = Mangle::mangleType( ¶mType ); 1571 1661 1572 auto sizeParam = makeObj( typeParam->location, sizeofName( paramName ) ); 1573 layoutParams.emplace_back( sizeParam ); 1574 1575 auto alignParam = makeObj( typeParam->location, alignofName( paramName ) ); 1576 layoutParams.emplace_back( alignParam ); 1662 ast::ObjectDecl * sizeParam = ast::deepCopy( &newObj ); 1663 sizeParam->location = typeParam->location; 1664 sizeParam->name = sizeofName( paramName ); 1665 last = mutDecl->params.insert( last, sizeParam ); 1666 ++last; 1667 1668 ast::ObjectDecl * alignParam = ast::deepCopy( &newObj ); 1669 alignParam->location = typeParam->location; 1670 alignParam->name = alignofName( paramName ); 1671 last = mutDecl->params.insert( last, alignParam ); 1672 ++last; 1577 1673 } 1578 1674 // TODO: These should possibly all be gone. … … 1600 1696 // Add size/align for generic parameter types to parameter list. 1601 1697 std::set<std::string> seenTypes; 1602 ast::vector<ast::DeclWithType> otypeParams;1698 std::vector<ast::ptr<ast::DeclWithType>> otypeParams; 1603 1699 for ( ast::ptr<ast::DeclWithType> & funcParam : mutDecl->params ) { 1604 ast::Type const * polyType = isPolyType( funcParam->get_type(), localTypeVars );1700 ast::Type const * polyType = isPolyType( funcParam->get_type(), scopeTypeVars ); 1605 1701 if ( !polyType || dynamic_cast<ast::TypeInstType const *>( polyType ) ) { 1606 1702 continue; … … 1608 1704 std::string typeName = Mangle::mangleType( polyType ); 1609 1705 if ( seenTypes.count( typeName ) ) continue; 1706 1707 ast::ObjectDecl * sizeParam = ast::deepCopy( &newObj ); 1708 sizeParam->location = funcParam->location; 1709 sizeParam->name = sizeofName( typeName ); 1710 otypeParams.emplace_back( sizeParam ); 1711 1712 ast::ObjectDecl * alignParam = ast::deepCopy( &newObj ); 1713 alignParam->location = funcParam->location; 1714 alignParam->name = alignofName( typeName ); 1715 otypeParams.emplace_back( alignParam ); 1716 1717 if ( auto * polyStruct = 1718 dynamic_cast<ast::StructInstType const *>( polyType ) ) { 1719 // Zero-length arrays are illegal in C, so empty structs have no 1720 // offset array. 1721 if ( !polyStruct->base->members.empty() ) { 1722 ast::ObjectDecl * offsetParam = ast::deepCopy( &newPtr ); 1723 offsetParam->location = funcParam->location; 1724 offsetParam->name = offsetofName( typeName ); 1725 otypeParams.emplace_back( offsetParam ); 1726 } 1727 } 1610 1728 seenTypes.insert( typeName ); 1611 1612 auto sizeParam = makeObj( funcParam->location, sizeofName( typeName ) ); 1613 otypeParams.emplace_back( sizeParam ); 1614 1615 auto alignParam = makeObj( funcParam->location, alignofName( typeName ) ); 1616 otypeParams.emplace_back( alignParam ); 1617 1618 // Zero-length arrays are illegal in C, so empty structs have no 1619 // offset array. 1620 if ( auto * polyStruct = 1621 dynamic_cast<ast::StructInstType const *>( polyType ) ; 1622 polyStruct && !polyStruct->base->members.empty() ) { 1623 auto offsetParam = makePtr( funcParam->location, offsetofName( typeName ) ); 1624 otypeParams.emplace_back( offsetParam ); 1625 } 1626 } 1627 1628 // Prepend each argument group. From last group to first. addAdapters 1629 // does do the same, it just does it itself and see all other parameters. 1630 spliceBegin( mutDecl->params, inferredParams ); 1631 spliceBegin( mutDecl->params, otypeParams ); 1632 spliceBegin( mutDecl->params, layoutParams ); 1633 addAdapters( mutDecl, localTypeVars ); 1729 } 1730 1731 // TODO: A unified way of putting these together might be nice. 1732 // Put the list together: adapters (in helper) otype parameters, 1733 // inferred params., layout params. (done) and finally explicit params. 1734 spliceBegin( inferredParams, otypeParams ); 1735 spliceAt( mutDecl->params, last, inferredParams ); 1736 mutDecl = addAdapters( mutDecl ); 1634 1737 1635 1738 return mutDecl; 1636 1739 } 1637 1740 1638 ast:: FunctionDeclconst * DeclAdapter::postvisit(1741 ast::DeclWithType const * DeclAdapter::postvisit( 1639 1742 ast::FunctionDecl const * decl ) { 1640 1743 ast::FunctionDecl * mutDecl = mutate( decl ); … … 1670 1773 } 1671 1774 1672 void DeclAdapter::addAdapters( 1673 ast::FunctionDecl * mutDecl, TypeVarMap & localTypeVars ) { 1674 ast::vector<ast::FunctionType> functions; 1775 void DeclAdapter::previsit( ast::CompoundStmt const * ) { 1776 GuardScope( scopeTypeVars ); 1777 // TODO: It is entirely possible the scope doesn't need to spread 1778 // across multiple functions. Otherwise, find a better clear. 1779 std::set<TypeVarMap::key_type> keys; 1780 for ( auto pair : const_cast<TypeVarMap const &>( scopeTypeVars ) ) { 1781 keys.insert( pair.first ); 1782 } 1783 for ( auto key : keys ) { 1784 scopeTypeVars.erase( key ); 1785 } 1786 } 1787 1788 // It actually does mutate in-place, but does the return for consistency. 1789 ast::FunctionDecl * DeclAdapter::addAdapters( ast::FunctionDecl * mutDecl ) { 1790 std::vector<ast::ptr<ast::FunctionType>> functions; 1675 1791 for ( ast::ptr<ast::DeclWithType> & arg : mutDecl->params ) { 1676 1792 ast::Type const * type = arg->get_type(); 1677 type = findAndReplaceFunction( type, functions, localTypeVars, needsAdapter );1793 type = findAndReplaceFunction( type, functions, scopeTypeVars, needsAdapter ); 1678 1794 arg.get_and_mutate()->set_type( type ); 1679 1795 } 1680 1796 std::set<std::string> adaptersDone; 1681 1797 for ( ast::ptr<ast::FunctionType> const & func : functions ) { 1682 std::string mangleName = mangleAdapterName( func, localTypeVars );1798 std::string mangleName = mangleAdapterName( func, scopeTypeVars ); 1683 1799 if ( adaptersDone.find( mangleName ) != adaptersDone.end() ) { 1684 1800 continue; … … 1688 1804 mutDecl->params.insert( mutDecl->params.begin(), new ast::ObjectDecl( 1689 1805 mutDecl->location, adapterName, 1690 new ast::PointerType( makeAdapterType( func, localTypeVars ) ),1806 new ast::PointerType( makeAdapterType( func, scopeTypeVars ) ), 1691 1807 nullptr, {}, {}, nullptr, 1692 1808 { new ast::Attribute( "unused" ) } ) ); 1693 1809 adaptersDone.insert( adaptersDone.begin(), mangleName ); 1694 1810 } 1811 return mutDecl; 1695 1812 } 1696 1813 … … 1809 1926 /// Namer for VLA (variable length array) buffers. 1810 1927 UniqueName bufNamer; 1811 /// If the argument of an AddressExpr is MemberExpr, it is stored here.1812 ast:: MemberExpr const * addrMember = nullptr;1928 /// AddressExpr argument is MemberExpr? (TODO: What?) 1929 ast::Expr const * addrMember = nullptr; 1813 1930 /// Used to avoid recursing too deep in type declarations. 1814 1931 bool expect_func_type = false; … … 1842 1959 beginTypeScope( decl->type ); 1843 1960 1844 // TODO: Going though dec->params does not work for some reason. 1961 // - Tried inserting this code. 1962 // Make sure that any type information passed into the function is 1963 // accounted for. 1964 // TODO: For some reason going through decl->params/->get_type() does 1965 // not work. Possibly something is not getting updated. 1845 1966 for ( ast::ptr<ast::Type> const & funcParam : decl->type->params ) { 1846 1967 // Condition here duplicates that in `DeclAdapter::previsit( FunctionDecl const * )` … … 1898 2019 ast::StructDecl const * PolyGenericCalculator::previsit( 1899 2020 ast::StructDecl const * decl ) { 2021 //return strict_dynamic_cast<ast::StructDecl *>( mutateMembers( decl ) ); 1900 2022 auto mutDecl = mutate( decl ); 1901 2023 mutateMembers( mutDecl ); … … 1905 2027 ast::UnionDecl const * PolyGenericCalculator::previsit( 1906 2028 ast::UnionDecl const * decl ) { 2029 //return strict_dynamic_cast<ast::UnionDecl *>( mutateMembers( decl ) ); 1907 2030 auto mutDecl = mutate( decl ); 1908 2031 mutateMembers( mutDecl ); … … 1965 2088 auto mutDecl = mutate( decl ); 1966 2089 1967 // Forally, side effects are not safe in this function. But it works. 2090 //mutDecl->attributes.remove_if( matchAndMove ); 2091 // TODO: This common helper might work, but does not officially support 2092 // side effects. 1968 2093 erase_if( mutDecl->attributes, matchAndMove ); 1969 2094 … … 2073 2198 // the substitution manually. For some reason this is not currently the 2074 2199 // case. This requires more investigation. 2075 ast:: ptr<ast::Type>memberType = deepCopy( expr->member->get_type() );2200 ast::Type const * memberType = deepCopy( expr->member->get_type() ); 2076 2201 ast::TypeSubstitution sub = genericSubstitution( objectType ); 2077 sub.apply( memberType );2078 2202 auto result = sub.apply( memberType ); 2203 memberType = result.node.get(); // .release(); 2079 2204 // Not all members of a polymorphic type are themselves of a polymorphic 2080 2205 // type; in this cas the member expression should be wrapped and … … 2092 2217 2093 2218 void PolyGenericCalculator::previsit( ast::AddressExpr const * expr ) { 2219 // Is the argument a MemberExpr before mutating? 2094 2220 GuardValue( addrMember ) = expr->arg.as<ast::MemberExpr>(); 2095 2221 } … … 2107 2233 // MemberExpr was converted to pointer + offset; and it is not valid C to 2108 2234 // take the address of an addition, so stript the address-of. 2109 // It also preserves the env value. 2110 return ast::mutate_field( expr->arg.get(), &ast::Expr::env, expr->env ); 2235 // TODO: should expr->arg->result be changed to expr->result? 2236 ast::Expr * ret = mutate( expr->arg.get() ); 2237 ret->env = expr->env; 2238 return ret; 2111 2239 } 2112 2240 … … 2444 2572 public BoxPass, 2445 2573 public ast::WithGuards { 2446 void guardTypeVarMap( ast::Type const * type ) { 2447 GuardScope( scopeTypeVars ); 2448 makeTypeVarMap( type, scopeTypeVars ); 2449 } 2574 template<typename decl_t> 2575 decl_t const * handleDecl( decl_t const * decl, ast::Type const * type ); 2450 2576 2451 2577 ast::ObjectDecl const * previsit( ast::ObjectDecl const * decl ); … … 2459 2585 }; 2460 2586 2587 template<typename decl_t> 2588 decl_t const * Eraser::handleDecl( 2589 decl_t const * decl, ast::Type const * type ) { 2590 GuardScope( scopeTypeVars ); 2591 makeTypeVarMap( type, scopeTypeVars ); 2592 return scrubAllTypeVars( decl ); 2593 } 2594 2461 2595 ast::ObjectDecl const * Eraser::previsit( ast::ObjectDecl const * decl ) { 2462 guardTypeVarMap( decl->type ); 2463 return scrubAllTypeVars( decl ); 2596 return handleDecl( decl, decl->type ); 2464 2597 } 2465 2598 2466 2599 ast::FunctionDecl const * Eraser::previsit( ast::FunctionDecl const * decl ) { 2467 guardTypeVarMap( decl->type ); 2468 return scrubAllTypeVars( decl ); 2600 return handleDecl( decl, decl->type ); 2469 2601 } 2470 2602 2471 2603 ast::TypedefDecl const * Eraser::previsit( ast::TypedefDecl const * decl ) { 2472 guardTypeVarMap( decl->base ); 2473 return scrubAllTypeVars( decl ); 2604 return handleDecl( decl, decl->base ); 2474 2605 } 2475 2606 … … 2477 2608 template<typename node_t> 2478 2609 node_t const * stripGenericMembers( node_t const * decl ) { 2479 if ( decl->params.empty() ) return decl; 2480 auto mutDecl = ast::mutate( decl ); 2481 mutDecl->members.clear(); 2482 return mutDecl; 2610 if ( !decl->params.empty() ) { 2611 auto mutDecl = ast::mutate( decl ); 2612 mutDecl->members.clear(); 2613 return mutDecl; 2614 } 2615 return decl; 2483 2616 } 2484 2617 … … 2496 2629 2497 2630 void Eraser::previsit( ast::PointerType const * type ) { 2498 guardTypeVarMap( type ); 2631 GuardScope( scopeTypeVars ); 2632 makeTypeVarMap( type, scopeTypeVars ); 2499 2633 } 2500 2634 2501 2635 void Eraser::previsit( ast::FunctionType const * type ) { 2502 guardTypeVarMap( type ); 2636 GuardScope( scopeTypeVars ); 2637 makeTypeVarMap( type, scopeTypeVars ); 2503 2638 } 2504 2639 -
src/GenPoly/InstantiateGeneric.h
rf45772e r2261bcc 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InstantiateGeneric.h -- Create concrete instances of generic types.7 // InstantiateGeneric.h -- 8 8 // 9 9 // Author : Aaron B. Moss … … 24 24 25 25 namespace GenPoly { 26 26 /// Replaces all generic types that have static layout with concrete 27 /// instantiations. Types with concrete values for otype parameters will be 28 /// template-expanded, while dtype and ftype parameters will be replaced by 29 /// the appropriate void type. 27 30 void instantiateGeneric( std::list< Declaration* > &translationUnit ); 28 31 void instantiateGeneric( ast::TranslationUnit & translationUnit ); 29 /// Replaces all generic types that have static layout with concrete30 /// instantiations. Sized types are replaced with the concrete argument types31 /// while unsized types are erased to a void type.32 /// This pass can cause designators to ignore the pretty print option.33 34 32 } // namespace GenPoly 35 33 -
src/GenPoly/InstantiateGenericNew.cpp
rf45772e r2261bcc 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // InstantiateGenericNew.cpp -- Create concrete instances of generic types.7 // InstantiateGenericNew.cpp -- 8 8 // 9 9 // Author : Andrew Beach -
src/Validate/NoIdSymbolTable.hpp
rf45772e r2261bcc 20 20 namespace Validate { 21 21 22 // A SymbolTable that only tracks names relevant to Validate passes. 23 // It tracks type names but not identifier names. 24 // Some of the canonicalization that occurs before the resolver 25 // affects how identifier name errors get reported to the user. 26 // The Validate phase needs to chase type names, 27 // but it is too early to try tracking identifier names. 28 // Identifier skipping is acheived by omitting methods that should not be 22 // A SymbolTable that only has the operations used in the Translate Dimension 23 // pass. More importantly, it doesn't have some methods that should no be 29 24 // called by the Pass template (lookupId and addId). 30 25 class NoIdSymbolTable { 31 26 ast::SymbolTable base; 32 27 public: 33 // All names that are tracked (now) are eligible for collision validation (now).34 // (Names that are only tracked later get their collision validation then.)35 NoIdSymbolTable() : base(ast::SymbolTable::ValidateOnAdd) {}36 37 28 # define FORWARD_X( func, types_and_names, just_names ) \ 38 29 inline auto func types_and_names -> decltype( base.func just_names ) { \ -
src/main.cc
rf45772e r2261bcc 421 421 DUMP( bboxp, std::move( transUnit ) ); 422 422 PASS( "Box", GenPoly::box, transUnit ); 423 PASS( "Link-Once", CodeGen::translateLinkOnce, transUnit );424 423 425 424 translationUnit = convert( std::move( transUnit ) ); 425 426 PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit ); 426 427 427 428 // Code has been lowered to C, now we can start generation. -
tests/collections/.expect/string-istream-manip.txt
rf45772e r2261bcc 1 preS1 01234562 preS1 x3 preS2 012345674 preS2 x5 preS3 0123456786 preS3 x7 preS4 01234567898 preS4 x9 preSMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345610 preSMN1 x11 preSMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456712 preSMN2 x13 preSMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567814 preSMN3 x15 preSMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678916 preSMN4 x17 preRMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345618 preRMN1 x19 preRMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456720 preRMN2 x21 preRMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567822 preRMN3 x23 preRMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678924 preRMN4 x25 preSMI1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "26 preSMI1 "x"27 preSMI2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "28 preSMI2 "x"29 preSMI3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "30 preSMI3 "x"31 preSMI4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "32 preSMI4 "x"33 preSME1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "34 preSME1 "x"35 preSME2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "36 preSME2 "x"37 preSME3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "38 preSME3 "x"39 preSME4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... "40 preSME4 "x"41 preSMG1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345642 preSMG1 x43 preSMG2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456744 preSMG2 x45 preSMG3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567846 preSMG3 x47 preSMG4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678948 preSMG4 x49 preSMD1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345650 preSMD1 x51 preSMD2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456752 preSMD2 x53 preSMD3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567854 preSMD3 x55 preSMD4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678956 preSMD4 x57 1 1 yyyyyyyyyyyyyyyyyyyy 58 2 2 abcxxx … … 68 12 12 wwwwwwww 69 13 13 wwwwwwww 70 14 cccc71 1572 14 1 yyyyyyyyyyyyyyyyyyyy 73 15 2 abcxxx … … 83 25 12 wwwwwwww 84 26 13 wwwwwwww 85 14 cccc86 15 -
tests/collections/.in/string-istream-manip.txt
rf45772e r2261bcc 1 0123456 x2 01234567 x3 012345678 x4 0123456789 x5 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x6 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x7 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x8 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x9 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x10 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x11 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x12 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x13 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-14 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-15 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-16 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-17 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-18 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-19 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-20 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x-21 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345622 x23 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456724 x25 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567826 x27 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678928 x29 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456@x@30 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567@x@31 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678@x@32 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789@x@33 1 abc 34 cccccb2 abc 35 3 xx 36 4 abcxxx 37 5 abcyyy 38 6 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 39 uuuuuccccuuuuu40 7 abc 41 cccccb8 abc 42 9 xx 43 10 abcxxx 44 11 abcyyy 45 12 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 46 uuuuuccccuuuuu -
tests/collections/string-istream-manip.cfa
rf45772e r2261bcc 3 3 #include <collections/string.hfa> 4 4 #include <collections/string_res.hfa> 5 #include <stdio.h>6 7 // No-op manipulators.8 // Temporary hack while there are two code paths in the string implementation.9 // (One for reading plain strings, the other for reading via a manipulator.)10 // The test cases that use plainjane(-) are exercising the via-manipulator code path,11 // just with trivial manipulation.12 static _Istream_Sstr plainjane( string & s ) { return (_Istream_Sstr)@{ s, {{0p}, -1, {.flags.rwd : false}} }; }13 static _Istream_Rstr plainjane( string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, -1, {.flags.rwd : false}} }; }14 15 static void forceStringHeapFreeSpaceTo(int desiredSize) {16 for (1_000_000) {17 string x = "a";18 (void)x;19 if (desiredSize == DEBUG_string_bytes_avail_until_gc(DEBUG_string_heap())) return;20 }21 sout | "Unable to force size" | desiredSize | "in 1,000,000 tries";22 }23 5 24 6 int main() { 25 // These "pre" cases deal with issues analogous to the "pre" cases of io/manipulatorsInput.26 // The acceptance criterion is simpler but driving the cases is harder.27 // The tests just read strings and echo what they read; acceptance of simple echoing assures28 // no spurious splitting merging.29 // The lengths of the strings are chosen to match white-box knowledge of when the string layer30 // has tor drive the cstring layer through a second iteration:31 // - for no-manip, lengths are near the room at end of string heap32 // (chosen target size of 9 showed the original bug on preS2, aligned with the other cases)33 // - for manip, lengths are near the auxiliary buffer size of 12834 // Only first case repeats for string_res; rest run only from the passthru string layer.35 // Similarly, the manipulator breadth isn't checked at the cstring layer either.36 {37 // S: string, no manipulator38 void echoTillX(const char * casename) {39 string s;40 do {41 forceStringHeapFreeSpaceTo(9);42 sin | s;43 sout | casename | s;44 } while ( size(s) > 0 && s[size(s)-1] != 'x' );45 }46 echoTillX("preS1");47 echoTillX("preS2");48 echoTillX("preS3");49 echoTillX("preS4");50 }51 {52 // SMN: string, manipulator for no-op53 void echoTillX(const char * casename) {54 string s;55 do {56 sin | plainjane( s );57 sout | casename | s;58 } while ( size(s) > 0 && s[size(s)-1] != 'x' );59 }60 echoTillX("preSMN1");61 echoTillX("preSMN2");62 echoTillX("preSMN3");63 echoTillX("preSMN4");64 }65 {66 // RMN: string_res, manipulator for no-op67 void echoTillX(const char * casename) {68 string_res s;69 do {70 sin | plainjane( s );71 sout | casename | s;72 } while ( size(s) > 0 && s[size(s)-1] != 'x' );73 }74 echoTillX("preRMN1");75 echoTillX("preRMN2");76 echoTillX("preRMN3");77 echoTillX("preRMN4");78 }79 {80 // SMI: string, manipulator `incl`81 void echoTillX(const char * casename) {82 string s;83 do {84 sin | skip("-\n");85 sin | incl( ".:|# x", s );86 sout | casename | " \"" | s | "\"";87 } while ( size(s) > 0 && s[size(s)-1] != 'x' );88 }89 echoTillX("preSMI1");90 echoTillX("preSMI2");91 echoTillX("preSMI3");92 echoTillX("preSMI4");93 }94 {95 // SME: string, manipulator `excl`96 void echoTillX(const char * casename) {97 string s;98 do {99 sin | skip("-\n");100 sin | excl( "-\n", s );101 sout | casename | " \"" | s | "\"";102 } while ( size(s) > 0 && s[size(s)-1] != 'x' );103 }104 echoTillX("preSME1");105 echoTillX("preSME2");106 echoTillX("preSME3");107 echoTillX("preSME4");108 }109 sin | skip("-\n");110 {111 // SMG: string, manipulator `getline`112 void echoTillX(const char * casename) {113 string s;114 do {115 sin | getline( s );116 sout | casename | s;117 } while ( size(s) > 0 && s[size(s)-1] != 'x' );118 }119 echoTillX("preSMG1");120 echoTillX("preSMG2");121 echoTillX("preSMG3");122 echoTillX("preSMG4");123 }124 {125 // SMD: string, manipulator (`getline` with custom) delimiter126 void echoTillX(const char * casename) {127 string s;128 do {129 sin | getline( s, '@' );130 sout | casename | s;131 } while ( size(s) > 0 && s[size(s)-1] != 'x' );132 sin | skip(" \n");133 }134 echoTillX("preSMD1");135 echoTillX("preSMD2");136 echoTillX("preSMD3");137 echoTillX("preSMD4");138 }139 140 7 /* Keep harmonized with io/manipulatorsInput */ 141 8 { … … 156 23 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 157 24 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 158 159 s = "q"; 160 sin | incl( "abc", s ); sout | "14" | s; 161 s = "q"; 162 sin | excl( "u", s ); sout | "15" | s; 163 sin | skip( "u" ); 164 sin | "\n"; 165 } 166 // Full repeat on string_res layer assures the full manipulator vocabulary is supported there. 25 } 167 26 { 168 27 string_res s = "yyyyyyyyyyyyyyyyyyyy"; … … 182 41 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 183 42 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 184 185 s = "q";186 sin | incl( "abc", s ); sout | "14" | s;187 s = "q";188 sin | excl( "u", s ); sout | "15" | s;189 sin | skip( "u" );190 sin | "\n";191 43 } 192 44 } -
tests/errors/.expect/scope.txt
rf45772e r2261bcc 1 errors/scope.cfa: 13:1 error: duplicate object definition for thisIsAnError: signed int2 errors/scope.cfa: 30:1 error: duplicate function definition for butThisIsAnError: function1 errors/scope.cfa:2:1 error: duplicate object definition for thisIsAnError: signed int 2 errors/scope.cfa:20:1 error: duplicate function definition for butThisIsAnError: function 3 3 ... with parameters 4 4 double -
tests/errors/scope.cfa
rf45772e r2261bcc 1 // Keep harmonized with errors/scope. 1 int thisIsAnError; 2 int thisIsAnError; 2 3 3 #ifdef OMIT_DRIVING_REJECTIONS 4 // For manual sanity checking: 5 // Leave out the offensive declarations and verify that what's left is accepted. 6 #define EXPREJ(...) 7 #else 8 #define EXPREJ(...) __VA_ARGS__ 9 #endif 4 int thisIsNotAnError; 5 float thisIsNotAnError; 10 6 7 int thisIsAlsoNotAnError() { 8 int thisIsNotAnError; 9 } 11 10 12 int thisIsAnError; 13 EXPREJ( int thisIsAnError; ) 11 int thisIsAlsoNotAnError( double x ) { 12 } 14 13 15 int thisIsNotAnError;16 float thisIsNotAnError;14 double thisIsStillNotAnError( double ); 15 double thisIsStillNotAnError( double ); 17 16 18 int thisIsAlsoNotAnError() { 19 int thisIsNotAnError; 20 } 17 double butThisIsAnError( double ) { 18 } 21 19 22 int thisIsAlsoNotAnError( double x ) { 23 } 24 25 double thisIsStillNotAnError( double ); 26 double thisIsStillNotAnError( double ); 27 28 double butThisIsAnError( double ) { 29 } 30 EXPREJ( 31 double butThisIsAnError( double ) { 32 } 33 ) 20 double butThisIsAnError( double ) { 21 } 34 22 35 23 // Local Variables: // -
tests/io/.expect/manipulatorsInput.arm64.txt
rf45772e r2261bcc 1 1 pre1 "123456", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 7 4 1 yyyyyyyyyyyyyyyyyyyy 8 5 2 abcxxx … … 18 15 12 wwwwwwww 19 16 13 wwwwwwww 20 14 rc=1, cccc21 15 rc=0, q22 17 1 yyyyyyyyyyyyyyyyyyyy 23 18 2 abcxxx … … 33 28 12 wwwwwwww 34 29 13 wwwwwwww 35 14 cccc36 1537 30 a 38 31 a -
tests/io/.expect/manipulatorsInput.x64.txt
rf45772e r2261bcc 1 1 pre1 "123456", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 7 4 1 yyyyyyyyyyyyyyyyyyyy 8 5 2 abcxxx … … 18 15 12 wwwwwwww 19 16 13 wwwwwwww 20 14 rc=1, cccc21 15 rc=0, q22 17 1 yyyyyyyyyyyyyyyyyyyy 23 18 2 abcxxx … … 33 28 12 wwwwwwww 34 29 13 wwwwwwww 35 14 cccc36 1537 30 a 38 31 a -
tests/io/.expect/manipulatorsInput.x86.txt
rf45772e r2261bcc 1 1 pre1 "123456", canary ok 2 pre2 "1234567", canary ok 3 pre3a "1234567", exception occurred, canary ok 4 pre3b "8", canary ok 5 pre4a "1234567", exception occurred, canary ok 6 pre4b "89", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 7 4 1 yyyyyyyyyyyyyyyyyyyy 8 5 2 abcxxx … … 18 15 12 wwwwwwww 19 16 13 wwwwwwww 20 14 rc=1, cccc21 15 rc=0, q22 17 1 yyyyyyyyyyyyyyyyyyyy 23 18 2 abcxxx … … 33 28 12 wwwwwwww 34 29 13 wwwwwwww 35 14 cccc36 1537 30 a 38 31 a -
tests/io/.in/manipulatorsInput.txt
rf45772e r2261bcc 1 1 123456 2 12345673 123456784 2 123456789 5 3 abc 6 cccccb4 abc 7 5 xx 8 6 abcxxx 9 7 abcyyy 10 8 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 11 uuuuuccccuuuuu12 9 abc 13 cccccb10 abc 14 11 xx 15 12 abcxxx 16 13 abcyyy 17 14 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww 18 uuuuuccccuuuuu19 15 ab 20 16 0xff 017 15-15 -
tests/io/manipulatorsInput.cfa
rf45772e r2261bcc 45 45 } 46 46 47 rep("pre1"); // 123456 | 123456 48 rep("pre2"); // 1234567 | 1234567 49 rep("pre3a"); // 12345678 | 1234567 50 rep("pre3b"); // | 8 51 rep("pre4a"); // 123456789 | 1234567 52 rep("pre4b"); // | 89 53 47 rep("pre1"); 48 rep("pre2a"); 49 rep("pre2b"); 54 50 scanf("\n"); // next test does not start with %s so does not tolerate leading whitespace 55 51 } 56 52 { 57 53 char s[] = "yyyyyyyyyyyyyyyyyyyy"; 58 const char sk _fmt[] = "%*[abc]";59 scanf( "abc " ); scanf( sk _fmt ); for ( 5 ) scanf( "%*c" );printf( "1 %s\n", s );54 const char sk[] = "abc"; 55 scanf( "abc " ); scanf( sk ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s ); 60 56 scanf( "%s", s ); printf( "2 %s\n", s ); 61 57 scanf( "%*s" ); printf( "3 %s\n", s ); … … 71 67 scanf( "%*8[abc]" ); printf( "12 %s\n", s ); 72 68 scanf( "%*8[^abc]" ); printf( "13 %s\n", s ); 73 74 int rc;75 s[0] = 'q'; s[1] = '\0'; rc = 99;76 rc = scanf( "%[abc]", s ); printf( "14 rc=%d, %s\n", rc, s );77 s[0] = 'q'; s[1] = '\0'; rc = 99;78 rc = scanf( "%[^u]", s ); printf( "15 rc=%d, %s\n", rc, s );79 scanf( "%*[u]" );80 scanf("\n");81 69 } 82 70 { … … 97 85 sin | ignore( incl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "12" | s; 98 86 sin | ignore( excl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "13" | s; 99 100 s[0] = 'q'; s[1] = '\0';101 sin | incl( "abc", wdi( sizeof(s), s ) ); sout | "14" | s;102 s[0] = 'q'; s[1] = '\0';103 sin | excl( "u", wdi( sizeof(s), s ) ); sout | "15" | s;104 sin | skip( "u" );105 sin | "\n";106 87 } 107 88 /* Keep harmonized with collections/string-istream-manip */ -
tests/test.py
rf45772e r2261bcc 116 116 parser.add_argument('--no-invariant', help='Tell the compiler not to check invariants.', action='store_false', dest='invariant') 117 117 parser.add_argument('--invariant', help='Tell the compiler to check invariants.', action='store_const', const=True) 118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default= 240)118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=180) 119 119 parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200) 120 120 parser.add_argument('--timeout-with-gdb', help='Instead of killing the command when it times out, orphan it and print process id to allow gdb to attach', type=yes_no, default="no") -
tools/build/cfa.m4
rf45772e r2261bcc 67 67 "x86_64" ) cannon_arch_name="x64";; 68 68 "aarch64" ) cannon_arch_name="arm64";; 69 "arm 64") cannon_arch_name="arm64";;69 "arm4" ) cannon_arch_name="arm64";; 70 70 "ARM64" ) cannon_arch_name="arm64";; 71 71 "x86" ) cannon_arch_name="x86";;
Note:
See TracChangeset
for help on using the changeset viewer.