Changes in / [4da6a6c:026bb82]
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4da6a6c r026bb82 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 13 23:56:59201713 // Update Count : 47 712 // Last Modified On : Sun Mar 5 17:13:33 2017 13 // Update Count : 475 14 14 // 15 15 … … 895 895 896 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 if ( decl->get_storageClasses(). val != 0) {897 if ( decl->get_storageClasses().any() ) { 898 898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses() ); 899 899 } // if -
src/GenPoly/Box.cc
r4da6a6c r026bb82 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 14 07:45:29 201713 // Update Count : 33 412 // Last Modified On : Mon Mar 6 23:45:59 2017 13 // Update Count : 330 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 ),301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 302 302 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), 303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 304 304 layoutDecl->fixUniqueId(); 305 305 return layoutDecl; -
src/InitTweak/FixGlobalInit.cc
r4da6a6c r026bb82 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 13 23:58:27201713 // Update Count : 1 612 // Last Modified On : Mon Mar 6 23:14:19 2017 13 // Update Count : 14 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 ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 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 ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 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
r4da6a6c r026bb82 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 14 08:05:28201713 // Update Count : 6312 // Last Modified On : Tue Mar 7 07:51:40 2017 13 // Update Count : 59 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() .is_static) {680 if ( objDecl->get_storageClasses()[ DeclarationNode::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 ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 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 ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), 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 ), 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::StaticClass ), 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() .is_static) {823 if ( ! objDecl->get_storageClasses()[ DeclarationNode::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
r4da6a6c r026bb82 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 13 23:59:09201713 // Update Count : 1 8012 // Last Modified On : Tue Mar 7 07:51:38 2017 13 // Update Count : 179 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 .is_static) return;188 if ( storageClasses[ DeclarationNode::StaticClass] ) return; 189 189 190 190 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { -
src/InitTweak/InitTweak.cc
r4da6a6c r026bb82 260 260 (objDecl->get_init() == NULL || 261 261 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) 262 && ! objDecl->get_storageClasses() .is_extern;262 && ! objDecl->get_storageClasses()[ DeclarationNode::Extern ]; 263 263 } 264 264 -
src/Parser/DeclarationNode.cc
r4da6a6c r026bb82 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 14 10:19:38201713 // Update Count : 9 6412 // Last Modified On : Tue Mar 7 17:28:56 2017 13 // Update Count : 937 14 14 // 15 15 … … 90 90 newnode->type = maybeClone( type ); 91 91 newnode->storageClasses = storageClasses; 92 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 92 93 newnode->funcSpecs = funcSpecs; 93 newnode->bitfieldWidth = maybeClone( bitfieldWidth );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. val != 0 ) { // storage classes?119 if ( storageClasses.any() ) { // function specifiers? 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. val != 0 ) { // function specifiers?129 if ( funcSpec.any() ) { // 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 essc ) {205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses = sc;204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) { 205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses[ sc ] = true; 207 207 return newnode; 208 208 } // DeclarationNode::newStorageClass 209 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifier sfs ) {211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs = fs;210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifier fs ) { 211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs[ fs ] = true; 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() ) { // duplicates?462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates461 if ( (qsrc & qdst).any() ) { // common qualifier ? 462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find common qualifiers 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 .val & src->funcSpecs.val) != 0 ) { // duplicates?472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates471 if ( (funcSpecs & src->funcSpecs).any() ) { // common specifier ? 472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find common specifier 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 .val != 0 && src->storageClasses.val!= 0 ) { // any reason to check ?480 if ( (storageClasses .val & src->storageClasses.val ) != 0) { // duplicates ?479 if ( storageClasses != 0 && src->storageClasses != 0 ) { // any reason to check ? 480 if ( (storageClasses & src->storageClasses).any() ) { // 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 .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 specifier487 } 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 specifier 491 491 } // if 492 492 } // if … … 496 496 497 497 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 498 funcSpecs .val = funcSpecs.val | q->funcSpecs.val;499 storageClasses .val = storageClasses.val | q->storageClasses.val;498 funcSpecs = funcSpecs | q->funcSpecs; 499 storageClasses = storageClasses | q->storageClasses; 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. val != 0) {1060 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 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. val != 0) {1070 if ( funcSpecs.any() ) { 1071 1071 throw SemanticError( "invalid function specifier for ", this ); 1072 1072 } // if -
src/Parser/ParseNode.h
r4da6a6c r026bb82 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 14 11:05:05201713 // Update Count : 7 5212 // Last Modified On : Tue Mar 7 08:10:53 2017 13 // Update Count : 726 14 14 // 15 15 … … 204 204 // These must remain in the same order as the corresponding DeclarationNode names. 205 205 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 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 }; 234 210 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier }; 235 211 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; … … 252 228 static const char * builtinTypeNames[]; 253 229 254 static DeclarationNode * newStorageClass( StorageClass es);255 static DeclarationNode * newFuncSpecifier( FuncSpecifier s);230 static DeclarationNode * newStorageClass( StorageClass ); 231 static DeclarationNode * newFuncSpecifier( FuncSpecifier ); 256 232 static DeclarationNode * newTypeQualifier( TypeQualifier ); 257 233 static DeclarationNode * newBasicType( BasicType ); … … 350 326 TypeData * type; 351 327 328 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses; 352 329 StorageClasses storageClasses; 353 330 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 354 331 332 typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers; 355 333 FuncSpecifiers funcSpecs; 356 334 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); -
src/SymTab/Autogen.cc
r4da6a6c r026bb82 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 14 07:45:00201713 // Update Count : 5 412 // Last Modified On : Tue Mar 7 07:42:44 2017 13 // Update Count : 51 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 );164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ); 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 ) );167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ); 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 ) ) );722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 723 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 725 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 727 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) ); 729 729 typeParams.push_back( newDecl ); 730 730 done.insert( ty->get_baseType() ); -
src/SymTab/Indexer.cc
r4da6a6c r026bb82 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 14 08:07:34201713 // Update Count : 1 712 // Last Modified On : Tue Mar 7 07:45:32 2017 13 // Update Count : 16 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() .is_extern && ! oldobj->get_storageClasses().is_extern) {740 if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ] ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if
Note:
See TracChangeset
for help on using the changeset viewer.