Changeset 62e5546
- Timestamp:
- Oct 27, 2016, 4:22:27 PM (9 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:
- 0ebac75
- Parents:
- d93d980
- Location:
- src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelFixer.h
rd93d980 r62e5546 26 26 namespace ControlStruct { 27 27 /// normalizes label definitions and generates multi-level exit labels 28 class LabelFixer : public Visitor {28 class LabelFixer final : public Visitor { 29 29 typedef Visitor Parent; 30 30 public: … … 33 33 std::map < Label, Statement * > *resolveJumps() throw ( SemanticError ); 34 34 35 using Visitor::visit; 36 35 37 // Declarations 36 virtual void visit( FunctionDecl *functionDecl ) ;38 virtual void visit( FunctionDecl *functionDecl ) override; 37 39 38 40 // Statements 39 41 void visit( Statement *stmt ); 40 42 41 virtual void visit( CompoundStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }42 virtual void visit( NullStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }43 virtual void visit( ExprStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }44 virtual void visit( IfStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }45 virtual void visit( WhileStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }46 virtual void visit( ForStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }47 virtual void visit( SwitchStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }48 virtual void visit( CaseStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }49 virtual void visit( ReturnStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }50 virtual void visit( TryStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }51 virtual void visit( CatchStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }52 virtual void visit( DeclStmt *stmt ) { visit( (Statement *)stmt ); return Parent::visit( stmt ); }53 virtual void visit( BranchStmt *branchStmt ) ;54 virtual void visit( UntypedExpr *untyped ) ;43 virtual void visit( CompoundStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 44 virtual void visit( NullStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 45 virtual void visit( ExprStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 46 virtual void visit( IfStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 47 virtual void visit( WhileStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 48 virtual void visit( ForStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 49 virtual void visit( SwitchStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 50 virtual void visit( CaseStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 51 virtual void visit( ReturnStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 52 virtual void visit( TryStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 53 virtual void visit( CatchStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 54 virtual void visit( DeclStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); } 55 virtual void visit( BranchStmt *branchStmt ) override; 56 virtual void visit( UntypedExpr *untyped ) override; 55 57 56 58 Label setLabelsDef( std::list< Label > &, Statement *definition ); -
src/ControlStruct/LabelTypeChecker.cc
rd93d980 r62e5546 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // LabelTypeChecker.cc -- 7 // LabelTypeChecker.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 28 28 assert( untypedExpr != 0 ); 29 29 NameExpr *fname; 30 if ( ((fname = dynamic_cast<NameExpr *>(untypedExpr->get_function())) != 0) 30 if ( ((fname = dynamic_cast<NameExpr *>(untypedExpr->get_function())) != 0) 31 31 && fname->get_name() == std::string("&&") ) 32 32 std::cerr << "Taking the label of an address." << std::endl; … … 58 58 59 59 NameExpr *name; 60 if ( ( (name = dynamic_cast<NameExpr *>(target)) == 0))60 if ( (name = dynamic_cast<NameExpr *>(target)) == 0 ) 61 61 return; // Not a name expression 62 62 63 63 std::list< DeclarationWithType * > interps; 64 64 index.lookupId(name->get_name(), interps); -
src/GenPoly/Box.cc
rd93d980 r62e5546 64 64 65 65 /// Adds layout-generation functions to polymorphic types 66 class LayoutFunctionBuilder : public DeclMutator {66 class LayoutFunctionBuilder final : public DeclMutator { 67 67 unsigned int functionNesting; // current level of nested functions 68 68 public: 69 69 LayoutFunctionBuilder() : functionNesting( 0 ) {} 70 70 71 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 72 virtual Declaration *mutate( StructDecl *structDecl ); 73 virtual Declaration *mutate( UnionDecl *unionDecl ); 71 using DeclMutator::mutate; 72 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 73 virtual Declaration *mutate( StructDecl *structDecl ) override; 74 virtual Declaration *mutate( UnionDecl *unionDecl ) override; 74 75 }; 75 76 76 77 /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call 77 class Pass1 : public PolyMutator {78 class Pass1 final : public PolyMutator { 78 79 public: 79 80 Pass1(); 80 virtual Expression *mutate( ApplicationExpr *appExpr ); 81 virtual Expression *mutate( AddressExpr *addrExpr ); 82 virtual Expression *mutate( UntypedExpr *expr ); 83 virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ); 84 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 85 virtual Expression *mutate( CommaExpr *commaExpr ); 86 virtual Expression *mutate( ConditionalExpr *condExpr ); 87 virtual Statement * mutate( ReturnStmt *returnStmt ); 88 virtual Type *mutate( PointerType *pointerType ); 89 virtual Type * mutate( FunctionType *functionType ); 90 91 virtual void doBeginScope(); 92 virtual void doEndScope(); 81 82 using PolyMutator::mutate; 83 virtual Expression *mutate( ApplicationExpr *appExpr ) override; 84 virtual Expression *mutate( AddressExpr *addrExpr ) override; 85 virtual Expression *mutate( UntypedExpr *expr ) override; 86 virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ) override; 87 virtual TypeDecl *mutate( TypeDecl *typeDecl ) override; 88 virtual Expression *mutate( CommaExpr *commaExpr ) override; 89 virtual Expression *mutate( ConditionalExpr *condExpr ) override; 90 virtual Statement * mutate( ReturnStmt *returnStmt ) override; 91 virtual Type *mutate( PointerType *pointerType ) override; 92 virtual Type * mutate( FunctionType *functionType ) override; 93 94 virtual void doBeginScope() override; 95 virtual void doEndScope() override; 93 96 private: 94 97 /// Pass the extra type parameters from polymorphic generic arguments or return types into a function application … … 135 138 /// * Moves polymorphic returns in function types to pointer-type parameters 136 139 /// * adds type size and assertion parameters to parameter lists 137 class Pass2 : public PolyMutator {140 class Pass2 final : public PolyMutator { 138 141 public: 139 142 template< typename DeclClass > 140 143 DeclClass *handleDecl( DeclClass *decl, Type *type ); 141 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 142 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ); 143 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 144 virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ); 145 virtual Type *mutate( PointerType *pointerType ); 146 virtual Type *mutate( FunctionType *funcType ); 144 145 using PolyMutator::mutate; 146 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 147 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 148 virtual TypeDecl *mutate( TypeDecl *typeDecl ) override; 149 virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override; 150 virtual Type *mutate( PointerType *pointerType ) override; 151 virtual Type *mutate( FunctionType *funcType ) override; 147 152 148 153 private: … … 156 161 /// * Calculates polymorphic offsetof expressions from offset array 157 162 /// * Inserts dynamic calculation of polymorphic type layouts where needed 158 class PolyGenericCalculator : public PolyMutator {163 class PolyGenericCalculator final : public PolyMutator { 159 164 public: 160 165 typedef PolyMutator Parent; … … 163 168 template< typename DeclClass > 164 169 DeclClass *handleDecl( DeclClass *decl, Type *type ); 165 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) ;166 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) ;167 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) ;168 virtual TypeDecl *mutate( TypeDecl *objectDecl ) ;169 virtual Statement *mutate( DeclStmt *declStmt ) ;170 virtual Type *mutate( PointerType *pointerType ) ;171 virtual Type *mutate( FunctionType *funcType ) ;172 virtual Expression *mutate( MemberExpr *memberExpr ) ;173 virtual Expression *mutate( SizeofExpr *sizeofExpr ) ;174 virtual Expression *mutate( AlignofExpr *alignofExpr ) ;175 virtual Expression *mutate( OffsetofExpr *offsetofExpr ) ;176 virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ) ;177 178 virtual void doBeginScope() ;179 virtual void doEndScope() ;170 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 171 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 172 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; 173 virtual TypeDecl *mutate( TypeDecl *objectDecl ) override; 174 virtual Statement *mutate( DeclStmt *declStmt ) override; 175 virtual Type *mutate( PointerType *pointerType ) override; 176 virtual Type *mutate( FunctionType *funcType ) override; 177 virtual Expression *mutate( MemberExpr *memberExpr ) override; 178 virtual Expression *mutate( SizeofExpr *sizeofExpr ) override; 179 virtual Expression *mutate( AlignofExpr *alignofExpr ) override; 180 virtual Expression *mutate( OffsetofExpr *offsetofExpr ) override; 181 virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ) override; 182 183 virtual void doBeginScope() override; 184 virtual void doEndScope() override; 180 185 181 186 private: … … 197 202 198 203 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable 199 class Pass3 : public PolyMutator {204 class Pass3 final : public PolyMutator { 200 205 public: 201 206 template< typename DeclClass > 202 207 DeclClass *handleDecl( DeclClass *decl, Type *type ); 203 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 204 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ); 205 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ); 206 virtual TypeDecl *mutate( TypeDecl *objectDecl ); 207 virtual Type *mutate( PointerType *pointerType ); 208 virtual Type *mutate( FunctionType *funcType ); 208 209 using PolyMutator::mutate; 210 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 211 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 212 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; 213 virtual TypeDecl *mutate( TypeDecl *objectDecl ) override; 214 virtual Type *mutate( PointerType *pointerType ) override; 215 virtual Type *mutate( FunctionType *funcType ) override; 209 216 private: 210 217 }; -
src/GenPoly/InstantiateGeneric.cc
rd93d980 r62e5546 147 147 148 148 /// Mutator pass that replaces concrete instantiations of generic types with actual struct declarations, scoped appropriately 149 class GenericInstantiator : public DeclMutator {149 class GenericInstantiator final : public DeclMutator { 150 150 /// Map of (generic type, parameter list) pairs to concrete type instantiations 151 151 InstantiationMap< AggregateDecl, AggregateDecl > instantiations; … … 158 158 GenericInstantiator() : DeclMutator(), instantiations(), dtypeStatics(), typeNamer("_conc_") {} 159 159 160 virtual Type* mutate( StructInstType *inst ); 161 virtual Type* mutate( UnionInstType *inst ); 162 163 virtual void doBeginScope(); 164 virtual void doEndScope(); 160 using DeclMutator::mutate; 161 virtual Type* mutate( StructInstType *inst ) override; 162 virtual Type* mutate( UnionInstType *inst ) override; 163 164 virtual void doBeginScope() override; 165 virtual void doEndScope() override; 165 166 private: 166 167 /// Wrap instantiation lookup for structs -
src/GenPoly/Specialize.cc
rd93d980 r62e5546 36 36 const std::list<Label> noLabels; 37 37 38 class Specialize : public PolyMutator {38 class Specialize final : public PolyMutator { 39 39 public: 40 40 Specialize( std::string paramPrefix = "_p" ); 41 41 42 virtual Expression * mutate( ApplicationExpr *applicationExpr ); 43 virtual Expression * mutate( AddressExpr *castExpr ); 44 virtual Expression * mutate( CastExpr *castExpr ); 42 using PolyMutator::mutate; 43 virtual Expression * mutate( ApplicationExpr *applicationExpr ) override; 44 virtual Expression * mutate( AddressExpr *castExpr ) override; 45 virtual Expression * mutate( CastExpr *castExpr ) override; 45 46 // virtual Expression * mutate( LogicalExpr *logicalExpr ); 46 47 // virtual Expression * mutate( ConditionalExpr *conditionalExpr ); -
src/InitTweak/FixInit.cc
rd93d980 r62e5546 50 50 const std::list<Expression*> noDesignators; 51 51 52 class InsertImplicitCalls : public GenPoly::PolyMutator {52 class InsertImplicitCalls final : public GenPoly::PolyMutator { 53 53 public: 54 54 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 56 56 static void insert( std::list< Declaration * > & translationUnit ); 57 57 58 virtual Expression * mutate( ApplicationExpr * appExpr ); 59 }; 60 61 class ResolveCopyCtors : public SymTab::Indexer { 58 using GenPoly::PolyMutator::mutate; 59 virtual Expression * mutate( ApplicationExpr * appExpr ) override; 60 }; 61 62 class ResolveCopyCtors final : public SymTab::Indexer { 62 63 public: 63 64 /// generate temporary ObjectDecls for each argument and return value of each ImplicitCopyCtorExpr, … … 66 67 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit ); 67 68 68 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 69 using SymTab::Indexer::visit; 70 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 69 71 70 72 /// create and resolve ctor/dtor expression: fname(var, [cpArg]) … … 82 84 using Parent::visit; 83 85 typedef std::set< ObjectDecl * > ObjectSet; 84 virtual void visit( CompoundStmt *compoundStmt ) ;85 virtual void visit( DeclStmt *stmt ) ;86 virtual void visit( CompoundStmt *compoundStmt ) override; 87 virtual void visit( DeclStmt *stmt ) override; 86 88 protected: 87 89 ObjectSet curVars; … … 103 105 } 104 106 105 class LabelFinder : public ObjDeclCollector {107 class LabelFinder final : public ObjDeclCollector { 106 108 public: 107 109 typedef ObjDeclCollector Parent; … … 117 119 // subclasses are added, there is only one place that the code has to be updated, rather than ensure that 118 120 // every specialized class knows about every new kind of statement that might be added. 119 virtual void visit( CompoundStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 120 virtual void visit( ExprStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 121 virtual void visit( AsmStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 122 virtual void visit( IfStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 123 virtual void visit( WhileStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 124 virtual void visit( ForStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 125 virtual void visit( SwitchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 126 virtual void visit( CaseStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 127 virtual void visit( BranchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 128 virtual void visit( ReturnStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 129 virtual void visit( TryStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 130 virtual void visit( CatchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 131 virtual void visit( FinallyStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 132 virtual void visit( NullStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 133 virtual void visit( DeclStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 134 virtual void visit( ImplicitCtorDtorStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 135 }; 136 137 class InsertDtors : public ObjDeclCollector { 121 using Parent::visit; 122 virtual void visit( CompoundStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 123 virtual void visit( ExprStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 124 virtual void visit( AsmStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 125 virtual void visit( IfStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 126 virtual void visit( WhileStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 127 virtual void visit( ForStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 128 virtual void visit( SwitchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 129 virtual void visit( CaseStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 130 virtual void visit( BranchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 131 virtual void visit( ReturnStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 132 virtual void visit( TryStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 133 virtual void visit( CatchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 134 virtual void visit( FinallyStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 135 virtual void visit( NullStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 136 virtual void visit( DeclStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 137 virtual void visit( ImplicitCtorDtorStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 138 }; 139 140 class InsertDtors final : public ObjDeclCollector { 138 141 public: 139 142 /// insert destructor calls at the appropriate places. must happen before CtorInit nodes are removed … … 147 150 InsertDtors( LabelFinder & finder ) : labelVars( finder.vars ) {} 148 151 149 virtual void visit( ObjectDecl * objDecl ); 150 151 virtual void visit( CompoundStmt * compoundStmt ); 152 virtual void visit( ReturnStmt * returnStmt ); 153 virtual void visit( BranchStmt * stmt ); 152 using Parent::visit; 153 154 virtual void visit( ObjectDecl * objDecl ) override; 155 156 virtual void visit( CompoundStmt * compoundStmt ) override; 157 virtual void visit( ReturnStmt * returnStmt ) override; 158 virtual void visit( BranchStmt * stmt ) override; 154 159 private: 155 160 void handleGoto( BranchStmt * stmt ); … … 159 164 }; 160 165 161 class FixInit : public GenPoly::PolyMutator {166 class FixInit final : public GenPoly::PolyMutator { 162 167 public: 163 168 /// expand each object declaration to use its constructor after it is declared. 164 169 static void fixInitializers( std::list< Declaration * > &translationUnit ); 165 170 166 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ); 171 using GenPoly::PolyMutator::mutate; 172 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 167 173 168 174 std::list< Declaration * > staticDtorDecls; 169 175 }; 170 176 171 class FixCopyCtors : public GenPoly::PolyMutator {177 class FixCopyCtors final : public GenPoly::PolyMutator { 172 178 public: 173 179 /// expand ImplicitCopyCtorExpr nodes into the temporary declarations, copy constructors, call expression, … … 175 181 static void fixCopyCtors( std::list< Declaration * > &translationUnit ); 176 182 177 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ); 178 }; 179 180 class GenStructMemberCalls : public SymTab::Indexer { 183 using GenPoly::PolyMutator::mutate; 184 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 185 }; 186 187 class GenStructMemberCalls final : public SymTab::Indexer { 181 188 public: 182 189 typedef Indexer Parent; … … 186 193 static void generate( std::list< Declaration * > & translationUnit ); 187 194 188 virtual void visit( FunctionDecl * funcDecl ); 189 190 virtual void visit( MemberExpr * memberExpr ); 191 virtual void visit( ApplicationExpr * appExpr ); 195 using Parent::visit; 196 197 virtual void visit( FunctionDecl * funcDecl ) override; 198 199 virtual void visit( MemberExpr * memberExpr ) override; 200 virtual void visit( ApplicationExpr * appExpr ) override; 192 201 193 202 SemanticError errors; … … 207 216 // resolve UntypedExprs that are found within newly 208 217 // generated constructor/destructor calls 209 class MutatingResolver : public Mutator {218 class MutatingResolver final : public Mutator { 210 219 public: 211 220 MutatingResolver( SymTab::Indexer & indexer ) : indexer( indexer ) {} 212 221 213 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ); 214 215 virtual Expression* mutate( UntypedExpr *untypedExpr ); 216 private: 222 using Mutator::mutate; 223 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ) override; 224 virtual Expression* mutate( UntypedExpr *untypedExpr ) override; 225 226 private: 217 227 SymTab::Indexer & indexer; 218 228 }; 219 229 220 class FixCtorExprs : public GenPoly::DeclMutator {230 class FixCtorExprs final : public GenPoly::DeclMutator { 221 231 public: 222 232 /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument 223 233 static void fix( std::list< Declaration * > & translationUnit ); 224 234 225 virtual Expression * mutate( ConstructorExpr * ctorExpr ); 235 using GenPoly::DeclMutator::mutate; 236 virtual Expression * mutate( ConstructorExpr * ctorExpr ) override; 226 237 }; 227 238 } // namespace -
src/InitTweak/GenInit.cc
rd93d980 r62e5546 36 36 } 37 37 38 class ReturnFixer : public GenPoly::PolyMutator {38 class ReturnFixer final : public GenPoly::PolyMutator { 39 39 public: 40 40 /// consistently allocates a temporary variable for the return value … … 45 45 ReturnFixer(); 46 46 47 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );48 49 virtual Statement * mutate( ReturnStmt * returnStmt ) ;47 using GenPoly::PolyMutator::mutate; 48 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 49 virtual Statement * mutate( ReturnStmt * returnStmt ) override; 50 50 51 51 protected: … … 55 55 }; 56 56 57 class CtorDtor : public GenPoly::PolyMutator {57 class CtorDtor final : public GenPoly::PolyMutator { 58 58 public: 59 59 typedef GenPoly::PolyMutator Parent; … … 65 65 static void generateCtorDtor( std::list< Declaration * > &translationUnit ); 66 66 67 virtual DeclarationWithType * mutate( ObjectDecl * ) ;68 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) ;67 virtual DeclarationWithType * mutate( ObjectDecl * ) override; 68 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 69 69 // should not traverse into any of these declarations to find objects 70 70 // that need to be constructed or destructed 71 virtual Declaration* mutate( StructDecl *aggregateDecl ) ;72 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }73 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }74 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }75 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; }76 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; }77 78 virtual Type * mutate( FunctionType *funcType ) { return funcType; }79 80 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) ;71 virtual Declaration* mutate( StructDecl *aggregateDecl ) override; 72 virtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; } 73 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; } 74 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; } 75 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; } 76 virtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; } 77 78 virtual Type * mutate( FunctionType *funcType ) override { return funcType; } 79 80 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override; 81 81 82 82 private: … … 91 91 }; 92 92 93 class HoistArrayDimension : public GenPoly::DeclMutator {93 class HoistArrayDimension final : public GenPoly::DeclMutator { 94 94 public: 95 95 typedef GenPoly::DeclMutator Parent; … … 101 101 102 102 private: 103 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ); 104 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 103 using Parent::mutate; 104 105 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override; 106 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 105 107 // should not traverse into any of these declarations to find objects 106 108 // that need to be constructed or destructed 107 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }108 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }109 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }110 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }111 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; }112 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; }113 114 virtual Type* mutate( FunctionType *funcType ) { return funcType; }109 virtual Declaration* mutate( StructDecl *aggregateDecl ) override { return aggregateDecl; } 110 virtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; } 111 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; } 112 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; } 113 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; } 114 virtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; } 115 116 virtual Type* mutate( FunctionType *funcType ) override { return funcType; } 115 117 116 118 void hoist( Type * type ); -
src/InitTweak/InitTweak.h
rd93d980 r62e5546 100 100 101 101 class ExpanderImpl; 102 typedef std::list< Expression * > IndexList; 102 103 private: 103 104 std::shared_ptr< ExpanderImpl > expander; … … 105 106 106 107 // invariant: list of size 2N (elements come in pairs [index, dimension]) 107 typedef std::list< Expression * > IndexList;108 108 IndexList indices; 109 109 }; -
src/Parser/ParseNode.h
rd93d980 r62e5546 109 109 ExpressionNode * set_extension( bool exten ) { extension = exten; return this; } 110 110 111 v oid print( std::ostream &os, int indent = 0 ) const{}111 virtual void print( std::ostream &os, int indent = 0 ) const override {} 112 112 void printOneLine( std::ostream &os, int indent = 0 ) const {} 113 113 … … 187 187 //############################################################################## 188 188 189 classTypeData;189 struct TypeData; 190 190 191 191 class DeclarationNode : public ParseNode { … … 271 271 } 272 272 273 v oid print( std::ostream &os, int indent = 0 ) const;274 v oid printList( std::ostream &os, int indent = 0 ) const;273 virtual void print( std::ostream &os, int indent = 0 ) const override; 274 virtual void printList( std::ostream &os, int indent = 0 ) const override; 275 275 276 276 Declaration * build() const; … … 345 345 virtual StatementNode * append_last_case( StatementNode * ); 346 346 347 virtual void print( std::ostream &os, int indent = 0 ) {}348 virtual void printList( std::ostream &os, int indent = 0 ) {}347 virtual void print( std::ostream &os, int indent = 0 ) const override {} 348 virtual void printList( std::ostream &os, int indent = 0 ) const override {} 349 349 private: 350 350 std::unique_ptr<Statement> stmt; -
src/ResolvExpr/AlternativePrinter.h
rd93d980 r62e5546 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativePrinter.h -- 7 // AlternativePrinter.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 23 23 24 24 namespace ResolvExpr { 25 class AlternativePrinter : public SymTab::Indexer {25 class AlternativePrinter final : public SymTab::Indexer { 26 26 public: 27 27 AlternativePrinter( std::ostream &os ); 28 virtual void visit( ExprStmt *exprStmt ); 28 29 using SymTab::Indexer::visit; 30 virtual void visit( ExprStmt *exprStmt ) override; 29 31 private: 30 32 std::ostream &os; -
src/ResolvExpr/Resolver.cc
rd93d980 r62e5546 32 32 33 33 namespace ResolvExpr { 34 class Resolver : public SymTab::Indexer {34 class Resolver final : public SymTab::Indexer { 35 35 public: 36 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 37 38 virtual void visit( FunctionDecl *functionDecl ); 39 virtual void visit( ObjectDecl *functionDecl ); 40 virtual void visit( TypeDecl *typeDecl ); 41 virtual void visit( EnumDecl * enumDecl ); 42 43 virtual void visit( ArrayType * at ); 44 virtual void visit( PointerType * at ); 45 46 virtual void visit( ExprStmt *exprStmt ); 47 virtual void visit( AsmExpr *asmExpr ); 48 virtual void visit( AsmStmt *asmStmt ); 49 virtual void visit( IfStmt *ifStmt ); 50 virtual void visit( WhileStmt *whileStmt ); 51 virtual void visit( ForStmt *forStmt ); 52 virtual void visit( SwitchStmt *switchStmt ); 53 virtual void visit( CaseStmt *caseStmt ); 54 virtual void visit( BranchStmt *branchStmt ); 55 virtual void visit( ReturnStmt *returnStmt ); 56 57 virtual void visit( SingleInit *singleInit ); 58 virtual void visit( ListInit *listInit ); 59 virtual void visit( ConstructorInit *ctorInit ); 36 Resolver() : SymTab::Indexer( false ) {} 37 38 using SymTab::Indexer::visit; 39 virtual void visit( FunctionDecl *functionDecl ) override; 40 virtual void visit( ObjectDecl *functionDecl ) override; 41 virtual void visit( TypeDecl *typeDecl ) override; 42 virtual void visit( EnumDecl * enumDecl ) override; 43 44 virtual void visit( ArrayType * at ) override; 45 virtual void visit( PointerType * at ) override; 46 47 virtual void visit( ExprStmt *exprStmt ) override; 48 virtual void visit( AsmExpr *asmExpr ) override; 49 virtual void visit( AsmStmt *asmStmt ) override; 50 virtual void visit( IfStmt *ifStmt ) override; 51 virtual void visit( WhileStmt *whileStmt ) override; 52 virtual void visit( ForStmt *forStmt ) override; 53 virtual void visit( SwitchStmt *switchStmt ) override; 54 virtual void visit( CaseStmt *caseStmt ) override; 55 virtual void visit( BranchStmt *branchStmt ) override; 56 virtual void visit( ReturnStmt *returnStmt ) override; 57 58 virtual void visit( SingleInit *singleInit ) override; 59 virtual void visit( ListInit *listInit ) override; 60 virtual void visit( ConstructorInit *ctorInit ) override; 60 61 private: 61 62 typedef std::list< Initializer * >::iterator InitIterator; … … 69 70 std::list< Type * > functionReturn; 70 71 Type *initContext; 71 Type *switchType;72 72 bool inEnumDecl = false; 73 73 }; -
src/ResolvExpr/TypeMap.h
rd93d980 r62e5546 38 38 typedef typename std::map< std::string, Value* > ValueMap; 39 39 typedef typename ValueMap::iterator ValueMapIterator; 40 40 41 41 Value *voidValue; ///< Value for void type 42 42 Value *basicValue[BasicType::NUMBER_OF_BASIC_TYPES]; ///< Values for basic types … … 54 54 /// One scope of map rollbacks 55 55 typedef std::vector< std::pair< ValueMapIterator, Value* > > MapScope; 56 56 57 57 PointerScope pointers; ///< Value pointers to roll back to their previous state 58 58 MapScope mapNodes; ///< Value map iterators to roll back to their previous state … … 68 68 69 69 std::vector< Rollback > scopes; ///< Scope rollback information 70 70 71 71 struct Lookup : public Visitor { 72 72 Lookup( TypeMap<Value> &typeMap ) : typeMap( typeMap ), found( 0 ), toInsert( 0 ) {} … … 87 87 return found; 88 88 } 89 89 90 90 void findAndReplace( Value *&loc ) { 91 91 found = loc; … … 109 109 } 110 110 } 111 111 112 112 virtual void visit( VoidType *voidType ) { 113 113 findAndReplace( typeMap.voidValue ); 114 114 } 115 115 116 116 virtual void visit( BasicType *basicType ) { 117 117 findAndReplace( typeMap.basicValue[basicType->get_kind()] ); 118 118 } 119 119 120 120 virtual void visit( PointerType *pointerType ) { 121 121 // NOTE This is one of the places where the apporoximation of the resolver is (deliberately) poor; … … 129 129 } 130 130 } 131 131 132 132 virtual void visit( ArrayType *arrayType ) { 133 133 if ( dynamic_cast< FunctionType* >( arrayType->get_base() ) ) { … … 137 137 } 138 138 } 139 139 140 140 virtual void visit( FunctionType *functionType ) { 141 141 findAndReplace( typeMap.functionPointerValue ); 142 142 } 143 143 144 144 virtual void visit( StructInstType *structType ) { 145 145 findAndReplace( typeMap.structValue, structType->get_name() ); 146 146 } 147 147 148 148 virtual void visit( UnionInstType *unionType ) { 149 149 findAndReplace( typeMap.unionValue, unionType->get_name() ); 150 150 } 151 151 152 152 virtual void visit( EnumInstType *enumType ) { 153 153 findAndReplace( typeMap.enumValue, enumType->get_name() ); … … 157 157 Value *found; ///< Value found (NULL if none yet) 158 158 Value *toInsert; ///< Value to insert (NULL if a lookup) 159 }; // classLookup160 friend classLookup;161 159 }; // struct Lookup 160 friend struct Lookup; 161 162 162 public: 163 163 /// Starts a new scope … … 180 180 scopes.pop_back(); 181 181 } 182 182 183 183 TypeMap() : voidValue( 0 ), pointerValue( 0 ), voidPointerValue( 0 ), functionPointerValue( 0 ), structValue(), unionValue(), enumValue(), scopes() { 184 184 beginScope(); … … 199 199 return searcher.find( key ); 200 200 } 201 201 202 202 }; // class TypeMap 203 203 -
src/ResolvExpr/Unify.cc
rd93d980 r62e5546 73 73 const OpenVarSet &openVars; 74 74 WidenMode widenMode; 75 Type *commonType;76 75 const SymTab::Indexer &indexer; 77 76 }; -
src/SymTab/Validate.cc
rd93d980 r62e5546 94 94 95 95 /// Associates forward declarations of aggregates with their definitions 96 class Pass2 : public Indexer {96 class Pass2 final : public Indexer { 97 97 typedef Indexer Parent; 98 98 public: 99 99 Pass2( bool doDebug, const Indexer *indexer ); 100 100 private: 101 virtual void visit( StructInstType *structInst ); 102 virtual void visit( UnionInstType *unionInst ); 103 virtual void visit( TraitInstType *contextInst ); 104 virtual void visit( StructDecl *structDecl ); 105 virtual void visit( UnionDecl *unionDecl ); 106 virtual void visit( TypeInstType *typeInst ); 101 using Indexer::visit; 102 void visit( StructInstType *structInst ) final; 103 void visit( UnionInstType *unionInst ) final; 104 void visit( TraitInstType *contextInst ) final; 105 void visit( StructDecl *structDecl ) final; 106 void visit( UnionDecl *unionDecl ) final; 107 void visit( TypeInstType *typeInst ) final; 107 108 108 109 const Indexer *indexer; … … 182 183 }; 183 184 184 class CompoundLiteral : public GenPoly::DeclMutator {185 class CompoundLiteral final : public GenPoly::DeclMutator { 185 186 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass; 186 187 187 virtual DeclarationWithType * mutate( ObjectDecl *objectDecl ); 188 virtual Expression *mutate( CompoundLiteralExpr *compLitExpr ); 188 using GenPoly::DeclMutator::mutate; 189 DeclarationWithType * mutate( ObjectDecl *objectDecl ) final; 190 Expression *mutate( CompoundLiteralExpr *compLitExpr ) final; 189 191 }; 190 192 … … 652 654 void EliminateTypedef::addImplicitTypedef( AggDecl * aggDecl ) { 653 655 if ( typedefNames.count( aggDecl->get_name() ) == 0 ) { 654 Type *type ;656 Type *type = nullptr; 655 657 if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( aggDecl ) ) { 656 658 type = new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ); -
src/Tuples/TupleAssignment.cc
rd93d980 r62e5546 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleAssignment.cc -- 7 // TupleAssignment.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 29 29 30 30 namespace Tuples { 31 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f = 0)31 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f ) 32 32 : currentFinder(f), matcher(0), hasMatched( false ) {} 33 33 -
src/Tuples/TupleAssignment.h
rd93d980 r62e5546 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleAssignment.h -- 7 // TupleAssignment.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 29 29 public: 30 30 // dispatcher for Tuple (multiple and mass) assignment operations 31 TupleAssignSpotter( ResolvExpr::AlternativeFinder * );31 TupleAssignSpotter( ResolvExpr::AlternativeFinder * = 0 ); 32 32 ~TupleAssignSpotter() { delete matcher; matcher = 0; } 33 33 … … 97 97 ResolvExpr::AlternativeFinder *currentFinder; 98 98 //std::list<Expression *> rhs, lhs; 99 Expression *rhs, *lhs;99 // Expression *rhs, *lhs; 100 100 Matcher *matcher; 101 101 bool hasMatched;
Note: See TracChangeset
for help on using the changeset viewer.