Changes in src/SymTab/Validate.cc [d24d4e1:06edda0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rd24d4e1 r06edda0 106 106 107 107 /// Fix return types so that every function returns exactly one value 108 struct ReturnTypeFixer { 108 class ReturnTypeFixer { 109 public: 109 110 static void fix( std::list< Declaration * > &translationUnit ); 110 111 … … 114 115 115 116 /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers. 116 struct EnumAndPointerDecay { 117 class EnumAndPointerDecay { 118 public: 117 119 void previsit( EnumDecl *aggregateDecl ); 118 120 void previsit( FunctionType *func ); … … 157 159 }; 158 160 159 struct ReturnChecker : public WithGuards { 161 class ReturnChecker : public WithScopes { 162 public: 160 163 /// Checks that return statements return nothing if their return type is void 161 164 /// and return something if the return type is non-void. 162 165 static void checkFunctionReturns( std::list< Declaration * > & translationUnit ); 163 166 private: 164 167 void previsit( FunctionDecl * functionDecl ); 165 168 void previsit( ReturnStmt * returnStmt ); … … 202 205 }; 203 206 204 struct VerifyCtorDtorAssign { 207 class VerifyCtorDtorAssign { 208 public: 205 209 /// ensure that constructors, destructors, and assignment have at least one 206 210 /// parameter, the first of which must be a pointer, and that ctor/dtors have no … … 212 216 213 217 /// ensure that generic types have the correct number of type arguments 214 struct ValidateGenericParameters { 218 class ValidateGenericParameters { 219 public: 215 220 void previsit( StructInstType * inst ); 216 221 void previsit( UnionInstType * inst ); 217 222 }; 218 223 219 struct ArrayLength { 224 class ArrayLength { 225 public: 220 226 /// for array types without an explicit length, compute the length and store it so that it 221 227 /// is known to the rest of the phases. For example, … … 230 236 }; 231 237 232 struct CompoundLiteral final : public WithDeclsToAdd, public WithVisitorRef<CompoundLiteral>{238 class CompoundLiteral final : public GenPoly::DeclMutator { 233 239 Type::StorageClasses storageClasses; 234 240 235 void premutate( ObjectDecl *objectDecl ); 236 Expression * postmutate( CompoundLiteralExpr *compLitExpr ); 241 using GenPoly::DeclMutator::mutate; 242 DeclarationWithType * mutate( ObjectDecl *objectDecl ) final; 243 Expression *mutate( CompoundLiteralExpr *compLitExpr ) final; 237 244 }; 238 245 … … 241 248 LinkReferenceToTypes lrt( doDebug, 0 ); 242 249 ForallPointerDecay fpd( 0 ); 243 PassVisitor<CompoundLiteral>compoundliteral;250 CompoundLiteral compoundliteral; 244 251 PassVisitor<ValidateGenericParameters> genericParams; 245 252 … … 256 263 Concurrency::implementThreadStarter( translationUnit ); 257 264 ReturnChecker::checkFunctionReturns( translationUnit ); 258 mutateAll( translationUnit, compoundliteral);265 compoundliteral.mutateDeclarationList( translationUnit ); 259 266 acceptAll( translationUnit, fpd ); 260 267 ArrayLength::computeLength( translationUnit ); … … 876 883 } 877 884 878 void CompoundLiteral::premutate( ObjectDecl *objectDecl ) {885 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 879 886 storageClasses = objectDecl->get_storageClasses(); 880 } 881 882 Expression *CompoundLiteral::postmutate( CompoundLiteralExpr *compLitExpr ) { 887 DeclarationWithType * temp = Mutator::mutate( objectDecl ); 888 return temp; 889 } 890 891 Expression *CompoundLiteral::mutate( CompoundLiteralExpr *compLitExpr ) { 883 892 // transform [storage_class] ... (struct S){ 3, ... }; 884 893 // into [storage_class] struct S temp = { 3, ... }; 885 894 static UniqueName indexName( "_compLit" ); 886 895 887 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() );888 compLitExpr->set_result( nullptr);889 compLitExpr->set_initializer( nullptr);896 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_result(), compLitExpr->get_initializer() ); 897 compLitExpr->set_result( 0 ); 898 compLitExpr->set_initializer( 0 ); 890 899 delete compLitExpr; 891 declsToAddBefore.push_back( tempvar ); // add modified temporary to current block 892 return new VariableExpr( tempvar ); 900 DeclarationWithType * newtempvar = mutate( tempvar ); 901 addDeclaration( newtempvar ); // add modified temporary to current block 902 return new VariableExpr( newtempvar ); 893 903 } 894 904
Note:
See TracChangeset
for help on using the changeset viewer.