Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (8 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/CoreStaticInitializationHandler.cc

    r10624 r10821  
    9999        std::set<Identifier*> identifiers;
    100100        const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER);
    101         for (std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)
    102             identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(*it)->getIdentifier());
     101        for (const auto & instance : instances)
     102            identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(instance)->getIdentifier());
    103103
    104104        // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is
     
    106106        // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another
    107107        // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash.
    108         for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
    109             (*it)->destroyObjects();
     108        for (const auto & identifier : identifiers)
     109            (identifier)->destroyObjects();
    110110
    111111        // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another
    112112        // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by
    113113        // changing object dependencies; or by changing the logic that allows modules to be unloaded).
    114         for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
     114        for (const auto & identifier : identifiers)
    115115        {
    116             ObjectListBase* objectList = Context::getRootContext()->getObjectList(*it);
     116            ObjectListBase* objectList = Context::getRootContext()->getObjectList(identifier);
    117117            if (objectList->size() > 0)
    118118            {
    119                 orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (*it)->getName()
     119                orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (identifier)->getName()
    120120                    << " after unloading the Identifier. This may lead to a crash" << endl;
    121121            }
     
    123123
    124124        // destroy object-lists in all contexts
    125         for (std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)
     125        for (const auto & identifier : identifiers)
    126126        {
    127127            // only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over
    128             if (!(*it_identifier)->isExactlyA(Class(Context)))
     128            if (!(identifier)->isExactlyA(Class(Context)))
    129129            {
    130130                // iterate over all contexts
    131131                for (ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context)
    132                     it_context->destroyObjectList((*it_identifier));
     132                    it_context->destroyObjectList((identifier));
    133133            }
    134134        }
Note: See TracChangeset for help on using the changeset viewer.