Changeset 08d5507b
- Timestamp:
- Mar 14, 2017, 11:29:34 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 4da6a6c, e496303
- Parents:
- 68ac32e
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r68ac32e r08d5507b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 5 17:13:33201713 // Update Count : 47 512 // Last Modified On : Mon Mar 13 23:56:59 2017 13 // Update Count : 477 14 14 // 15 15 … … 895 895 896 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 if ( decl->get_storageClasses(). any()) {897 if ( decl->get_storageClasses().val != 0 ) { 898 898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses() ); 899 899 } // if -
src/GenPoly/Box.cc
r68ac32e r08d5507b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:45:59 201713 // Update Count : 33 012 // Last Modified On : Tue Mar 14 07:45:29 2017 13 // Update Count : 334 14 14 // 15 15 … … 299 299 // because each unit generates copies of the default routines for each aggregate. 300 300 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static Class),301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ), 302 302 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), 303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) );303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ); 304 304 layoutDecl->fixUniqueId(); 305 305 return layoutDecl; -
src/InitTweak/FixGlobalInit.cc
r68ac32e r08d5507b 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:14:19201713 // Update Count : 1 412 // Last Modified On : Mon Mar 13 23:58:27 2017 13 // Update Count : 16 14 14 // 15 15 … … 87 87 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 88 88 } 89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 90 90 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 92 92 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 93 93 } … … 143 143 // compile-command: "make install" // 144 144 // End: // 145 -
src/InitTweak/FixInit.cc
r68ac32e r08d5507b 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:51:40201713 // Update Count : 5912 // Last Modified On : Tue Mar 14 08:05:28 2017 13 // Update Count : 63 14 14 // 15 15 … … 678 678 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 679 679 if ( Statement * ctor = ctorInit->get_ctor() ) { 680 if ( objDecl->get_storageClasses() [ DeclarationNode::Static ]) {680 if ( objDecl->get_storageClasses().is_static ) { 681 681 // originally wanted to take advantage of gcc nested functions, but 682 682 // we get memory errors with this approach. To remedy this, the static … … 704 704 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 705 705 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators ); 706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr ); 707 707 isUninitializedVar->fixUniqueId(); 708 708 … … 731 731 732 732 // void __objName_dtor_atexitN(...) {...} 733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 734 734 dtorCaller->fixUniqueId(); 735 735 dtorCaller->get_statements()->push_back( dtorStmt ); … … 764 764 // create a new object which is never used 765 765 static UniqueName dummyNamer( "_dummy" ); 766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 767 767 return dummy; 768 768 } … … 821 821 void InsertDtors::visit( ObjectDecl * objDecl ) { 822 822 // remember non-static destructed objects so that their destructors can be inserted later 823 if ( ! objDecl->get_storageClasses() [ DeclarationNode::Static ]) {823 if ( ! objDecl->get_storageClasses().is_static ) { 824 824 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 825 825 // a decision should have been made by the resolver, so ctor and init are not both non-NULL -
src/InitTweak/GenInit.cc
r68ac32e r08d5507b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:51:38201713 // Update Count : 1 7912 // Last Modified On : Mon Mar 13 23:59:09 2017 13 // Update Count : 180 14 14 // 15 15 … … 186 186 // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension. 187 187 if ( ! inFunction ) return; 188 if ( storageClasses [ DeclarationNode::StaticClass]) return;188 if ( storageClasses.is_static ) return; 189 189 190 190 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { -
src/InitTweak/InitTweak.cc
r68ac32e r08d5507b 260 260 (objDecl->get_init() == NULL || 261 261 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) 262 && ! objDecl->get_storageClasses() [ DeclarationNode::Extern ];262 && ! objDecl->get_storageClasses().is_extern; 263 263 } 264 264 -
src/Parser/DeclarationNode.cc
r68ac32e r08d5507b 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 17:28:56201713 // Update Count : 9 3712 // Last Modified On : Tue Mar 14 10:19:38 2017 13 // Update Count : 964 14 14 // 15 15 … … 90 90 newnode->type = maybeClone( type ); 91 91 newnode->storageClasses = storageClasses; 92 newnode->funcSpecs = funcSpecs; 92 93 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 93 newnode->funcSpecs = funcSpecs;94 94 newnode->enumeratorValue.reset( maybeClone( enumeratorValue.get() ) ); 95 95 newnode->hasEllipsis = hasEllipsis; … … 117 117 118 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) { 119 if ( storageClasses. any() ) { // function specifiers?119 if ( storageClasses.val != 0 ) { // storage classes ? 120 120 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) { 121 121 if ( storageClasses[i] ) { … … 127 127 128 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) { 129 if ( funcSpec. any() ) { // function specifiers?129 if ( funcSpec.val != 0 ) { // function specifiers ? 130 130 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) { 131 131 if ( funcSpec[i] ) { … … 202 202 203 203 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses [ sc ] = true;204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) { 205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses = sc; 207 207 return newnode; 208 208 } // DeclarationNode::newStorageClass 209 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifier fs ) {211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs [ fs ] = true;210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) { 211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs = fs; 213 213 return newnode; 214 214 } // DeclarationNode::newFuncSpecifier … … 459 459 const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization 460 460 461 if ( (qsrc & qdst).any() ) { // common qualifier?462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find common qualifiers461 if ( (qsrc & qdst).any() ) { // duplicates ? 462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates 463 463 if ( qsrc[i] && qdst[i] ) { 464 464 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] ); … … 469 469 470 470 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 471 if ( (funcSpecs & src->funcSpecs).any() ) { // common specifier?472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find common specifier471 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates 473 473 if ( funcSpecs[i] && src->funcSpecs[i] ) { 474 474 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] ); … … 477 477 } // if 478 478 479 if ( storageClasses != 0 && src->storageClasses!= 0 ) { // any reason to check ?480 if ( (storageClasses & src->storageClasses).any()) { // duplicates ?479 if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ? 480 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 481 481 for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates 482 482 if ( storageClasses[i] && src->storageClasses[i] ) { … … 485 485 } // for 486 486 // src is the new item being added and has a single bit 487 } else if ( ! src->storageClasses [ Threadlocal ]) { // conflict ?488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses. to_ulong()) - 1] +489 " & " + storageClassNames[ffs( src->storageClasses. to_ulong()) - 1] );490 src->storageClasses. reset(); // FIX to preserve invariant of one basic storage specifier487 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] + 489 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] ); 490 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 491 491 } // if 492 492 } // if … … 496 496 497 497 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 498 funcSpecs = funcSpecs | q->funcSpecs;499 storageClasses = storageClasses | q->storageClasses;498 funcSpecs.val = funcSpecs.val | q->funcSpecs.val; 499 storageClasses.val = storageClasses.val | q->storageClasses.val; 500 500 501 501 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 1058 1058 // inline _Noreturn int g( int i ); // allowed 1059 1059 // inline _Noreturn int i; // disallowed 1060 if ( type->kind != TypeData::Function && funcSpecs. any()) {1060 if ( type->kind != TypeData::Function && funcSpecs.val != 0 ) { 1061 1061 throw SemanticError( "invalid function specifier for ", this ); 1062 1062 } // if … … 1068 1068 // inlne _Noreturn struct S { ... }; // disallowed 1069 1069 // inlne _Noreturn enum E { ... }; // disallowed 1070 if ( funcSpecs. any()) {1070 if ( funcSpecs.val != 0 ) { 1071 1071 throw SemanticError( "invalid function specifier for ", this ); 1072 1072 } // if -
src/Parser/ParseNode.h
r68ac32e r08d5507b 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 08:10:53201713 // Update Count : 7 2612 // Last Modified On : Tue Mar 14 11:05:05 2017 13 // Update Count : 752 14 14 // 15 15 … … 204 204 // These must remain in the same order as the corresponding DeclarationNode names. 205 205 206 enum StorageClass { Extern, Static, Auto, Register, Threadlocal, NoStorageClass, 207 ExternClass = 1 << Extern, StaticClass = 1 << Static, AutoClass = 1 << Auto, RegisterClass = 1 << Register, ThreadlocalClass = 1 << Threadlocal }; 208 enum FuncSpecifier { Inline, Noreturn, Fortran, NoFuncSpecifier, 209 InlineSpec = 1 << Inline, NoreturnSpec = 1 << Noreturn, FortranSpec = 1 << Fortran }; 206 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 }; 207 union StorageClasses { 208 unsigned int val; 209 struct { 210 bool is_extern : 1; 211 bool is_static : 1; 212 bool is_auto : 1; 213 bool is_register : 1; 214 bool is_threadlocal : 1; 215 }; 216 StorageClasses() : val( 0 ) {} 217 StorageClasses( unsigned int val ) : val( val ) {} 218 bool operator[]( unsigned int i ) const { return val & (1 << i); } 219 }; // StorageClasses 220 221 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 }; 222 union FuncSpecifiers { 223 unsigned int val; 224 struct { 225 bool is_inline : 1; 226 bool is_noreturn : 1; 227 bool is_fortran : 1; 228 }; 229 FuncSpecifiers() : val( 0 ) {} 230 FuncSpecifiers( unsigned int val ) : val( val ) {} 231 bool operator[]( unsigned int i ) const { return val & (1 << i); } 232 }; // FuncSpecifiers 233 210 234 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier }; 211 235 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; … … 228 252 static const char * builtinTypeNames[]; 229 253 230 static DeclarationNode * newStorageClass( StorageClass );231 static DeclarationNode * newFuncSpecifier( FuncSpecifier );254 static DeclarationNode * newStorageClass( StorageClasses ); 255 static DeclarationNode * newFuncSpecifier( FuncSpecifiers ); 232 256 static DeclarationNode * newTypeQualifier( TypeQualifier ); 233 257 static DeclarationNode * newBasicType( BasicType ); … … 326 350 TypeData * type; 327 351 328 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses;329 352 StorageClasses storageClasses; 330 353 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 331 354 332 typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers;333 355 FuncSpecifiers funcSpecs; 334 356 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); -
src/SymTab/Autogen.cc
r68ac32e r08d5507b 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:42:44201713 // Update Count : 5 112 // Last Modified On : Tue Mar 14 07:45:00 2017 13 // Update Count : 54 14 14 // 15 15 … … 162 162 // because each unit generates copies of the default routines for each aggregate. 163 163 // DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static Class);164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ); 165 165 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 166 166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) );167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ); 168 168 decl->fixUniqueId(); 169 169 return decl; … … 720 720 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 721 721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 723 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 725 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 727 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 729 729 typeParams.push_back( newDecl ); 730 730 done.insert( ty->get_baseType() ); -
src/SymTab/Indexer.cc
r68ac32e r08d5507b 10 10 // Created On : Sun May 17 21:37:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:45:32201713 // Update Count : 1 612 // Last Modified On : Tue Mar 14 08:07:34 2017 13 // Update Count : 17 14 14 // 15 15 … … 738 738 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added ); 739 739 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 740 if ( ! newobj->get_storageClasses() [ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ]) {740 if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if
Note: See TracChangeset
for help on using the changeset viewer.