Changeset e3bf4cf
- Timestamp:
- Oct 31, 2022, 12:16:40 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 994028dc
- Parents:
- 637c139
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/GenPoly/Box.cc ¶
r637c139 re3bf4cf 68 68 /// Adds layout-generation functions to polymorphic types. 69 69 class LayoutFunctionBuilder final : public WithDeclsToAdd, public WithVisitorRef<LayoutFunctionBuilder>, public WithShortCircuiting { 70 // Current level of nested functions:71 unsigned int functionNesting = 0;72 70 public: 73 void previsit( FunctionDecl *functionDecl );74 71 void previsit( StructDecl *structDecl ); 75 72 void previsit( UnionDecl *unionDecl ); … … 237 234 ////////////////////////////////// LayoutFunctionBuilder //////////////////////////////////////////// 238 235 239 void LayoutFunctionBuilder::previsit( FunctionDecl *functionDecl ) {240 visit_children = false;241 maybeAccept( functionDecl->get_functionType(), *visitor );242 ++functionNesting;243 maybeAccept( functionDecl->get_statements(), *visitor );244 --functionNesting;245 }246 247 236 /// Get a list of type declarations that will affect a layout function 248 237 std::list< TypeDecl* > takeOtypeOnly( std::list< TypeDecl* > &decls ) { … … 271 260 272 261 /// Builds a layout function declaration 273 FunctionDecl *buildLayoutFunctionDecl( AggregateDecl *typeDecl, unsigned int functionNesting, FunctionType *layoutFnType ) {262 FunctionDecl *buildLayoutFunctionDecl( AggregateDecl *typeDecl, bool isInFunction, FunctionType *layoutFnType ) { 274 263 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 275 264 // because each unit generates copies of the default routines for each aggregate. 276 265 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 277 functionNesting > 0? Type::StorageClasses() : Type::StorageClasses( Type::Static ),266 isInFunction ? Type::StorageClasses() : Type::StorageClasses( Type::Static ), 278 267 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt(), 279 268 std::list< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ); … … 347 336 348 337 // build function decl 349 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( structDecl, functionNesting, layoutFnType );338 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( structDecl, isInFunction(), layoutFnType ); 350 339 351 340 // calculate struct layout in function body … … 401 390 402 391 // build function decl 403 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( unionDecl, functionNesting, layoutFnType );392 FunctionDecl *layoutDecl = buildLayoutFunctionDecl( unionDecl, isInFunction(), layoutFnType ); 404 393 405 394 // calculate union layout in function body
Note: See TracChangeset
for help on using the changeset viewer.