-
Notifications
You must be signed in to change notification settings - Fork 415
Make TR_Uncopyable more widely available as TR::Uncopyable #6646
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
Conversation
| #define OMR_UNCOPYABLE_INCL | ||
|
|
||
| namespace TR { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to have a brief comment here for what and why this class is useful and how it is expected to be used (i.e., subclassing). Would you mind adding a brief comment here please?
compiler/infra/Uncopyable.hpp
Outdated
| *******************************************************************************/ | ||
|
|
||
| #ifndef OMR_UNCOPYABLE_INCL | ||
| #define OMR_UNCOPYABLE_INCL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this should be TR_UNCOPYABLE_INCL per existing conventions.
compiler/infra/Uncopyable.hpp
Outdated
| @@ -0,0 +1,40 @@ | |||
| /******************************************************************************* | |||
| * Copyright (c) 2022, 2022 IBM Corp. and others | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this was lifted from FrontEnd.hpp, I think the first copyright date should be 2000.
TR_Uncopyable provides highly general functionality that should be available without including FrontEnd.hpp. This commit moves it into its own header, where it will be more widely available. Additionally: - It is moved into the TR namespace. - A doc comment is added to the class, and another comment explains the mechanism by which it works. - The constructor and destructor are declared protected rather than public. Only subclasses need access to those. - The only existing point of use (TR_FrontEnd) is changed to use private rather than public inheritance, since the fact that inheritance is used to get the desired effect is an implementation detail. - A couple of types are changed to use TR::Uncopyable.
|
Updated to fix the copyright start date and include guard name, and to document the class. I also added another comment to explain how it works. While documenting this, I realized that it additionally happens to prevent the implicit default definition of the move constructor and move assignment operator (in both However, it isn't clear that we have a reasonable level of support for move semantics in all of our build compilers (even though the list of supported C++ features claims that we can use it). For example, cppreference.com says that no version of XLC++ supports "defaulted move special member functions." From a bit of experimentation, it seems that this includes implicitly-defined move operations, which means that we couldn't portably rely on the implicit definitions allowed by the snippet above. But it seems we don't use move semantics regardless. At least, I don't recall seeing any explicit rvalue references or moves in the codebase, and in my experimentation I hit a number of surprising road blocks beyond just the lack of defaulted move methods, e.g. lack of move constructors for STL types. So for now I've left the move constructor and assignment operator undeclared without so much as commenting about them in the code, just as though move semantics don't even exist. |
|
Jenkins build all |
TR_Uncopyableprovides highly general functionality that should be available without including FrontEnd.hpp. This commit moves it into its own header, where it will be more widely available.Additionally:
It is moved into the
TRnamespace.The constructor and destructor are declared
protectedrather thanpublic. Only subclasses need access to those.The only existing point of use (
TR_FrontEnd) is changed to useprivaterather thanpublicinheritance, since the fact that inheritance is used to get the desired effect is an implementation detail.A couple of types are changed to use
TR::Uncopyable.