Changeset 5f98ce5 for src/SymTab


Ignore:
Timestamp:
Jul 19, 2016, 7:09:30 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
40e636a
Parents:
2be1023
Message:

hoist non-constexpr array dimension into const variable in case of side effects

Location:
src/SymTab
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r2be1023 r5f98ce5  
    2626
    2727namespace SymTab {
     28        Type * SizeType = 0;
     29
    2830        class AutogenerateRoutines : public Visitor {
    2931                public:
  • src/SymTab/Autogen.h

    r2be1023 r5f98ce5  
    2929        /// returns true if obj's name is the empty string and it has a bitfield width
    3030        bool isUnnamedBitfield( ObjectDecl * obj );
     31
     32        /// size_t type - set when size_t typedef is seen. Useful in a few places,
     33        /// such as in determining array dimension type
     34        extern Type * SizeType;
    3135
    3236        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
  • src/SymTab/Validate.cc

    r2be1023 r5f98ce5  
    174174
    175175                virtual void visit( FunctionDecl *funcDecl );
    176 };
     176        };
    177177
    178178        class CompoundLiteral : public GenPoly::DeclMutator {
     
    490490                EliminateTypedef eliminator;
    491491                mutateAll( translationUnit, eliminator );
     492                if ( eliminator.typedefNames.count( "size_t" ) ) {
     493                        // grab and remember declaration of size_t
     494                        SizeType = eliminator.typedefNames["size_t"].first->get_base()->clone();
     495                } else {
     496                        assert( false && "missing global typedef for size_t" );
     497                }
    492498                filter( translationUnit, isTypedef, true );
     499
    493500        }
    494501
     
    518525        Declaration *EliminateTypedef::mutate( TypedefDecl * tyDecl ) {
    519526                Declaration *ret = Mutator::mutate( tyDecl );
     527
    520528                if ( typedefNames.count( tyDecl->get_name() ) == 1 && typedefNames[ tyDecl->get_name() ].second == scopeLevel ) {
    521529                        // typedef to the same name from the same scope
Note: See TracChangeset for help on using the changeset viewer.