Changeset c13e8dc8 for src/CodeGen/FixNames.cc
- Timestamp:
- Dec 5, 2017, 2:35:03 PM (8 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f9feab8
- Parents:
- 9c35431 (diff), 65197c2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/FixNames.cc
r9c35431 rc13e8dc8 19 19 #include <string> // for string, operator!=, operator== 20 20 21 #include "Common/PassVisitor.h" 21 22 #include "Common/SemanticError.h" // for SemanticError 22 23 #include "FixMain.h" // for FixMain … … 32 33 33 34 namespace CodeGen { 34 class FixNames : public Visitor{35 class FixNames : public WithGuards { 35 36 public: 36 v irtual voidvisit( ObjectDecl *objectDecl );37 v irtual voidvisit( FunctionDecl *functionDecl );37 void postvisit( ObjectDecl *objectDecl ); 38 void postvisit( FunctionDecl *functionDecl ); 38 39 39 v irtual voidvisit( CompoundStmt *compoundStmt );40 void previsit( CompoundStmt *compoundStmt ); 40 41 private: 41 42 int scopeLevel = 1; … … 93 94 } 94 95 95 void fixNames( std::list< Declaration* > translationUnit ) {96 FixNamesfixer;96 void fixNames( std::list< Declaration* > & translationUnit ) { 97 PassVisitor<FixNames> fixer; 97 98 acceptAll( translationUnit, fixer ); 98 99 } 99 100 100 void FixNames::fixDWT( DeclarationWithType * dwt ) {101 void FixNames::fixDWT( DeclarationWithType * dwt ) { 101 102 if ( dwt->get_name() != "" ) { 102 103 if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) { … … 107 108 } 108 109 109 void FixNames::visit( ObjectDecl *objectDecl ) { 110 Visitor::visit( objectDecl ); 110 void FixNames::postvisit( ObjectDecl * objectDecl ) { 111 111 fixDWT( objectDecl ); 112 112 } 113 113 114 void FixNames::visit( FunctionDecl *functionDecl ) { 115 Visitor::visit( functionDecl ); 114 void FixNames::postvisit( FunctionDecl * functionDecl ) { 116 115 fixDWT( functionDecl ); 117 116 … … 121 120 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl); 122 121 } 123 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( n oLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );122 functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) ); 124 123 CodeGen::FixMain::registerMain( functionDecl ); 125 124 } 126 125 } 127 126 128 void FixNames:: visit( CompoundStmt *compoundStmt) {127 void FixNames::previsit( CompoundStmt * ) { 129 128 scopeLevel++; 130 Visitor::visit( compoundStmt ); 131 scopeLevel--; 129 GuardAction( [this](){ scopeLevel--; } ); 132 130 } 133 131 } // namespace CodeGen
Note:
See TracChangeset
for help on using the changeset viewer.