Changeset 1931bb0
- Timestamp:
- Jul 12, 2022, 3:21:18 PM (15 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- b9f8274
- Parents:
- 9c6443e
- Location:
- src
- Files:
-
- 10 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r9c6443e r1931bb0 168 168 auto attr = get<Attribute>().acceptL( node->attributes ); 169 169 170 // This field can be unset very early on (Pre-FixReturnTypes). 171 auto newType = (type) ? type->clone() : nullptr; 172 170 173 auto decl = new ObjectDecl( 171 174 node->name, … … 173 176 LinkageSpec::Spec( node->linkage.val ), 174 177 bfwd, 175 type->clone(),178 newType, 176 179 nullptr, // prevent infinite loop 177 180 attr, … … 1579 1582 1580 1583 virtual void visit( const ObjectDecl * old ) override final { 1584 if ( inCache( old ) ) { 1585 return; 1586 } 1581 1587 auto&& type = GET_ACCEPT_1(type, Type); 1582 1588 auto&& init = GET_ACCEPT_1(init, Init); 1583 1589 auto&& bfwd = GET_ACCEPT_1(bitfieldWidth, Expr); 1584 1590 auto&& attr = GET_ACCEPT_V(attributes, Attribute); 1585 if ( inCache( old ) ) { 1586 return; 1587 } 1591 1588 1592 auto decl = new ast::ObjectDecl( 1589 1593 old->location, -
src/AST/Decl.hpp
r9c6443e r1931bb0 315 315 316 316 EnumDecl( const CodeLocation& loc, const std::string& name, 317 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, Type * base = nullptr,317 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, Type const * base = nullptr, 318 318 std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() ) 319 319 : AggregateDecl( loc, name, std::move(attrs), linkage ), base(base), enumValues(enumValues) {} -
src/CodeGen/CodeGenerator.cc
r9c6443e r1931bb0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 20:30:30 202213 // Update Count : 54 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 29 14:34:00 2022 13 // Update Count : 542 14 14 // 15 15 #include "CodeGenerator.h" … … 18 18 #include <list> // for _List_iterator, list, list<>::it... 19 19 20 #include "AST/Decl.hpp" // for DeclWithType 20 21 #include "Common/UniqueName.h" // for UniqueName 21 22 #include "Common/utility.h" // for CodeLocation, toString … … 1238 1239 } // if 1239 1240 } 1241 1242 std::string genName( ast::DeclWithType const * decl ) { 1243 if ( const OperatorInfo * opInfo = operatorLookup( decl->name ) ) { 1244 return opInfo->outputName; 1245 } else { 1246 return decl->name; 1247 } 1248 } 1249 1240 1250 } // namespace CodeGen 1241 1251 -
src/CodeGen/CodeGenerator.h
r9c6443e r1931bb0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Feb 1 09:23:21202213 // Update Count : 6 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 29 14:32:00 2022 13 // Update Count : 65 14 14 // 15 15 … … 26 26 #include "SynTree/Visitor.h" // for Visitor 27 27 #include "SynTree/SynTree.h" // for Visitor Nodes 28 29 namespace ast { 30 class DeclWithType; 31 } 28 32 29 33 namespace CodeGen { … … 182 186 /// returns C-compatible name of declaration 183 187 std::string genName( DeclarationWithType * decl ); 188 std::string genName( ast::DeclWithType const * decl ); 184 189 185 190 inline std::ostream & operator<<( std::ostream & os, const CodeGenerator::LineEnder & endl ) { -
src/CodeGen/GenType.cc
r9c6443e r1931bb0 254 254 255 255 void GenType::postvisit( EnumInstType * enumInst ) { 256 if ( enumInst->baseEnum ->base ) {256 if ( enumInst->baseEnum && enumInst->baseEnum->base ) { 257 257 typeString = genType(enumInst->baseEnum->base, "", options) + typeString; 258 258 } else { -
src/SymTab/FixFunction.cc
r9c6443e r1931bb0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 16:19:49 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 6 23:36:59 201713 // Update Count : 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Jul 12 14:28:00 2022 13 // Update Count : 7 14 14 // 15 15 … … 122 122 } 123 123 124 void previsit( const ast::FunctionType * ) { visit_children = false; } 125 126 const ast::Type * postvisit( const ast::FunctionType * type ) { 127 return new ast::PointerType( type ); 128 } 129 124 130 void previsit( const ast::VoidType * ) { isVoid = true; } 125 131 … … 145 151 } 146 152 153 const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ) { 154 ast::Pass< FixFunction_new > fixer; 155 type = type->accept( fixer ); 156 isVoid |= fixer.core.isVoid; 157 return type; 158 } 159 147 160 } // namespace SymTab 148 161 -
src/SymTab/FixFunction.h
r9c6443e r1931bb0 10 10 // Created On : Sun May 17 17:02:08 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:45:55 201713 // Update Count : 412 // Last Modified On : Tue Jul 12 14:19:00 2022 13 // Update Count : 5 14 14 // 15 15 … … 21 21 namespace ast { 22 22 class DeclWithType; 23 class Type; 23 24 } 24 25 … … 31 32 /// Sets isVoid to true if type is void 32 33 const ast::DeclWithType * fixFunction( const ast::DeclWithType * dwt, bool & isVoid ); 34 const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ); 33 35 } // namespace SymTab 34 36 -
src/Validate/EliminateTypedef.cpp
r9c6443e r1931bb0 10 10 // Created On : Wed Apr 20 16:37:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Apr 25 14:26:00 202213 // Update Count : 012 // Last Modified On : Mon Jul 11 16:30:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 28 28 29 29 struct EliminateTypedefCore { 30 // Remove typedefs from inside aggregates. 30 31 ast::StructDecl const * previsit( ast::StructDecl const * decl ); 31 32 ast::UnionDecl const * previsit( ast::UnionDecl const * decl ); 33 // Remove typedefs from statement lists. 32 34 ast::CompoundStmt const * previsit( ast::CompoundStmt const * stmt ); 35 // Remove typedefs from control structure initializers. 36 ast::IfStmt const * previsit( ast::IfStmt const * stmt ); 37 ast::ForStmt const * previsit( ast::ForStmt const * stmt ); 38 ast::WhileDoStmt const * previsit( ast::WhileDoStmt const * stmt ); 33 39 }; 34 40 … … 63 69 } 64 70 71 ast::IfStmt const * EliminateTypedefCore::previsit( ast::IfStmt const * stmt ) { 72 return field_erase_if( stmt, &ast::IfStmt::inits, isTypedefStmt ); 73 } 74 75 ast::ForStmt const * EliminateTypedefCore::previsit( ast::ForStmt const * stmt ) { 76 return field_erase_if( stmt, &ast::ForStmt::inits, isTypedefStmt ); 77 } 78 79 ast::WhileDoStmt const * EliminateTypedefCore::previsit( ast::WhileDoStmt const * stmt ) { 80 return field_erase_if( stmt, &ast::WhileDoStmt::inits, isTypedefStmt ); 81 } 82 65 83 } // namespace 66 84 -
src/Validate/module.mk
r9c6443e r1931bb0 26 26 Validate/EliminateTypedef.cpp \ 27 27 Validate/EliminateTypedef.hpp \ 28 Validate/EnumAndPointerDecay.cpp \ 29 Validate/EnumAndPointerDecay.hpp \ 28 30 Validate/FindSpecialDeclsNew.cpp \ 29 31 Validate/FixQualifiedTypes.cpp \ 30 32 Validate/FixQualifiedTypes.hpp \ 33 Validate/FixReturnTypes.cpp \ 34 Validate/FixReturnTypes.hpp \ 31 35 Validate/ForallPointerDecay.cpp \ 32 36 Validate/ForallPointerDecay.hpp \ … … 37 41 Validate/HoistStruct.cpp \ 38 42 Validate/HoistStruct.hpp \ 43 Validate/HoistTypeDecls.cpp \ 44 Validate/HoistTypeDecls.hpp \ 39 45 Validate/InitializerLength.cpp \ 40 46 Validate/InitializerLength.hpp \ … … 44 50 Validate/LinkReferenceToTypes.hpp \ 45 51 Validate/NoIdSymbolTable.hpp \ 52 Validate/ReplaceTypedef.cpp \ 53 Validate/ReplaceTypedef.hpp \ 46 54 Validate/ReturnCheck.cpp \ 47 Validate/ReturnCheck.hpp 55 Validate/ReturnCheck.hpp \ 56 Validate/VerifyCtorDtorAssign.cpp \ 57 Validate/VerifyCtorDtorAssign.hpp 48 58 49 59 SRCDEMANGLE += $(SRC_VALIDATE) -
src/main.cc
r9c6443e r1931bb0 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Ju n 7 13:29:00 202213 // Update Count : 67 412 // Last Modified On : Tue Jul 12 12:02:00 2022 13 // Update Count : 675 14 14 // 15 15 … … 78 78 #include "Validate/CompoundLiteral.hpp" // for handleCompoundLiterals 79 79 #include "Validate/EliminateTypedef.hpp" // for eliminateTypedef 80 #include "Validate/EnumAndPointerDecay.hpp" // for decayEnumsAndPointers 80 81 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 81 82 #include "Validate/FixQualifiedTypes.hpp" // for fixQualifiedTypes 83 #include "Validate/FixReturnTypes.hpp" // for fixReturnTypes 82 84 #include "Validate/ForallPointerDecay.hpp" // for decayForallPointers 83 85 #include "Validate/GenericParameter.hpp" // for fillGenericParameters, tr... 84 86 #include "Validate/HoistStruct.hpp" // for hoistStruct 87 #include "Validate/HoistTypeDecls.hpp" // for hoistTypeDecls 85 88 #include "Validate/InitializerLength.hpp" // for setLengthFromInitializer 86 89 #include "Validate/LabelAddressFixer.hpp" // for fixLabelAddresses 87 90 #include "Validate/LinkReferenceToTypes.hpp" // for linkReferenceToTypes 91 #include "Validate/ReplaceTypedef.hpp" // for replaceTypedef 88 92 #include "Validate/ReturnCheck.hpp" // for checkReturnStatements 93 #include "Validate/VerifyCtorDtorAssign.hpp" // for verifyCtorDtorAssign 89 94 #include "Virtual/ExpandCasts.h" // for expandCasts 90 95 … … 331 336 } // if 332 337 333 // add the assignment statement after the initialization of a type parameter334 PASS( "Validate-A", SymTab::validate_A( translationUnit ) );335 336 338 CodeTools::fillLocations( translationUnit ); 337 339 … … 346 348 347 349 forceFillCodeLocations( transUnit ); 350 351 // Must happen before auto-gen, or anything that examines ops. 352 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) ); 353 354 PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) ); 355 // Hoist Type Decls pulls some declarations out of contexts where 356 // locations are not tracked. Perhaps they should be, but for now 357 // the full fill solves it. 358 forceFillCodeLocations( transUnit ); 359 360 PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) ); 361 362 // Must happen before auto-gen. 363 PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) ); 364 365 // Must happen before Link Reference to Types, it needs correct 366 // types for mangling. 367 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) ); 348 368 349 369 // Must happen before auto-gen, because it uses the sized flag. … … 453 473 translationUnit = convert( move( transUnit ) ); 454 474 } else { 475 // add the assignment statement after the initialization of a type parameter 476 PASS( "Validate-A", SymTab::validate_A( translationUnit ) ); 455 477 PASS( "Validate-B", SymTab::validate_B( translationUnit ) ); 456 478 PASS( "Validate-C", SymTab::validate_C( translationUnit ) );
Note: See TracChangeset
for help on using the changeset viewer.