Changeset 139775e for src/InitTweak


Ignore:
Timestamp:
Nov 6, 2020, 4:48:52 PM (5 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
75baaa3
Parents:
55acc3a (diff), 836c9925 (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 plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/InitTweak
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixGlobalInit.cc

    r55acc3a r139775e  
    109109        }
    110110
    111         void fixGlobalInit(std::list<ast::ptr<ast::Decl>> & translationUnit, bool inLibrary) {
     111        void fixGlobalInit(ast::TranslationUnit & translationUnit, bool inLibrary) {
    112112                ast::Pass<GlobalFixer_new> fixer;
    113113                accept_all(translationUnit, fixer);
     
    119119                                ast::Storage::Static, ast::Linkage::C, {new ast::Attribute("constructor", std::move(ctorParams))});
    120120
    121                         translationUnit.emplace_back( initFunction );
     121                        translationUnit.decls.emplace_back( initFunction );
    122122                } // if
    123123
     
    128128                                ast::Storage::Static, ast::Linkage::C, {new ast::Attribute("destructor", std::move(dtorParams))});
    129129
    130                         translationUnit.emplace_back(destroyFunction);
     130                        translationUnit.decls.emplace_back(destroyFunction);
    131131                } // if
    132132        }
     
    183183                        } // if
    184184                        if ( const ast::Stmt * ctor = ctorInit->ctor ) {
     185                                addDataSectionAttribute(mutDecl);
    185186                                initStmts.push_back( ctor );
    186187                                mutDecl->init = nullptr;
  • src/InitTweak/FixGlobalInit.h

    r55acc3a r139775e  
    2929        /// function is for library code.
    3030        void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary );
    31         void fixGlobalInit( std::list< ast::ptr<ast::Decl> > & translationUnit, bool inLibrary );
     31        void fixGlobalInit( ast::TranslationUnit & translationUnit, bool inLibrary );
    3232} // namespace
    3333
  • src/InitTweak/FixInit.h

    r55acc3a r139775e  
    1919#include <string>  // for string
    2020
    21 #include <AST/Fwd.hpp>
    22 
    2321class Declaration;
     22namespace ast {
     23        class TranslationUnit;
     24}
    2425
    2526namespace InitTweak {
     
    2728        void fix( std::list< Declaration * > & translationUnit, bool inLibrary );
    2829
    29         void fix( std::list<ast::ptr<ast::Decl>> & translationUnit, bool inLibrary);
     30        void fix( ast::TranslationUnit & translationUnit, bool inLibrary);
    3031} // namespace
    3132
  • src/InitTweak/FixInitNew.cpp

    r55acc3a r139775e  
    179179        /// expand each object declaration to use its constructor after it is declared.
    180180        struct FixInit : public ast::WithStmtsToAdd<> {
    181                 static void fixInitializers( std::list< ast::ptr<ast::Decl> > &translationUnit );
     181                static void fixInitializers( ast::TranslationUnit &translationUnit );
    182182
    183183                const ast::DeclWithType * postvisit( const ast::ObjectDecl *objDecl );
     
    225225} // namespace
    226226
    227 void fix( std::list< ast::ptr<ast::Decl> > & translationUnit, bool inLibrary ) {
     227void fix( ast::TranslationUnit & translationUnit, bool inLibrary ) {
    228228        ast::Pass<SelfAssignChecker>::run( translationUnit );
    229229
     
    308308        }
    309309
    310         void FixInit::fixInitializers( std::list< ast::ptr<ast::Decl> > & translationUnit ) {
     310        void FixInit::fixInitializers( ast::TranslationUnit & translationUnit ) {
    311311                ast::Pass<FixInit> fixer;
    312312
     
    314314                // can't use DeclMutator, because sometimes need to insert IfStmt, etc.
    315315                SemanticErrorException errors;
    316                 for ( auto i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
     316                for ( auto i = translationUnit.decls.begin(); i != translationUnit.decls.end(); ++i ) {
    317317                        try {
    318318                                // maybeAccept( *i, fixer ); translationUnit should never contain null
    319319                                *i = (*i)->accept(fixer);
    320                                 translationUnit.splice( i, fixer.core.staticDtorDecls );
     320                                translationUnit.decls.splice( i, fixer.core.staticDtorDecls );
    321321                        } catch( SemanticErrorException &e ) {
    322322                                errors.append( e );
     
    864864                        if ( const ast::Stmt * ctor = ctorInit->ctor ) {
    865865                                if ( objDecl->storage.is_static ) {
     866                                        addDataSectionAttribute(objDecl);
    866867                                        // originally wanted to take advantage of gcc nested functions, but
    867868                                        // we get memory errors with this approach. To remedy this, the static
     
    947948                                                objDecl->name = objDecl->name + staticNamer.newName();
    948949                                                objDecl->mangleName = Mangle::mangle( objDecl );
     950                                                objDecl->init = nullptr;
    949951
    950952                                                // xxx - temporary hack: need to return a declaration, but want to hoist the current object out of this scope
  • src/InitTweak/InitTweak.cc

    r55acc3a r139775e  
    11131113        }
    11141114
     1115        void addDataSectionAttribute( ast::ObjectDecl * objDecl ) {
     1116                auto strLitT = new ast::PointerType(new ast::BasicType(ast::BasicType::Char));
     1117                objDecl->attributes.push_back(new ast::Attribute("section", {new ast::ConstantExpr(objDecl->location, strLitT, "\".data#\"", std::nullopt)}));
     1118        }
     1119
    11151120}
  • src/InitTweak/InitTweak.h

    r55acc3a r139775e  
    119119        void addDataSectonAttribute( ObjectDecl * objDecl );
    120120
     121        void addDataSectionAttribute( ast::ObjectDecl * objDecl );
     122
    121123        class InitExpander_old {
    122124        public:
Note: See TracChangeset for help on using the changeset viewer.