-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It should be possible to disable use of std::auto_ptr #1301
Comments
I am in favor of the clean fix, replace Auto_ptr.h with memory where unique_ptr is used |
Maybe clang-tidy can help, see https://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-auto-ptr.html |
for clang-tidy you need a compile_commands.json file i.e. generated by cmake! Claus-iMac:ACE_TAO clausklein$ find ACE -type f \( -name '*.cpp' -o -name '*.h' \) | xargs grep --color -w auto_ptr
ACE/netsvcs/servers/main.cpp: // ACE_Service_Object_Ptr which is an <auto_ptr> specialized
ACE/tests/Proactor_Timer_Test.cpp: // The use of auto_ptr<> is optional, ACE uses dangerous memory
ACE/tests/Proactor_Timer_Test.cpp: // auto_ptr<> ...
ACE/tests/Network_Adapters_Test.cpp: // The use of auto_ptr<> is optional, ACE uses dangerous memory
ACE/tests/Future_Set_Test.cpp: // @@ Should make these be <auto_ptr>s...
ACE/tests/Future_Test.cpp: // @@ Should make these be <auto_ptr>s...
ACE/tests/Reactor_Timer_Test.cpp: // The use of auto_ptr<> is optional, ACE uses dangerous memory
ACE/tests/Reactor_Timer_Test.cpp: // auto_ptr<> ...
ACE/tests/Compiler_Features_09_Test.cpp: * std::auto_ptr<> correctly. The motivation for this test was a discussion
ACE/tests/Compiler_Features_09_Test.cpp: // ... this works with the ACE version of auto_ptr (well, the
ACE/tests/Compiler_Features_09_Test.cpp: // ... with a compliant implementation of std::auto_ptr<> you should be
ACE/Kokyu/Default_Dispatcher_Impl.cpp: //ACE_DEBUG ((LM_DEBUG, "task array auto_ptr set\n" ));
ACE/Kokyu/Kokyu.h://using the auto_ptr<> to store the implementation causes a compile
ACE/Kokyu/Kokyu.h://found. Note that the auto-ptr<T>::~auto_ptr() calls delete on the
ACE/examples/Smart_Pointers/Widget_Impl.h: /// - We cannot use auto_ptr to manage the objects, since auto_ptr does not
ACE/examples/Web_Crawler/URL_Visitor.h: * This class is similar to an auto_ptr<> and should be used to
ACE/examples/Reactor/WFMO_Reactor/Window_Messages.cpp: auto_ptr<ACE_Reactor> reactor (new ACE_Reactor (impl, 1));
ACE/examples/Reactor/WFMO_Reactor/Handle_Close.cpp: auto_ptr<ACE_Reactor> reactor (create_reactor ());
ACE/examples/Reactor/TP_Reactor/client.cpp: // put someData in a kind of auto_ptr so it gets deleted automatically
ACE/ace/OS_Memory.h: // screws up auto_ptr.
ACE/ace/Service_Object.h: * auto_ptr. It is used in conjunction with statically linked
ACE/ace/Value_Ptr.h: * Using a @c std::auto_ptr\<\> as a class member is sometimes
ACE/ace/Value_Ptr.h: * for @c auto_ptr\<\>s, but why would one use an @c
ACE/ace/Value_Ptr.h: * auto_ptr\<\> as the template argument for this particular
ACE/ace/Refcounted_Auto_Ptr.h: * @brief This class implements support for a reference counted auto_ptr.
ACE/ace/TLI.cpp: auto_ptr<char> req_opt_buf_p (reinterpret_cast<char*> (req.opt.buf));
ACE/ace/TLI.cpp: auto_ptr<char> ret_opt_buf_p (reinterpret_cast<char*> (ret.opt.buf));
ACE/ace/TLI.cpp: auto_ptr<char> req_opt_buf_p (reinterpret_cast<char*> (req.opt.buf));
ACE/ace/TLI.cpp: auto_ptr<char> ret_opt_buf_p (reinterpret_cast<char*> (ret.opt.buf));
ACE/ace/WFMO_Reactor.cpp: // (via auto_ptr<> event, above) at function return will
ACE/ace/SString.h: * The class plays the same role as auto_ptr<>
ACE/ace/Auto_Functor.h: * @brief Helper template to implement auto_ptr<>-like classes, but
ACE/ace/Intrusive_Auto_Ptr.h: * auto_ptr. It assumes reference counting abilities of the
ACE/ace/Log_Msg.h: /// ownership neither std::auto_ptr nor ACE_Strong_Bound_Ptr have the right
ACE/ace/Service_Gestalt.cpp: auto_ptr<ACE_XML_Svc_Conf> xml_svc_conf (this->get_xml_svc_conf (dll));
ACE/ace/Service_Gestalt.cpp: auto_ptr<ACE_XML_Svc_Conf>
ACE/ace/Auto_Ptr.h: * @brief Implements the draft C++ standard auto_ptr abstraction.
ACE/ace/Auto_Ptr.h: * @class auto_ptr
ACE/ace/Auto_Ptr.h: * @brief Implements the draft C++ standard auto_ptr abstraction.
ACE/ace/Auto_Ptr.h:class auto_ptr : public ACE_Auto_Basic_Ptr<X>
ACE/ace/Auto_Ptr.h: explicit auto_ptr (X * p = 0) : ACE_Auto_Basic_Ptr<X> (p) {}
ACE/ace/Auto_Ptr.h: auto_ptr (auto_ptr<X> & ap) : ACE_Auto_Basic_Ptr<X> (ap.release ()) {}
ACE/ace/Auto_Ptr.h: * @brief Implements the draft C++ standard auto_ptr abstraction.
ACE/ace/Auto_Ptr.h: * This version can be used instead of auto_ptr<T>
ACE/ace/Auto_Ptr.h: * @brief Implements an extension to the draft C++ standard auto_ptr
ACE/ace/Auto_Ptr.h: * @brief Implements an extension to the draft C++ standard auto_ptr
ACE/ace/Auto_Ptr.h: * @brief Reset given @c auto_ptr element to new element.
ACE/ace/Auto_Ptr.h: * Some platforms have an older version of auto_ptr support, which
ACE/ace/Auto_Ptr.h: // of element type found in auto_ptr.
Claus-iMac:ACE_TAO clausklein$ |
for TAO, it is much more: Claus-iMac:ACE_TAO clausklein$ find TAO -type f \( -name '*.cpp' -o -name '*.h' \) | xargs grep --color -w auto_ptr
TAO/tests/Oneway_Send_Timeouts/Server_Task.h: std::auto_ptr<Server> server_;
TAO/tests/Oneway_Send_Timeouts/Server.h: std::auto_ptr<Test_i> test_i_;
TAO/tests/Oneway_Send_Timeouts/main.cpp: std::auto_ptr<Server_Task> server_task_;
TAO/tests/Oneway_Send_Timeouts/main.cpp: std::auto_ptr<Client_Task> client_task_;
TAO/tests/Client_Leaks/child.cpp: // Paranoia, we should have an auto_ptr-like gadget for
TAO/tests/Compression/RLECompressorTest.cpp:struct ACE_Byte_Array_ptr : std::auto_ptr<ACE_Byte> {
TAO/tests/Compression/RLECompressorTest.cpp: : std::auto_ptr<ACE_Byte>(_Ptr) {}
TAO/tests/Bug_3251_Regression/DllOrb.h: auto_ptr < ACE_Thread_Barrier > ma_barrier_;
TAO/tests/Bug_3542_Regression/DllOrb.h: auto_ptr < ACE_Thread_Barrier > ma_barrier_;
TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp: // NOTE: ACE_NEW is incompatable with auto_ptr
TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp: auto_ptr<TAO::Fault_Detector_i> detector(pFD);
TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.h: auto_ptr<RTPOA_Setup> rtpoa_setup_;
TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.h: typedef auto_ptr<Send_Task_Stopper> Auto_Send_Task_Stopper;
TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.cpp: // @@ We need an 'auto_ptr for thread pools' here!
TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.cpp: auto_ptr<TAO_EC_Factory> factory (
TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.h: auto_ptr<RTCORBA_Setup> rtcorba_setup_;
TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp: ACE_Auto_Basic_Array_Ptr<auto_ptr<Loopback_Disconnect> > disconnects (
TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp: new auto_ptr<Loopback_Disconnect>[2*this->peers_count_]
TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.cpp: /// Resetting the auto_ptr<> destroys all the objects. The
TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.h: auto_ptr < ACE_Thread_Barrier > ma_barrier_;
TAO/orbsvcs/tests/FtRtEvent/supplier.cpp:auto_ptr<TAO_FTRTEC::FTEC_Gateway> gateway;
TAO/orbsvcs/tests/FtRtEvent/consumer.cpp:auto_ptr<TAO_FTRTEC::FTEC_Gateway> gateway;
TAO/orbsvcs/tests/Trading/colocated_test.cpp: auto_ptr<TAO_Trader_Factory::TAO_TRADER> trader (TAO_Trader_Factory::create_trader (argc, argv));
TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<ACE_Event_Handler> eh;
TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<TAO_ECG_Mcast_EH> mcast_eh(new TAO_ECG_Mcast_EH (receiver.in()));
TAO/orbsvcs/tests/Event/Mcast/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<TAO_ECG_UDP_EH> udp_eh (new TAO_ECG_UDP_EH (receiver.in()));
TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp: friend class std::auto_ptr< TAO_Notify_Tracker >;
TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp: static std::auto_ptr< TAO_Notify_Tracker > s_instance;
TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp:std::auto_ptr< TAO_Notify_Tracker > TAO_Notify_Tracker::s_instance;
TAO/orbsvcs/orbsvcs/AV/SCTP_SEQ.h://typedef auto_ptr <Interface_Seq> Interface_Seq_Ptr;
TAO/orbsvcs/orbsvcs/FtRtEvent/EventChannel/replace_key.cpp:/// file conflicts with the use of auto_ptr in the
TAO/orbsvcs/orbsvcs/Naming/Naming_Server.cpp: // Use an auto_ptr to ensure that we clean up the factory in the case
TAO/orbsvcs/orbsvcs/Naming/Naming_Server.cpp: // The activator already took over the factories so we need to release the auto_ptr
TAO/orbsvcs/examples/FaultTolerance/RolyPoly/ReplicaController.h: auto_ptr<ACE_TMCast::Group> group_;
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/CosEvent_Utilities.cpp: auto_ptr<POA_RtecEventChannelAdmin::EventChannel>
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/CosEvent_Utilities.cpp: auto_ptr<TAO_CosEC_EventChannel_i>
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/ProxyPushSupplier_i.cpp: auto_ptr <TAO_CosEC_PushConsumerWrapper> auto_wrapper (wrapper);
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/SupplierAdmin_i.cpp: auto_ptr <TAO_CosEC_ProxyPushConsumer_i>
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/EventChannel_i.cpp: auto_ptr <TAO_CosEC_ConsumerAdmin_i> auto_consumer_ (consumer_);
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/EventChannel_i.cpp: auto_ptr <TAO_CosEC_SupplierAdmin_i> auto_supplier_ (supplier_);
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/ProxyPushConsumer_i.cpp: auto_ptr <TAO_CosEC_PushSupplierWrapper>
TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/ConsumerAdmin_i.cpp: auto_ptr<TAO_CosEC_ProxyPushSupplier_i>
TAO/orbsvcs/examples/CosEC/Factory/CosEventChannelFactory_i.cpp: auto_ptr <TAO_CEC_EventChannel> ec (impl);
TAO/orbsvcs/DevGuideExamples/EventServices/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<ACE_Event_Handler> eh;
TAO/orbsvcs/DevGuideExamples/EventServices/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<TAO_ECG_Mcast_EH> mcast_eh(new TAO_ECG_Mcast_EH (receiver.in()));
TAO/orbsvcs/DevGuideExamples/EventServices/RTEC_MCast_Federated/EchoEventSupplierMain.cpp: auto_ptr<TAO_ECG_UDP_EH> udp_eh (new TAO_ECG_UDP_EH (receiver.in()));
TAO/orbsvcs/DevGuideExamples/NotifyService/EventSequence/Messenger_i.h: auto_ptr<EventSequenceSupplier_i> supplier_;
TAO/examples/Load_Balancing/Load_Balancer_i.cpp: // Temporarily put the servant into the auto_ptr.
TAO/examples/Borland/ChatClientWnd.h: auto_ptr<TORBThread> orb_thread_;
TAO/examples/Borland/ChatClientWnd.cpp: auto_ptr<TStringList> ior (new TStringList);
TAO/tao/RTCORBA/RT_ORBInitializer.cpp: // mapping allocated above will be leaked. Use an auto_ptr<> or
TAO/tao/default_resource.h: * @brief A simple auto_ptr like class to manage timer queues dynamically
TAO/tao/LF_Event_Binder.h: * @brief Implement an auto_ptr-like class for the TAO_LF_Followers
TAO/tao/Leader_Follower.cpp: // End artificial scope for auto_ptr like helpers calling:
TAO/tao/Leader_Follower.cpp: // End artificial scope for auto_ptr like helpers calling:
TAO/tao/ORB_Core_Auto_Ptr.h: * @brief Define a TAO_ORB_Core auto_ptr class.
TAO/tao/CORBALOC_Parser.cpp: /// auto_ptr.
TAO/tao/LF_Follower_Auto_Ptr.h: * @brief Implement an auto_ptr-like class for the TAO_LF_Followers
TAO/tao/Asynch_Reply_Dispatcher_Base.h: * heap. We cannot use auto_ptr <> since it calls delete on the
TAO/tao/IORManipulation/IORManipulation.cpp: // this gets a copy of the MProfile, hence the auto_ptr;
TAO/tao/Messaging/AMH_Response_Handler.h: * heap. We cannot use auto_ptr <> since it calls delete on the
TAO/tao/Messaging/Asynch_Invocation.cpp: // NOTE: We don't need to do the auto_ptr <> trick. We got here
TAO/tao/Stub.h:// Define a TAO_Stub auto_ptr class.
TAO/tao/Stub.h: * @brief Implements the draft C++ standard auto_ptr abstraction.
TAO/tao/Load_Protocol_Factory_T.h: // TAO_Protocol_Factory then we used an auto_ptr<> above, so
TAO/tao/Load_Protocol_Factory_T.h: // Configurator so an auto_ptr<> wasn't used since the Service
TAO/tao/Load_Protocol_Factory_T.h: // use an auto_ptr<> in this method.
TAO/tao/PortableServer/Root_POA.cpp:// auto_ptr class
Claus-iMac:ACE_TAO clausklein$ |
Yes, |
Pull request are welcome for cleanup, all together it is a huge job for which we can use assistance and/or funding. |
do you mean bear? |
Not so easy as it should: Claus-iMac:TAO clausklein$ run-clang-tidy.py -j 1 -checks='-*,modernize-replace-auto-ptr' -extra-arg-before='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk'
Enabled checks:
modernize-replace-auto-ptr
clang-tidy -checks=-*,modernize-replace-auto-ptr -extra-arg-before=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -p=/Users/clausklein/Workspace/cpp/ACE_TAO/TAO /Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Event_Service/Event_Service.cpp
/Users/clausklein/Workspace/cpp/ACE_TAO/ACE/ace/config-macosx.h:3:10: error: 'Availability.h' file not found [clang-diagnostic-error]
#include <Availability.h>
^
1 warning and 1 error generated.
Error while processing /Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Event_Service/Event_Service.cpp.
Suppressed 1 warnings (1 with check filters).
Found compiler error(s). |
Oh it is really hard: + run-clang-tidy.py -j 1 -fix '-checks=-*,modernize-replace-auto-ptr' '-extra-arg-before=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk' -extra-arg=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include -extra-arg=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -extra-arg=-DTARGET_OS_IPHONE=0 ./orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp
Enabled checks:
modernize-replace-auto-ptr
clang-apply-replacements version 12.0.0
clang-tidy -checks=-*,modernize-replace-auto-ptr -export-fixes /var/folders/wb/ckvxxgls5db7qyhqq4y5_l1c0000gq/T/tmp3s9ii7_a/tmp6m8m3fjw.yaml -extra-arg=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include -extra-arg=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -extra-arg=-DTARGET_OS_IPHONE=0 -extra-arg-before=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -p=/Users/clausklein/Workspace/cpp/ACE_TAO/TAO /Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp
/Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp:604:36: error: use of undeclared identifier 'detector' [clang-diagnostic-error]
auto_ptr<TAO::Fault_Detector_i>; detector(pFD);
^
/Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp:618:5: error: use of undeclared identifier 'detector' [clang-diagnostic-error]
(*detector).start(this->threadManager_);
^
/Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp:620:34: error: use of undeclared identifier 'detector' [clang-diagnostic-error]
this->detectors_[detectorId] = detector.release();
^
225 warnings and 3 errors generated.
Error while processing /Users/clausklein/Workspace/cpp/ACE_TAO/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp.
Suppressed 225 warnings (2 in non-user code, 223 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
Applying fixes ...
Claus-iMac:TAO clausklein$ |
Yes, these kind of cleanup tasks sound simple to start with but given the size and complexity of ACE/TAO they are not easy and small tasks. |
|
I am not in favor of |
But then ACE and TAO would not longer compile with |
ACE7 and TAO3 require C++11 support or newer |
OK, than im looking forward to |
what is about this, i.e TAO/tests/Oneway_Send_Timeouts/main.cpp ACE_auto_ptr_reset (server_, new Server (my_args.argc(), my_args.argv()));
// change to?
server_ = std::make_unique<Server>(my_args.argc(), my_args.argv()); |
Inspecting the code, it looks like this is possible with
#define ACE_LACKS_AUTO_PTR
in config.h
This does not work as it prevents ace/Auto_Ptr.h from including <memory>
ACE_TAO/ACE/ace/Auto_Ptr.h
Line 71 in a853ed1
Use of std::unique_ptr elsewhere in ACE with >= C++11 fails because of this (ACE version 6.5.11)
Quick fix is to unconditionally include <memory> in ace/Auto_Ptr.h
It looks like the project is moving to C++11 for the next major release. Then this is maybe an acceptable change?
The text was updated successfully, but these errors were encountered: