Changeset 94b1022a for src/CodeGen


Ignore:
Timestamp:
May 30, 2018, 9:28:18 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, with_gc
Children:
bd946e4
Parents:
35718a9 (diff), ae32d96 (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.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r35718a9 r94b1022a  
    172172        // *** Declarations
    173173        void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
     174                // deleted decls should never be used, so don't print them
     175                if ( functionDecl->isDeleted && genC ) return;
    174176                extension( functionDecl );
    175177                genAttributes( functionDecl->get_attributes() );
     
    185187                        functionDecl->get_statements()->accept( *visitor );
    186188                } // if
     189                if ( functionDecl->isDeleted ) {
     190                        output << " = void";
     191                }
    187192        }
    188193
    189194        void CodeGenerator::postvisit( ObjectDecl * objectDecl ) {
     195                // deleted decls should never be used, so don't print them
     196                if ( objectDecl->isDeleted && genC ) return;
    190197                if (objectDecl->get_name().empty() && genC ) {
    191198                        // only generate an anonymous name when generating C code, otherwise it clutters the output too much
     
    206213                        objectDecl->get_init()->accept( *visitor );
    207214                } // if
     215                if ( objectDecl->isDeleted ) {
     216                        output << " = void";
     217                }
    208218
    209219                if ( objectDecl->get_bitfieldWidth() ) {
     
    827837                expr->expr->accept( *visitor );
    828838        }
     839
     840        void CodeGenerator::postvisit( GenericExpr * expr ) {
     841                assertf( ! genC, "C11 _Generic expressions should not reach code generation." );
     842                output << "_Generic(";
     843                expr->control->accept( *visitor );
     844                output << ", ";
     845                unsigned int numAssocs = expr->associations.size();
     846                unsigned int i = 0;
     847                for ( GenericExpr::Association & assoc : expr->associations ) {
     848                        if (assoc.isDefault) {
     849                                output << "default: ";
     850                        } else {
     851                                output << genType( assoc.type, "", pretty, genC ) << ": ";
     852                        }
     853                        assoc.expr->accept( *visitor );
     854                        if ( i+1 != numAssocs ) {
     855                                output << ", ";
     856                        }
     857                        i++;
     858                }
     859                output << ")";
     860        }
     861
    829862
    830863        // *** Statements
  • src/CodeGen/CodeGenerator.h

    r35718a9 r94b1022a  
    9494                void postvisit( ConstructorExpr * );
    9595                void postvisit( DeletedExpr * );
     96                void postvisit( GenericExpr * );
    9697
    9798                //*** Statements
Note: See TracChangeset for help on using the changeset viewer.