Changeset 0c577f7 for src/CodeGen/FixMain.cc
- Timestamp:
- Oct 29, 2021, 4:03:07 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 8e48fca4
- Parents:
- f42fc13
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixMain.cc
rf42fc13 r0c577f7 22 22 #include <string> // for operator<< 23 23 24 #include "AST/Decl.hpp" 25 #include "AST/Type.hpp" 24 26 #include "Common/PassVisitor.h" 25 27 #include "Common/SemanticError.h" // for SemanticError … … 105 107 } 106 108 109 bool is_main( const std::string & mangled_name ) { 110 // This breaks if you move it out of the function. 111 static const std::string mangled_mains[] = { 112 mangled_0_argument_main(), 113 mangled_2_argument_main(), 114 //mangled_3_argument_main(), 115 }; 116 117 for ( auto main_name : mangled_mains ) { 118 if ( main_name == mangled_name ) return true; 119 } 120 return false; 121 } 122 107 123 struct FindMainCore { 108 124 void previsit( FunctionDecl * decl ) { … … 116 132 117 133 bool FixMain::isMain( FunctionDecl * decl ) { 118 // This breaks if you move it out of the function.119 static const std::string mangled_mains[] = {120 mangled_0_argument_main(),121 mangled_2_argument_main(),122 //mangled_3_argument_main(),123 };124 125 134 if ( std::string("main") != decl->name ) { 126 135 return false; 127 136 } 128 auto mangled_name = SymTab::Mangler::mangle( decl, true, true ); 129 for ( auto main_name : mangled_mains ) { 130 if ( main_name == mangled_name ) return true; 137 return is_main( SymTab::Mangler::mangle( decl, true, true ) ); 138 } 139 140 bool FixMain::isMain( const ast::FunctionDecl * decl ) { 141 if ( std::string("main") != decl->name ) { 142 return false; 131 143 } 132 return false;144 return is_main( Mangle::mangle( decl, Mangle::Type ) ); 133 145 } 134 146
Note: See TracChangeset
for help on using the changeset viewer.