[clang-tools-extra] r189387 - Temporarily revert r189363 as it seems to be failing to build.
Eric Christopher
echristo at gmail.com
Tue Aug 27 10:26:08 PDT 2013
Author: echristo
Date: Tue Aug 27 12:26:07 2013
New Revision: 189387
URL: http://llvm.org/viewvc/llvm-project?rev=189387&view=rev
Log:
Temporarily revert r189363 as it seems to be failing to build.
Removed:
clang-tools-extra/trunk/cpp11-migrate/PassByValue/
clang-tools-extra/trunk/docs/PassByValueTransform.rst
clang-tools-extra/trunk/test/cpp11-migrate/PassByValue/
Modified:
clang-tools-extra/trunk/cpp11-migrate/Core/Transform.h
clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt
clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
clang-tools-extra/trunk/cpp11-migrate/tool/Makefile
clang-tools-extra/trunk/docs/MigratorUsage.rst
clang-tools-extra/trunk/docs/cpp11-migrate.rst
Modified: clang-tools-extra/trunk/cpp11-migrate/Core/Transform.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/Transform.h?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/Transform.h (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/Transform.h Tue Aug 27 12:26:07 2013
@@ -139,12 +139,6 @@ public:
bool isFileModifiable(const clang::SourceManager &SM,
const clang::SourceLocation &Loc) const;
- /// \brief Whether a transformation with a risk level of \p RiskLevel is
- /// acceptable or not.
- bool isAcceptableRiskLevel(RiskLevel RiskLevel) const {
- return RiskLevel <= GlobalOptions.MaxRiskLevel;
- }
-
/// \brief Called before parsing a translation unit for a FrontendAction.
///
/// Transform uses this function to apply file overrides and start
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt Tue Aug 27 12:26:07 2013
@@ -19,9 +19,6 @@ list(APPEND Cpp11MigrateSources ${UseAut
file(GLOB_RECURSE AddOverrideSources "../AddOverride/*.cpp")
list(APPEND Cpp11MigrateSources ${AddOverrideSources})
-file(GLOB_RECURSE PassByValueSources "../PassByValue/*.cpp")
-list(APPEND Cpp11MigrateSources ${PassByValueSources})
-
file(GLOB_RECURSE ReplaceAutoPtrSources "../ReplaceAutoPtr/*.cpp")
list(APPEND Cpp11MigrateSources ${ReplaceAutoPtrSources})
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp Tue Aug 27 12:26:07 2013
@@ -414,7 +414,6 @@ int main(int argc, const char **argv) {
// These anchors are used to force the linker to link the transforms
extern volatile int AddOverrideTransformAnchorSource;
extern volatile int LoopConvertTransformAnchorSource;
-extern volatile int PassByValueTransformAnchorSource;
extern volatile int ReplaceAutoPtrTransformAnchorSource;
extern volatile int UseAutoTransformAnchorSource;
extern volatile int UseNullptrTransformAnchorSource;
@@ -422,7 +421,6 @@ extern volatile int UseNullptrTransformA
static int TransformsAnchorsDestination[] = {
AddOverrideTransformAnchorSource,
LoopConvertTransformAnchorSource,
- PassByValueTransformAnchorSource,
ReplaceAutoPtrTransformAnchorSource,
UseAutoTransformAnchorSource,
UseNullptrTransformAnchorSource
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/Makefile?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/Makefile (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/Makefile Tue Aug 27 12:26:07 2013
@@ -30,8 +30,6 @@ SOURCES += $(addprefix ../UseAuto/,$(not
BUILT_SOURCES += $(ObjDir)/../UseAuto/.objdir
SOURCES += $(addprefix ../AddOverride/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../AddOverride/*.cpp)))
BUILT_SOURCES += $(ObjDir)/../AddOverride/.objdir
-SOURCES += $(addprefix ../PassByValue/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../PassByValue/*.cpp)))
-BUILT_SOURCES += $(ObjDir)/../PassByValue/.objdir
SOURCES += $(addprefix ../ReplaceAutoPtr/,$(notdir $(wildcard $(PROJ_SRC_DIR)/../ReplaceAutoPtr/*.cpp)))
BUILT_SOURCES += $(ObjDir)/../ReplaceAutoPtr/.objdir
Modified: clang-tools-extra/trunk/docs/MigratorUsage.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/MigratorUsage.rst?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/MigratorUsage.rst (original)
+++ clang-tools-extra/trunk/docs/MigratorUsage.rst Tue Aug 27 12:26:07 2013
@@ -141,7 +141,6 @@ General Command Line Options
=============== ===== === ==== ====
AddOverride (1) 3.0 4.7 14 8
LoopConvert 3.0 4.6 13 11
- PassByValue 3.0 4.6 13 11
ReplaceAutoPtr 3.0 4.6 13 11
UseAuto 2.9 4.4 12 10
UseNullptr 3.0 4.6 12.1 10
@@ -227,12 +226,6 @@ Transform-Specific Command Line Options
projects that use such macros to maintain build compatibility with non-C++11
code.
-.. option:: -pass-by-value
-
- Replace const-reference parameters by values in situations where it can be
- beneficial.
- See :doc:`PassByValueTransform`.
-
.. option:: -replace-auto_ptr
Replace ``std::auto_ptr`` (deprecated in C++11) by ``std::unique_ptr`` and
Removed: clang-tools-extra/trunk/docs/PassByValueTransform.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/PassByValueTransform.rst?rev=189386&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/PassByValueTransform.rst (original)
+++ clang-tools-extra/trunk/docs/PassByValueTransform.rst (removed)
@@ -1,137 +0,0 @@
-.. index:: Pass-By-Value Transform
-
-=======================
-Pass-By-Value Transform
-=======================
-
-The Pass-By-Value Transform makes use of the pass-by-value idiom when possible.
-
-With move semantics added to the language and the standard library updated with
-move constructors added for many types it is now interesting to take an argument
-directly by value, instead of by const-reference, and then copy. This
-transformation allows the compiler to take care of choosing the best way to
-construct the copy.
-
-The transformation is usually beneficial when the calling code passes an
-*rvalue* and assumes the move construction is a cheap operation. This short
-example illustrates how the construction of the value happens:
-
- .. code-block:: c++
-
- void foo(std::string s);
- std::string get_str();
-
- void f(const std::string &str) {
- foo(str); // lvalue -> copy construction
- foo(get_str()); // prvalue -> move construction
- }
-
-.. note::
-
- Currently only constructors are transformed to make use of pass-by-value.
- Contributions that handle other situations are welcome!
-
-
-Pass-by-value in constructors
------------------------------
-
-Replaces the uses of const-references constructor parameters that are copied
-into class fields. The parameter is then moved with `std::move()`.
-
-Since `std::move()` is a library function declared in `<utility>` it may be
-necessary to add this include. The transform will add the include directive when
-necessary.
-
-Example::
-
- $ cpp11-migrate -pass-by-value ctor.cpp
-
-**ctor.cpp**
-
- .. code-block:: c++
-
- #include <string>
-
- class Foo {
- public:
- - Foo(const std::string &Copied, const std::string &ReadOnly)
- - : Copied(Copied), ReadOnly(ReadOnly)
- + Foo(std::string Copied, const std::string &ReadOnly)
- + : Copied(std::move(Copied)), ReadOnly(ReadOnly)
- {}
-
- private:
- std::string Copied;
- const std::string &ReadOnly;
- };
-
- std::string get_cwd();
-
- void f(const std::string &Path) {
- // The parameter corresponding to 'get_cwd()' is move-constructed. By
- // using pass-by-value in the Foo constructor we managed to avoid a
- // copy-construction.
- Foo foo(get_cwd(), Path);
- }
-
-
-If the parameter is used more than once no transformation is performed since
-moved objects have an undefined state. It means the following code will be left
-untouched:
-
-.. code-block:: c++
-
- #include <string>
-
- void pass(const std::string &S);
-
- struct Foo {
- Foo(const std::string &S) : Str(S) {
- pass(S);
- }
-
- std::string Str;
- };
-
-
-Risk
-^^^^
-
-This modification is considered **reasonably safe** (see :option:`-risk`
-option).
-
-A situation where the generated code can be wrong is when the object referenced
-is modified before the assignment in the init-list through a "hidden" reference.
-
-Example:
-
-.. code-block:: c++
-
- std::string s("foo");
-
- struct Base {
- Base() {
- s = "bar";
- }
- };
-
- struct Derived : Base {
- - Derived(const std::string &S) : Field(S)
- + Derived(std::string S) : Field(std::move(S))
- { }
-
- std::string Field;
- };
-
- void f() {
- - Derived d(s); // d.Field holds "bar"
- + Derived d(s); // d.Field holds "foo"
- }
-
-
-.. seealso::
-
- For more information about this idiom, read: `Want Speed? Pass by Value`_.
-
- .. _Want Speed? Pass by Value: http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
-
Modified: clang-tools-extra/trunk/docs/cpp11-migrate.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/cpp11-migrate.rst?rev=189387&r1=189386&r2=189387&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/cpp11-migrate.rst (original)
+++ clang-tools-extra/trunk/docs/cpp11-migrate.rst Tue Aug 27 12:26:07 2013
@@ -11,7 +11,6 @@ C++11 Migrator User's Manual
UseNullptrTransform
LoopConvertTransform
AddOverrideTransform
- PassByValueTransform
ReplaceAutoPtrTransform
MigratorUsage
@@ -117,6 +116,4 @@ independently enabled. The transforms cu
* :doc:`AddOverrideTransform`
-* :doc:`PassByValueTransform`
-
* :doc:`ReplaceAutoPtrTransform`
More information about the cfe-commits
mailing list