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

57 lines
1.4 KiB
C++

#ifndef INPUTS_BASIC_H
#define INPUTS_BASIC_H
#include "memory_stub.h"
// Instrumentation for auto_ptr_ref test
// @{
struct Base {};
struct Derived : Base {};
std::auto_ptr<Derived> create_derived_ptr();
// CHECK: std::unique_ptr<Derived> create_derived_ptr();
// }
// Test function return values (declaration)
std::auto_ptr<char> f_5();
// CHECK: std::unique_ptr<char> f_5()
// Test function parameters
void f_6(std::auto_ptr<int>);
// CHECK: void f_6(std::unique_ptr<int>);
void f_7(const std::auto_ptr<int> &);
// CHECK: void f_7(const std::unique_ptr<int> &);
// Test on record type fields
struct A {
std::auto_ptr<int> field;
// CHECK: std::unique_ptr<int> field;
typedef std::auto_ptr<int> int_ptr_type;
// CHECK: typedef std::unique_ptr<int> int_ptr_type;
};
// Test template WITH instantiation
template <typename T> struct B {
typedef typename std::auto_ptr<T> created_type;
// CHECK: typedef typename std::unique_ptr<T> created_type;
created_type create() { return std::auto_ptr<T>(new T()); }
// CHECK: created_type create() { return std::unique_ptr<T>(new T()); }
};
// Test 'using' in a namespace (declaration)
namespace ns_1 {
// Test multiple using declarations
using std::auto_ptr;
using std::auto_ptr;
// CHECK: using std::unique_ptr;
// CHECK-NEXT: using std::unique_ptr;
}
namespace ns_2 {
template <typename T> struct auto_ptr {};
// CHECK: template <typename T> struct auto_ptr {};
}
#endif // INPUTS_BASIC_H