Edwin Vane 5ee6110817 cpp11-migrate: Add Replace-AutoPtr Transform
Add a new transform to replace uses of 'std::auto_ptr' by 'std::unique_ptr'.
Copy-ctor and assign-operator are wrapped with a call to 'std::move()'.

Note that until header modification is ready it is not that useful, that's why
it's marked as (EXPERIMENTAL) in the command line description and a "Known
Limitations" section is present in the transform documentation.

Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 185535
2013-07-03 13:21:24 +00:00

32 lines
1008 B
C++

// XFAIL: *
//
// Without inline namespace:
//
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
// RUN: cpp11-migrate -replace-auto_ptr %t.cpp -- -I %S/Inputs std=c++11
// RUN: FileCheck -input-file=%t.cpp %s
//
// With inline namespace:
//
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
// RUN: cpp11-migrate -replace-auto_ptr %t.cpp -- -I %S/Inputs std=c++11 \
// RUN: -DUSE_INLINE_NAMESPACE=1
// RUN: FileCheck -input-file=%t.cpp %s
#include "memory_stub.h"
// Fail to modify when the template is never instantiated.
//
// This might not be an issue. If it's never used it doesn't really matter if
// it's changed or not. If it's a header and one of the source use it, then it
// will still be changed.
template <typename X>
void f() {
std::auto_ptr<X> p;
// CHECK: std::unique_ptr<X> p;
}
// Alias template could be replaced if a matcher existed.
template <typename T> using aaaaaaaa = auto_ptr<T>;
// CHECK: template <typename T> using aaaaaaaa = unique_ptr<T>;