Changeset 25a054f for src/CodeGen


Ignore:
Timestamp:
Jan 19, 2016, 4:46:04 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
e551c69
Parents:
1194734
Message:

Add OffsetofExpr? for field offsets

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r1194734 r25a054f  
    443443        }
    444444
    445         void CodeGenerator::visit( AlignofExpr *sizeofExpr ) {
     445        void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
    446446                // use GCC extension to avoid bumping std to C11
    447447                output << "__alignof__(";
    448                 if ( sizeofExpr->get_isType() ) {
    449                         output << genType( sizeofExpr->get_type(), "" );
    450                 } else {
    451                         sizeofExpr->get_expr()->accept( *this );
    452                 } // if
     448                if ( alignofExpr->get_isType() ) {
     449                        output << genType( alignofExpr->get_type(), "" );
     450                } else {
     451                        alignofExpr->get_expr()->accept( *this );
     452                } // if
     453                output << ")";
     454        }
     455
     456        void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
     457                // use GCC builtin
     458                output << "__builtin_offsetof(";
     459                output << genType( offsetofExpr->get_type(), "" );
     460                output << ", ";
     461                offsetofExpr->get_member()->accept( *this );
    453462                output << ")";
    454463        }
  • src/CodeGen/CodeGenerator.h

    r1194734 r25a054f  
    6161                virtual void visit( SizeofExpr *sizeofExpr );
    6262                virtual void visit( AlignofExpr *alignofExpr );
     63                virtual void visit( OffsetofExpr *offsetofExpr );
    6364                virtual void visit( LogicalExpr *logicalExpr );
    6465                virtual void visit( ConditionalExpr *conditionalExpr );
Note: See TracChangeset for help on using the changeset viewer.