diff options
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate')
49 files changed, 0 insertions, 3897 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp b/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp deleted file mode 100644 index 41a50eb5e31..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -add-override %t.cpp -- -I %S -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -add-override -override-macros %t.cpp -- -I %S -std=c++11 -// RUN: FileCheck --check-prefix=MACRO --input-file=%t.cpp %s - -struct A { - virtual ~A(); - // CHECK: virtual ~A(); - void f(); - virtual void h() const; - // CHECK: virtual void h() const; - virtual void i() = 0; - // CHECK: virtual void i() = 0; -}; - -// Test that override isn't added to non-virtual functions. -struct B : public A { - void f(); - // CHECK: struct B - // CHECK-NEXT: void f(); -}; - -// Test that override is added to functions that override virtual functions. -struct C : public A { - void h() const; - // CHECK: struct C - // CHECK-NEXT: void h() const override; - // MACRO: struct C - // MACRO-NEXT: void h() const override; -}; - -// Test that override isn't add to functions that overload but not override. -struct D : public A { - void h(); - // CHECK: struct D - // CHECK-NEXT: void h(); -}; - -// Test that override isn't added again to functions that already have it. -struct E : public A { - void h() const override; - // CHECK: struct E - // CHECK-NEXT: void h() const override; - // MACRO: struct E - // MACRO-NEXT: void h() const override; -}; - -// Test that override isn't added to the destructor. -struct F : public A { - virtual ~F(); - // CHECK: struct F - // CHECK-NEXT: virtual ~F(); -}; - -// Test that override is placed before any end of line comments. -struct G : public A { - void h() const; // comment - void i() // comment - {} - // CHECK: struct G - // CHECK-NEXT: void h() const override; // comment - // CHECK-NEXT: void i() override // comment - // CHECK-NEXT: {} -}; - -// Test that override is placed correctly if there is an inline body. -struct H : public A { - void h() const { } - // CHECK: struct H - // CHECK-NEXT: void h() const override { } -}; - -// Test that override is placed correctly if there is a body on the next line. -struct I : public A { - void h() const - { } - // CHECK: struct I - // CHECK-NEXT: void h() const override - // CHECK-NEXT: { } -}; - -// Test that override is placed correctly if there is a body outside the class. -struct J : public A { - void h() const; - // CHECK: struct J - // CHECK-NEXT: void h() const override; -}; - -void J::h() const { - // CHECK: void J::h() const { -} - -// Test that override is placed correctly if there is a trailing return type. -struct K : public A { - auto h() const -> void; - // CHECK: struct K - // CHECK-NEXT: auto h() const -> void override; -}; - -#define LLVM_OVERRIDE override - -// Test that override isn't added if it is already specified via a macro. -struct L : public A { - void h() const LLVM_OVERRIDE; - // CHECK: struct L - // CHECK-NEXT: void h() const LLVM_OVERRIDE; - // MACRO: struct L - // MACRO-NEXT: void h() const LLVM_OVERRIDE; -}; - -template <typename T> -struct M : public A { - virtual void i(); - // CHECK: struct M - // CHECK-NEXT: virtual void i() override; - // MACRO: struct M - // MACRO-NEXT: virtual void i() LLVM_OVERRIDE; -}; -M<int> b; - -// Test that override isn't added at the wrong place for "pure overrides" -struct APure { - virtual APure *clone() = 0; -}; -struct BPure : APure { - virtual BPure *clone() { return new BPure(); } -}; -struct CPure : BPure { - virtual BPure *clone() = 0; - // CHECK: struct CPure : BPure { - // CHECK-NOT: virtual BPure *clone() = 0 override; - // CHECK: }; -}; -struct DPure : CPure { - virtual DPure *clone() { return new DPure(); } -}; - -// Test that override is not added on dangerous template constructs -struct Base1 { - virtual void f(); -}; -struct Base2 {}; -template<typename T> struct Derived : T { - void f(); // adding 'override' here will break instantiation of Derived<Base2> - // CHECK: struct Derived - // CHECK-NEXT: void f(); -}; -Derived<Base1> d1; -Derived<Base2> d2; - -#undef LLVM_OVERRIDE - -struct N : public A { - void h() const; - // CHECK: struct N - // CHECK-NEXT: void h() const override; - // MACRO: struct N - // MACRO-NEXT: void h() const override; -}; diff --git a/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp b/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp deleted file mode 100644 index a9d4c912ff1..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -add-override %t.cpp -- -I %S -// RUN: FileCheck -input-file=%t.cpp %s -// XFAIL: * - -// Test that override isn't placed correctly after "pure overrides" -struct A { - virtual A *clone() = 0; -}; -struct B : A { - virtual B *clone() { return new B(); } -}; -struct C : B { - virtual B *clone() = 0; - // CHECK: struct C : B { - // CHECK: virtual B *clone() override = 0; -}; -struct D : C { - virtual D *clone() { return new D(); } -}; diff --git a/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp b/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp deleted file mode 100644 index 6971879e576..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/Combined/combined.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t_risky.cpp -// RUN: cpp11-migrate -loop-convert -use-nullptr %t.cpp -- -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: cpp11-migrate -loop-convert -use-nullptr -risk=risky %t_risky.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=RISKY -input-file=%t_risky.cpp %s - -#define NULL 0 - -struct T { - struct iterator { - int *& operator*(); - const int *& operator*() const; - iterator & operator++(); - bool operator!=(const iterator &other); - void insert(int *); - int *x; - }; - - iterator begin(); - iterator end(); -}; - -void test_loopconvert_and_nullptr_iterator() { - T t; - - for (T::iterator it = t.begin(); it != t.end(); ++it) { - *it = NULL; - } - - // CHECK: for (auto & elem : t) - // CHECK-NEXT: elem = nullptr; -} - -void test_loopconvert_and_nullptr_risky() { - const int N = 10; - int *(*pArr)[N]; - - for (int i = 0; i < N; ++i) { - (*pArr)[i] = NULL; - } - - // RISKY: for (auto & elem : *pArr) - // RISKY-NEXT: elem = nullptr; -} diff --git a/clang-tools-extra/test/cpp11-migrate/Combined/compilers.cpp b/clang-tools-extra/test/cpp11-migrate/Combined/compilers.cpp deleted file mode 100644 index 14b29978693..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/Combined/compilers.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=clang-2.9 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=CLANG-29 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=clang-2.9 -override-macros %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=CLANG-29-OV-MACROS -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=clang-3.0 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=CLANG-30 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=gcc-4.6 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=GCC-46 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=gcc-4.7 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=GCC-47 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=icc-13 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=ICC-13 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=icc-14 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=ICC-14 -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=msvc-8 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=MSVC-8 -input-file=%t.cpp %s -// -// Test multiple compilers -// RUN: grep -Ev "// *[A-Z0-9-]+:" %s > %t.cpp -// RUN: cpp11-migrate -for-compilers=clang-3.0,gcc-4.6,gcc-4.7 %t.cpp -- -std=c++11 -// RUN: FileCheck -check-prefix=MULTIPLE -input-file=%t.cpp %s -// -// Test unknown platform -// RUN: not cpp11-migrate -for-compilers=foo-10 %t.cpp -- -std=c++11 -// -// Test when no transforms can be selected because the compiler lacks support of -// the needed C++11 features -// RUN: not cpp11-migrate -for-compilers=clang-2.0 %t.cpp -- -std=c++11 - -// Test add overrides -struct A { - virtual A *clone() = 0; -}; - -#define LLVM_OVERRIDE override - -struct B : A { - virtual B *clone(); - // CLANG-29-OV-MACROS: virtual B *clone() LLVM_OVERRIDE; - // CLANG-29: virtual B *clone(); - // CLANG-30: virtual B *clone() override; - // GCC-46: virtual B *clone(); - // GCC-47: virtual B *clone() override; - // ICC-13: virtual B *clone(); - // ICC-14: virtual B *clone() override; - // MSVC-8: virtual B *clone() override; - // MULTIPLE: virtual B *clone(); -}; diff --git a/clang-tools-extra/test/cpp11-migrate/Core/Reformatting.cpp b/clang-tools-extra/test/cpp11-migrate/Core/Reformatting.cpp deleted file mode 100644 index a98d1e2fb0d..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/Core/Reformatting.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: not cpp11-migrate -format-style=non_existent_file.yaml -use-auto %t.cpp -- -std=c++11 -// RUN: touch %T/non_format_config.yaml -// RUN: not cpp11-migrate -format-style=%T/non_format_config.yaml -use-auto %t.cpp -- -std=c++11 -// RUN: cpp11-migrate -format-style=LLVM -use-auto %t.cpp -- -std=c++11 -// RUN: FileCheck --strict-whitespace -input-file=%t.cpp %s - -class MyType012345678901234567890123456789 {}; - -int f() { - MyType012345678901234567890123456789 *a = - new MyType012345678901234567890123456789(); - // CHECK: {{^\ \ auto\ a\ \=\ new\ MyType012345678901234567890123456789\(\);}} - - delete a; -} diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h deleted file mode 100644 index 8e09412c452..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h +++ /dev/null @@ -1,8 +0,0 @@ -void update(int (&arr)[10]) { - int val = 1; - for (unsigned i = 0; i < sizeof(arr)/sizeof(int); ++i) { - arr[i] = val++; - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: elem = val++; - } -} diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.cpp b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.cpp deleted file mode 100644 index 9c4f0e543ce..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// This is just a dummy run command to keep lit happy. Tests for this file are -// in main.cpp -// RUN: true - -#include "common.h" - -void func1(int &I) { -} - -void func2() { - container C1; - container C2; - for (container::iterator I = C1.begin(), E = C1.end(); I != E; ++I) { - C2.push_back(*I); - } -} diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h deleted file mode 100644 index 3bb98cc705c..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef CPP11_MIGRATE_TEST_HEADER_REPLACEMENTS_COMMON_H -#define CPP11_MIGRATE_TEST_HEADER_REPLACEMENTS_COMMON_H - -struct container { - struct iterator { - int &operator*(); - const int &operator*() const; - iterator &operator++(); - bool operator!=(const iterator &other); - }; - - iterator begin(); - iterator end(); - void push_back(const int &); -}; - -void func1(int &I); -void func2(); - -void dostuff() { - container C; - for (container::iterator I = C.begin(), E = C.end(); I != E; ++I) { - func1(*I); - } -} - -#endif // CPP11_MIGRATE_TEST_HEADER_REPLACEMENTS_COMMON_H diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml deleted file mode 100644 index 67eb1fb9104..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -MainSourceFile: "$(path)/common.cpp" -Replacements: - - FilePath: "$(path)/common.h" - Offset: 506 - Length: 2 - ReplacementText: "elem" - - FilePath: "$(path)/common.h" - Offset: 432 - Length: 61 - ReplacementText: "(auto & elem : C)" - - FilePath: "$(path)/common.cpp" - Offset: 289 - Length: 2 - ReplacementText: "elem" - - FilePath: "$(path)/common.cpp" - Offset: 206 - Length: 63 - ReplacementText: "(auto & elem : C1)" -... diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp deleted file mode 100644 index 54cbc92728e..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following block tests the following: -// - Only 1 file is generated per translation unit -// - Replacements are written in YAML that matches the expected YAML file -// The test is run in %T/SerializeTest so it's easy to create a clean test -// directory. -// -// RUN: rm -rf %T/SerializeTest -// RUN: mkdir -p %T/SerializeTest -// RUN: cp %S/main.cpp %S/common.cpp %S/common.h %T/SerializeTest -// RUN: cpp11-migrate -loop-convert -headers -serialize-replacements -include=%T/SerializeTest %T/SerializeTest/main.cpp %T/SerializeTest/common.cpp -- -// Check that only 1 file is generated per translation unit -// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=MAIN_CPP -// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=COMMON_CPP -// We need to put the build path to the expected YAML file to diff against the generated one. -// RUN: sed -e 's#$(path)#%/T/SerializeTest#g' %S/main_expected.yaml > %T/SerializeTest/main_expected.yaml -// RUN: sed -i -e 's#\\#/#g' %T/SerializeTest/main.cpp_*.yaml -// RUN: diff -b %T/SerializeTest/main_expected.yaml %T/SerializeTest/main.cpp_*.yaml -// RUN: sed -e 's#$(path)#%/T/SerializeTest#g' %S/common_expected.yaml > %T/SerializeTest/common_expected.yaml -// RUN: sed -i -e 's#\\#/#g' %T/SerializeTest/common.cpp_*.yaml -// RUN: diff -b %T/SerializeTest/common_expected.yaml %T/SerializeTest/common.cpp_*.yaml -// -// The following are for FileCheck when used on output of 'ls'. See above. -// MAIN_CPP: {{^main.cpp_.*.yaml$}} -// MAIN_CPP-NOT: {{main.cpp_.*.yaml}} -// -// COMMON_CPP: {{^common.cpp_.*.yaml$}} -// COMMON_CPP-NOT: {{common.cpp_.*.yaml}} - -#include "common.h" - -void test_header_replacement() { - dostuff(); - func2(); -} diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml deleted file mode 100644 index 8702bc17245..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -MainSourceFile: "$(path)/main.cpp" -Replacements: - - FilePath: "$(path)/common.h" - Offset: 506 - Length: 2 - ReplacementText: "elem" - - FilePath: "$(path)/common.h" - Offset: 432 - Length: 61 - ReplacementText: "(auto & elem : C)" -... diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp deleted file mode 100644 index 880cc1f5a70..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Ensure that if -serialize-replacements is not provided, no serialized -// replacement files should be generated and the changes are made directly. -// -// RUN: mkdir -p %T/Inputs -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/no_yaml.h > %T/Inputs/no_yaml.h -// RUN: cpp11-migrate -loop-convert %t.cpp -headers -include=%T/Inputs -- -I %T/Inputs/no_yaml.h -// RUN: FileCheck --input-file=%t.cpp %s -// RUN: FileCheck --input-file=%T/Inputs/no_yaml.h %S/Inputs/no_yaml.h -// RUN: ls -1 %T | FileCheck %s --check-prefix=NO_YAML -// -// NO_YAML-NOT: {{no_yaml.cpp_.*.yaml}} -#include "Inputs/no_yaml.h" - -void func() { - int arr[10]; - for (unsigned i = 0; i < sizeof(arr)/sizeof(int); ++i) { - arr[i] = 0; - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: elem = 0; - } - - update(arr); -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/macro_problem.h b/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/macro_problem.h deleted file mode 100644 index 42f28fde703..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/macro_problem.h +++ /dev/null @@ -1,7 +0,0 @@ -#define myns nsblah - -namespace nsblah { -struct MyType { -}; - -} // namespace nsblah diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/negative-header.h b/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/negative-header.h deleted file mode 100644 index 3962032da9d..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/negative-header.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef NEGATIVE_HEADER_H -#define NEGATIVE_HEADER_H - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) -static void loopInHeader() { - const int N = 10; - int arr[N]; - int sum = 0; - for (int i = 0; i < N; ++i) - sum += arr[i]; -} - -#endif // NEGATIVE_HEADER_H diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h b/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h deleted file mode 100644 index 9dd04f42b5a..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/Inputs/structures.h +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef STRUCTURES_H -#define STRUCTURES_H - -extern "C" { -extern int printf(const char *restrict, ...); -} - -struct Val {int x; void g(); }; - -struct MutableVal { - void constFun(int) const; - void nonConstFun(int, int); - void constFun(MutableVal &) const; - void constParamFun(const MutableVal &) const; - void nonConstParamFun(const MutableVal &); - int x; -}; - -struct S { - typedef MutableVal *iterator; - typedef const MutableVal *const_iterator; - const_iterator begin() const; - const_iterator end() const; - iterator begin(); - iterator end(); -}; - -struct T { - struct iterator { - int& operator*(); - const int& operator*()const; - iterator& operator ++(); - bool operator!=(const iterator &other); - void insert(int); - int x; - }; - iterator begin(); - iterator end(); -}; - -struct U { - struct iterator { - Val& operator*(); - const Val& operator*()const; - iterator& operator ++(); - bool operator!=(const iterator &other); - Val *operator->(); - }; - iterator begin(); - iterator end(); - int x; -}; - -struct X { - S s; - T t; - U u; - S getS(); -}; - -template<typename ElemType> -class dependent{ - public: - struct iterator_base { - const ElemType& operator*()const; - iterator_base& operator ++(); - bool operator!=(const iterator_base &other) const; - const ElemType *operator->() const; - }; - - struct iterator : iterator_base { - ElemType& operator*(); - iterator& operator ++(); - ElemType *operator->(); - }; - - typedef iterator_base const_iterator; - const_iterator begin() const; - const_iterator end() const; - iterator begin(); - iterator end(); - unsigned size() const; - ElemType & operator[](unsigned); - const ElemType & operator[](unsigned) const; - ElemType & at(unsigned); - const ElemType & at(unsigned) const; - - // Intentionally evil. - dependent<ElemType> operator*(); - - void foo(); - void constFoo() const; -}; - -template<typename First, typename Second> -class doublyDependent{ - public: - struct Value { - First first; - Second second; - }; - - struct iterator_base { - const Value& operator*()const; - iterator_base& operator ++(); - bool operator!=(const iterator_base &other) const; - const Value *operator->() const; - }; - - struct iterator : iterator_base { - Value& operator*(); - Value& operator ++(); - Value *operator->(); - }; - - typedef iterator_base const_iterator; - const_iterator begin() const; - const_iterator end() const; - iterator begin(); - iterator end(); -}; - -template<typename Contained> -class transparent { - public: - Contained *at(); - Contained *operator->(); - Contained operator*(); -}; - -template<typename IteratorType> -struct Nested { - typedef IteratorType* iterator; - typedef const IteratorType* const_iterator; - IteratorType *operator->(); - IteratorType operator*(); - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; -}; - -// Like llvm::SmallPtrSet, the iterator has a dereference operator that returns -// by value instead of by reference. -template <typename T> -struct PtrSet { - struct iterator { - bool operator!=(const iterator &other) const; - const T operator*(); - iterator &operator++(); - }; - iterator begin() const; - iterator end() const; -}; - -template <typename T> -struct TypedefDerefContainer { - struct iterator { - typedef T &deref_type; - bool operator!=(const iterator &other) const; - deref_type operator*(); - iterator &operator++(); - }; - iterator begin() const; - iterator end() const; -}; - -template <typename T> -struct RValueDerefContainer { - struct iterator { - typedef T &&deref_type; - bool operator!=(const iterator &other) const; - deref_type operator*(); - iterator &operator++(); - }; - iterator begin() const; - iterator end() const; -}; -#endif // STRUCTURES_H diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/array.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/array.cpp deleted file mode 100644 index 780fc3746bf..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/array.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cp %t.cpp %t.base -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: cp %t.base %t.cpp -// NORUN cpp11-migrate -count-only . %t.cpp -- -I %S/Inputs > %T/out -// NORUN FileCheck -check-prefix=COUNTONLY -input-file=%T/out %s -// RUN: diff %t.cpp %t.base - -#include "structures.h" - -const int N = 6; -const int NMinusOne = N - 1; -int arr[N] = {1, 2, 3, 4, 5, 6}; -int (*pArr)[N] = &arr; - -void f() { - int sum = 0; - // Update the number of correctly converted loops as this test changes: - // COUNTONLY: 15 converted - // COUNTONLY-NEXT: 0 potentially conflicting - // COUNTONLY-NEXT: 0 change(s) rejected - - for (int i = 0; i < N; ++i) { - sum += arr[i]; - int k; - } - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: sum += elem; - // CHECK-NEXT: int k; - // CHECK-NEXT: } - - for (int i = 0; i < N; ++i) { - printf("Fibonacci number is %d\n", arr[i]); - sum += arr[i] + 2; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; - - for (int i = 0; i < N; ++i) { - int x = arr[i]; - int y = arr[i] + 2; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: int x = elem; - // CHECK-NEXT: int y = elem + 2; - - for (int i = 0; i < N; ++i) { - int x = N; - x = arr[i]; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: int x = N; - // CHECK-NEXT: x = elem; - - for (int i = 0; i < N; ++i) { - arr[i] += 1; - } - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: elem += 1; - // CHECK-NEXT: } - - for (int i = 0; i < N; ++i) { - int x = arr[i] + 2; - arr[i] ++; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: int x = elem + 2; - // CHECK-NEXT: elem ++; - - for (int i = 0; i < N; ++i) { - arr[i] = 4 + arr[i]; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: elem = 4 + elem; - - for (int i = 0; i < NMinusOne + 1; ++i) { - sum += arr[i]; - } - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: sum += elem; - // CHECK-NEXT: } - - for (int i = 0; i < N; ++i) { - printf("Fibonacci number %d has address %p\n", arr[i], &arr[i]); - sum += arr[i] + 2; - } - // CHECK: for (auto & elem : arr) - // CHECK-NEXT: printf("Fibonacci number %d has address %p\n", elem, &elem); - // CHECK-NEXT: sum += elem + 2; - - Val teas[N]; - for (int i = 0; i < N; ++i) { - teas[i].g(); - } - // CHECK: for (auto & tea : teas) { - // CHECK-NEXT: tea.g(); - // CHECK-NEXT: } -} - -struct HasArr { - int Arr[N]; - Val ValArr[N]; - void implicitThis() { - for (int i = 0; i < N; ++i) { - printf("%d", Arr[i]); - } - // CHECK: for (auto & elem : Arr) { - // CHECK-NEXT: printf("%d", elem); - // CHECK-NEXT: } - - for (int i = 0; i < N; ++i) { - printf("%d", ValArr[i].x); - } - // CHECK: for (auto & elem : ValArr) { - // CHECK-NEXT: printf("%d", elem.x); - // CHECK-NEXT: } - } - - void explicitThis() { - for (int i = 0; i < N; ++i) { - printf("%d", this->Arr[i]); - } - // CHECK: for (auto & elem : this->Arr) { - // CHECK-NEXT: printf("%d", elem); - // CHECK-NEXT: } - - for (int i = 0; i < N; ++i) { - printf("%d", this->ValArr[i].x); - } - // CHECK: for (auto & elem : this->ValArr) { - // CHECK-NEXT: printf("%d", elem.x); - // CHECK-NEXT: } - } -}; - -// Loops whose bounds are value-dependent shold not be converted. -template<int N> -void dependentExprBound() { - for (int i = 0; i < N; ++i) - arr[i] = 0; - // CHECK: for (int i = 0; i < N; ++i) - // CHECK-NEXT: arr[i] = 0; -} -template void dependentExprBound<20>(); - -void memberFunctionPointer() { - Val v; - void (Val::*mfpArr[N])(void) = { &Val::g }; - for (int i = 0; i < N; ++i) - (v.*mfpArr[i])(); - // CHECK: for (auto & elem : mfpArr) - // CHECK-NEXT: (v.*elem)(); -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/confidence.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/confidence.cpp deleted file mode 100644 index 8c130f165b9..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/confidence.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: cpp11-migrate -loop-convert %t.cpp -risk=risky -- -I %S/Inputs -// RUN: FileCheck -check-prefix=RISKY -input-file=%t.cpp %s - -#include "structures.h" - -void f() { - const int N = 5; - const int M = 7; - int (*pArr)[N]; - int Arr[N][M]; - int sum = 0; - - for (int i = 0; i < M; ++i) { - sum += Arr[0][i]; - } - // CHECK: for (int i = 0; i < M; ++i) { - // CHECK-NEXT: sum += Arr[0][i]; - // CHECK-NEXT: } - // RISKY: for (auto & elem : Arr[0]) { - // RISKY-NEXT: sum += elem; - // RISKY-NEXT: } - - for (int i = 0; i < N; ++i) { - sum += (*pArr)[i]; - } - // RISKY: for (auto & elem : *pArr) { - // RISKY-NEXT: sum += elem; - // RISKY-NEXT: } - // CHECK: for (int i = 0; i < N; ++i) { - // CHECK-NEXT: sum += (*pArr)[i]; - // CHECK-NEXT: } -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/dependency.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/dependency.cpp deleted file mode 100644 index 15fffbab812..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/dependency.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- && FileCheck -input-file=%t.cpp %s - -void f() { - const int N = 6; - const int M = 8; - int arr[N][M]; - - for (int i = 0; i < N; ++i) { - int a = 0; - int b = arr[i][a]; - } - // CHECK: for (auto & elem : arr) { - // CHECK-NEXT: int a = 0; - // CHECK-NEXT: int b = elem[a]; - // CHECK-NEXT: } - - for (int j = 0; j < M; ++j) { - int a = 0; - int b = arr[a][j]; - } - // CHECK: for (int j = 0; j < M; ++j) { - // CHECK-NEXT: int a = 0; - // CHECK-NEXT: int b = arr[a][j]; - // CHECK-NEXT: } -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp deleted file mode 100644 index 27f7e8bf75e..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/free_begin_end_fail.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -// XFAIL: * - -struct MyArray { - unsigned size(); -}; - -template <typename T> -struct MyContainer { -}; - -int *begin(const MyArray &Arr); -int *end(const MyArray &Arr); - -template <typename T> -T *begin(const MyContainer<T> &C); -template <typename T> -T *end(const MyContainer<T> &C); - -// The Loop Convert Transform doesn't detect free functions begin()/end() and -// so fails to transform these cases which it should. -void f() { - MyArray Arr; - for (unsigned i = 0, e = Arr.size(); i < e; ++i) {} - // CHECK: for (auto & elem : Arr) {} - - MyContainer<int> C; - for (int *I = begin(C), *E = end(C); I != E; ++I) {} - // CHECK: for (auto & elem : C) {} -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp deleted file mode 100644 index b8ba61b0a02..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/iterator.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: cpp11-migrate -loop-convert %t.cpp -risk=risky -- -I %S/Inputs -// RUN: FileCheck -check-prefix=RISKY -input-file=%t.cpp %s - -#include "structures.h" - -void f() { - /// begin()/end() - based for loops here: - T t; - for (T::iterator it = t.begin(), e = t.end(); it != e; ++it) { - printf("I found %d\n", *it); - } - // CHECK: for (auto & elem : t) - // CHECK-NEXT: printf("I found %d\n", elem); - - T *pt; - for (T::iterator it = pt->begin(), e = pt->end(); it != e; ++it) { - printf("I found %d\n", *it); - } - // CHECK: for (auto & elem : *pt) - // CHECK-NEXT: printf("I found %d\n", elem); - - S s; - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - S *ps; - for (S::iterator it = ps->begin(), e = ps->end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & p : *ps) - // CHECK-NEXT: printf("s has value %d\n", (p).x); - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - printf("s has value %d\n", it->x); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", elem.x); - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - it->x = 3; - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: elem.x = 3; - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - (*it).x = 3; - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: (elem).x = 3; - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - it->nonConstFun(4, 5); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: elem.nonConstFun(4, 5); - - U u; - for (U::iterator it = u.begin(), e = u.end(); it != e; ++it) { - printf("s has value %d\n", it->x); - } - // CHECK: for (auto & elem : u) - // CHECK-NEXT: printf("s has value %d\n", elem.x); - - for (U::iterator it = u.begin(), e = u.end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & elem : u) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - U::iterator A; - for (U::iterator i = u.begin(), e = u.end(); i != e; ++i) - int k = A->x + i->x; - // CHECK: for (auto & elem : u) - // CHECK-NEXT: int k = A->x + elem.x; - - dependent<int> v; - for (dependent<int>::iterator it = v.begin(), e = v.end(); - it != e; ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (auto & elem : v) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - - for (dependent<int>::iterator it(v.begin()), e = v.end(); - it != e; ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (auto & elem : v) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - - doublyDependent<int,int> intmap; - for (doublyDependent<int,int>::iterator it = intmap.begin(), e = intmap.end(); - it != e; ++it) { - printf("intmap[%d] = %d", it->first, it->second); - } - // CHECK: for (auto & elem : intmap) - // CHECK-NEXT: printf("intmap[%d] = %d", elem.first, elem.second); - - // PtrSet's iterator dereferences by value so auto & can't be used. - { - PtrSet<int*> int_ptrs; - for (PtrSet<int*>::iterator I = int_ptrs.begin(), - E = int_ptrs.end(); I != E; ++I) { - // CHECK: for (auto && int_ptr : int_ptrs) { - } - } - - // This container uses an iterator where the derefence type is a typedef of - // a reference type. Make sure non-const auto & is still used. A failure here - // means canonical types aren't being tested. - { - TypedefDerefContainer<int> int_ptrs; - for (TypedefDerefContainer<int>::iterator I = int_ptrs.begin(), - E = int_ptrs.end(); I != E; ++I) { - // CHECK: for (auto & int_ptr : int_ptrs) { - } - } - - { - // Iterators returning an rvalue reference should disqualify the loop from - // transformation. - RValueDerefContainer<int> container; - for (RValueDerefContainer<int>::iterator I = container.begin(), - E = container.end(); I != E; ++I) { - // CHECK: for (RValueDerefContainer<int>::iterator I = container.begin(), - // CHECK-NEXT: E = container.end(); I != E; ++I) { - } - } -} - -// Tests to verify the proper use of auto where the init variable type and the -// initializer type differ or are mostly the same except for const qualifiers. -void different_type() { - // s.begin() returns a type 'iterator' which is just a non-const pointer and - // differs from const_iterator only on the const qualification. - S s; - for (S::const_iterator it = s.begin(), e = s.end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (const auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - S *ps; - for (S::const_iterator it = ps->begin(), e = ps->end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (const auto & p : *ps) - // CHECK-NEXT: printf("s has value %d\n", (p).x); - - // v.begin() returns a user-defined type 'iterator' which, since it's - // different from const_iterator, disqualifies these loops from - // transformation. - dependent<int> v; - for (dependent<int>::const_iterator it = v.begin(), e = v.end(); - it != e; ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (dependent<int>::const_iterator it = v.begin(), e = v.end(); - // CHECK-NEXT: it != e; ++it) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", *it); - - for (dependent<int>::const_iterator it(v.begin()), e = v.end(); - it != e; ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (dependent<int>::const_iterator it(v.begin()), e = v.end(); - // CHECK-NEXT: it != e; ++it) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", *it); -} - -// Tests to ensure that an implicit 'this' is picked up as the container. -// If member calls are made to 'this' within the loop, the transform becomes -// risky as these calls may affect state that affects the loop. -class C { -public: - typedef MutableVal *iterator; - typedef const MutableVal *const_iterator; - - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; - - void doSomething(); - void doSomething() const; - - void doLoop() { - for (iterator I = begin(), E = end(); I != E; ++I) { - // CHECK: for (auto & elem : *this) { - } - for (iterator I = C::begin(), E = C::end(); I != E; ++I) { - // CHECK: for (auto & elem : *this) { - } - for (iterator I = begin(), E = end(); I != E; ++I) { - // CHECK: for (iterator I = begin(), E = end(); I != E; ++I) { - // RISKY: for (auto & elem : *this) { - doSomething(); - } - for (iterator I = begin(); I != end(); ++I) { - // CHECK: for (auto & elem : *this) { - } - for (iterator I = begin(); I != end(); ++I) { - // CHECK: for (iterator I = begin(); I != end(); ++I) { - // RISKY: for (auto & elem : *this) { - doSomething(); - } - } - - void doLoop() const { - for (const_iterator I = begin(), E = end(); I != E; ++I) { - // CHECK: for (auto & elem : *this) { - } - for (const_iterator I = C::begin(), E = C::end(); I != E; ++I) { - // CHECK: for (auto & elem : *this) { - } - for (const_iterator I = begin(), E = end(); I != E; ++I) { - // CHECK: for (const_iterator I = begin(), E = end(); I != E; ++I) { - // RISKY: for (auto & elem : *this) { - doSomething(); - } - } -}; - -class C2 { -public: - typedef MutableVal *iterator; - - iterator begin() const; - iterator end() const; - - void doLoop() { - // The implicit 'this' will have an Implicit cast to const C2* wrapped - // around it. Make sure the replacement still happens. - for (iterator I = begin(), E = end(); I != E; ++I) { - // CHECK: for (auto & elem : *this) { - } - } -}; diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/macro_problem.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/macro_problem.cpp deleted file mode 100644 index 03dbddc3ea9..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/macro_problem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cp %t.cpp %t.base -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// See PR15589 for why this test fails. -// XFAIL: * - -#include "macro_problem.h" -#include "structures.h" - -void side_effect(const myns::MyType &T); - -void f() { - TypedefDerefContainer<myns::MyType> container; - for (TypedefDerefContainer<myns::MyType>::iterator I = container.begin(), - E = container.end(); I != E; ++I) { - myns::MyType &alias = *I; - // CHECK: myns::MyType &ref = *I; - side_effect(ref); - } -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-alias.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-alias.cpp deleted file mode 100644 index 0ed3440ab77..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-alias.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -const int N = 10; - -Val Arr[N]; -Val &func(Val &); -void sideEffect(int); - -void aliasing() { - // If the loop container is only used for a declaration of a temporary - // variable to hold each element, we can name the new variable for the - // converted range-based loop as the temporary variable's name. - - // In the following case, "t" is used as a temporary variable to hold each - // element, and thus we consider the name "t" aliased to the loop. - // The extra blank braces are left as a placeholder for after the variable - // declaration is deleted. - for (int i = 0; i < N; ++i) { - Val &t = Arr[i]; { } - int y = t.x; - } - // CHECK: for (auto & t : Arr) - // CHECK-NOT: Val &{{[a-z_]+}} = - // CHECK-NEXT: { } - // CHECK-NEXT: int y = t.x; - - // The container was not only used to initialize a temporary loop variable for - // the container's elements, so we do not alias the new loop variable. - for (int i = 0; i < N; ++i) { - Val &t = Arr[i]; - int y = t.x; - int z = Arr[i].x + t.x; - } - // CHECK: for (auto & elem : Arr) - // CHECK-NEXT: Val &t = elem; - // CHECK-NEXT: int y = t.x; - // CHECK-NEXT: int z = elem.x + t.x; - - for (int i = 0; i < N; ++i) { - Val t = Arr[i]; - int y = t.x; - int z = Arr[i].x + t.x; - } - // CHECK: for (auto & elem : Arr) - // CHECK-NEXT: Val t = elem; - // CHECK-NEXT: int y = t.x; - // CHECK-NEXT: int z = elem.x + t.x; - - for (int i = 0; i < N; ++i) { - Val &t = func(Arr[i]); - int y = t.x; - } - // CHECK: for (auto & elem : Arr) - // CHECK-NEXT: Val &t = func(elem); - // CHECK-NEXT: int y = t.x; - - int IntArr[N]; - for (unsigned i = 0; i < N; ++i) { - if (int alias = IntArr[i]) { - sideEffect(alias); - } - } - // CHECK: for (auto alias : IntArr) - // CHECK-NEXT: if (alias) { - - for (unsigned i = 0; i < N; ++i) { - while (int alias = IntArr[i]) { - sideEffect(alias); - } - } - // CHECK: for (auto alias : IntArr) - // CHECK-NEXT: while (alias) { - - for (unsigned i = 0; i < N; ++i) { - switch (int alias = IntArr[i]) { - default: - sideEffect(alias); - } - } - // CHECK: for (auto alias : IntArr) - // CHECK-NEXT: switch (alias) { - - for (unsigned i = 0; i < N; ++i) { - for (int alias = IntArr[i]; alias < N; ++alias) { - sideEffect(alias); - } - } - // CHECK: for (auto alias : IntArr) - // CHECK-NEXT: for (; alias < N; ++alias) { - - for (unsigned i = 0; i < N; ++i) { - for (unsigned j = 0; int alias = IntArr[i]; ++j) { - sideEffect(alias); - } - } - // CHECK: for (auto alias : IntArr) - // CHECK-NEXT: for (unsigned j = 0; alias; ++j) { -} - -void refs_and_vals() { - // The following tests check that the transform correctly preserves the - // reference or value qualifiers of the aliased variable. That is, if the - // variable was declared as a value, the loop variable will be declared as a - // value and vice versa for references. - - S s; - const S s_const = s; - - for (S::const_iterator it = s_const.begin(); it != s_const.end(); ++it) { - MutableVal alias = *it; { } - alias.x = 0; - } - // CHECK: for (auto alias : s_const) - // CHECK-NOT: MutableVal {{[a-z_]+}} = - // CHECK-NEXT: { } - // CHECK-NEXT: alias.x = 0; - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - MutableVal alias = *it; { } - alias.x = 0; - } - // CHECK: for (auto alias : s) - // CHECK-NOT: MutableVal {{[a-z_]+}} = - // CHECK-NEXT: { } - // CHECK-NEXT: alias.x = 0; - - for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) { - MutableVal &alias = *it; { } - alias.x = 0; - } - // CHECK: for (auto & alias : s) - // CHECK-NOT: MutableVal &{{[a-z_]+}} = - // CHECK-NEXT: { } - // CHECK-NEXT: alias.x = 0; -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp deleted file mode 100644 index 2454d078e69..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/naming-conflict.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -#define MAX(a,b) (a > b) ? a : b -#define DEF 5 - -const int N = 10; -int nums[N]; -int sum = 0; - -namespace ns { - struct st { - int x; - }; -} - -void sameNames() { - int num = 0; - for (int i = 0; i < N; ++i) { - printf("Fibonacci number is %d\n", nums[i]); - sum += nums[i] + 2 + num; - (void) nums[i]; - } - // CHECK: for (auto & nums_i : nums) - // CHECK-NEXT: printf("Fibonacci number is %d\n", nums_i); - // CHECK-NEXT: sum += nums_i + 2 + num; - // CHECK-NOT: (void) num; -} - -void macroConflict() { - S MAXs; - for (S::iterator it = MAXs.begin(), e = MAXs.end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - printf("Max of 3 and 5: %d\n", MAX(3,5)); - } - // CHECK: for (auto & MAXs_it : MAXs) - // CHECK-NEXT: printf("s has value %d\n", (MAXs_it).x); - // CHECK-NEXT: printf("Max of 3 and 5: %d\n", MAX(3,5)); - - for (S::const_iterator it = MAXs.begin(), e = MAXs.end(); it != e; ++it) { - printf("s has value %d\n", (*it).x); - printf("Max of 3 and 5: %d\n", MAX(3,5)); - } - // CHECK: for (const auto & MAXs_it : MAXs) - // CHECK-NEXT: printf("s has value %d\n", (MAXs_it).x); - // CHECK-NEXT: printf("Max of 3 and 5: %d\n", MAX(3,5)); - - T DEFs; - for (T::iterator it = DEFs.begin(), e = DEFs.end(); it != e; ++it) { - if (*it == DEF) { - printf("I found %d\n", *it); - } - } - // CHECK: for (auto & DEFs_it : DEFs) - // CHECK-NEXT: if (DEFs_it == DEF) { - // CHECK-NEXT: printf("I found %d\n", DEFs_it); -} - -void keywordConflict() { - T ints; - for (T::iterator it = ints.begin(), e = ints.end(); it != e; ++it) { - *it = 5; - } - // CHECK: for (auto & ints_it : ints) - // CHECK-NEXT: ints_it = 5; - - U __FUNCTION__s; - for (U::iterator it = __FUNCTION__s.begin(), e = __FUNCTION__s.end(); - it != e; ++it) { - int __FUNCTION__s_it = (*it).x + 2; - } - // CHECK: for (auto & __FUNCTION__s_elem : __FUNCTION__s) - // CHECK-NEXT: int __FUNCTION__s_it = (__FUNCTION__s_elem).x + 2; -} - -void typeConflict() { - T Vals; - // Using the name "Val", although it is the name of an existing struct, is - // safe in this loop since it will only exist within this scope. - for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; ++it) { - } - // CHECK: for (auto & Val : Vals) - - // We cannot use the name "Val" in this loop since there is a reference to - // it in the body of the loop. - for (T::iterator it = Vals.begin(), e = Vals.end(); it != e; ++it) { - *it = sizeof(Val); - } - // CHECK: for (auto & Vals_it : Vals) - // CHECK-NEXT: Vals_it = sizeof(Val); - - typedef struct Val TD; - U TDs; - // Naming the variable "TD" within this loop is safe because the typedef - // was never used within the loop. - for (U::iterator it = TDs.begin(), e = TDs.end(); it != e; ++it) { - } - // CHECK: for (auto & TD : TDs) - - // "TD" cannot be used in this loop since the typedef is being used. - for (U::iterator it = TDs.begin(), e = TDs.end(); it != e; ++it) { - TD V; - V.x = 5; - } - // CHECK: for (auto & TDs_it : TDs) - // CHECK-NEXT: TD V; - // CHECK-NEXT: V.x = 5; - - using ns::st; - T sts; - for (T::iterator it = sts.begin(), e = sts.end(); it != e; ++it) { - *it = sizeof(st); - } - // CHECK: for (auto & sts_it : sts) - // CHECK-NEXT: sts_it = sizeof(st); -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-iterator.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-iterator.cpp deleted file mode 100644 index 09c43476be2..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-iterator.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) - -S s; -T t; -U u; - -struct BadBeginEnd : T { - iterator notBegin(); - iterator notEnd(); -}; - -void notBeginOrEnd() { - BadBeginEnd Bad; - for (T::iterator i = Bad.notBegin(), e = Bad.end(); i != e; ++i) - int k = *i; - - for (T::iterator i = Bad.begin(), e = Bad.notEnd(); i != e; ++i) - int k = *i; -} - -void badLoopShapes() { - for (T::iterator i = t.begin(), e = t.end(), f = e; i != e; ++i) - int k = *i; - - for (T::iterator i = t.begin(), e = t.end(); i != e; ) - int k = *i; - - for (T::iterator i = t.begin(), e = t.end(); ; ++i) - int k = *i; - - T::iterator outsideI; - T::iterator outsideE; - - for (; outsideI != outsideE ; ++outsideI) - int k = *outsideI; -} - -void iteratorArrayMix() { - int lower; - const int N = 6; - for (T::iterator i = t.begin(), e = t.end(); lower < N; ++i) - int k = *i; - - for (T::iterator i = t.begin(), e = t.end(); lower < N; ++lower) - int k = *i; -} - -struct ExtraConstructor : T::iterator { - ExtraConstructor(T::iterator, int); - explicit ExtraConstructor(T::iterator); -}; - -void badConstructor() { - for (T::iterator i = ExtraConstructor(t.begin(), 0), e = t.end(); - i != e; ++i) - int k = *i; - for (T::iterator i = ExtraConstructor(t.begin()), e = t.end(); i != e; ++i) - int k = *i; -} - -void iteratorMemberUsed() { - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - i.x = *i; - - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - int k = i.x + *i; - - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - int k = e.x + *i; -} - -void iteratorMethodCalled() { - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - i.insert(3); - - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - if (i != i) - int k = 3; -} - -void iteratorOperatorCalled() { - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - int k = *(++i); - - for (S::iterator i = s.begin(), e = s.end(); i != e; ++i) - MutableVal k = *(++i); -} - -void differentContainers() { - T other; - for (T::iterator i = t.begin(), e = other.end(); i != e; ++i) - int k = *i; - - for (T::iterator i = other.begin(), e = t.end(); i != e; ++i) - int k = *i; - - S otherS; - for (S::iterator i = s.begin(), e = otherS.end(); i != e; ++i) - MutableVal k = *i; - - for (S::iterator i = otherS.begin(), e = s.end(); i != e; ++i) - MutableVal k = *i; -} - -void wrongIterators() { - T::iterator other; - for (T::iterator i = t.begin(), e = t.end(); i != other; ++i) - int k = *i; -} - -struct EvilArrow : U { - // Please, no one ever write code like this. - U* operator->(); -}; - -void differentMemberAccessTypes() { - EvilArrow A; - for (EvilArrow::iterator i = A.begin(), e = A->end(); i != e; ++i) - Val k = *i; - for (EvilArrow::iterator i = A->begin(), e = A.end(); i != e; ++i) - Val k = *i; -} - -void f(const T::iterator &it, int); -void f(const T &it, int); -void g(T &it, int); - -void iteratorPassedToFunction() { - for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) - f(i, *i); -} - -// FIXME: Disallow this except for containers passed by value and/or const -// reference. Or maybe this is correct enough for any container? -void containerPassedToFunction() { -// for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) -// f(t, *i); -// for (T::iterator i = t.begin(), e = t.end(); i != e; ++i) -// g(t, *i); -} - -// FIXME: These tests can be removed if this tool ever does enough analysis to -// decide that this is a safe transformation. -// Until then, we don't want it applied. -void iteratorDefinedOutside() { - T::iterator theEnd = t.end(); - for (T::iterator i = t.begin(); i != theEnd; ++i) - int k = *i; - - T::iterator theBegin = t.begin(); - for (T::iterator e = t.end(); theBegin != e; ++theBegin) - int k = *theBegin; -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-multi-end-call.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-multi-end-call.cpp deleted file mode 100644 index 6e50ee72e35..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-multi-end-call.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert -risk=safe %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) - -S s; -T t; -U u; - -void multipleEnd() { - for (S::iterator i = s.begin(); i != s.end(); ++i) - MutableVal k = *i; - - for (T::iterator i = t.begin(); i != t.end(); ++i) - int k = *i; - - for (U::iterator i = u.begin(); i != u.end(); ++i) - Val k = *i; -} - -void f(X); -void f(S); -void f(T); - -void complexContainer() { - X x; - for (S::iterator i = x.s.begin(), e = x.s.end(); i != e; ++i) { - f(x); - MutableVal k = *i; - } - - for (T::iterator i = x.t.begin(), e = x.t.end(); i != e; ++i) { - f(x); - int k = *i; - } - - for (S::iterator i = x.s.begin(), e = x.s.end(); i != e; ++i) { - f(x.s); - MutableVal k = *i; - } - - for (T::iterator i = x.t.begin(), e = x.t.end(); i != e; ++i) { - f(x.t); - int k = *i; - } - - for (S::iterator i = x.getS().begin(), e = x.getS().end(); i != e; ++i) { - f(x.getS()); - MutableVal k = *i; - } - - X exes[5]; - int index = 0; - - for (S::iterator i = exes[index].getS().begin(), - e = exes[index].getS().end(); i != e; ++i) { - index++; - MutableVal k = *i; - } -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray-extra.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray-extra.cpp deleted file mode 100644 index 3ccdb12c620..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray-extra.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) - -const int N = 6; -dependent<int> v; -dependent<int> *pv; - -int sum = 0; - -// Checks to see that non-const member functions are not called on the container -// object. -// These could be conceivably allowed with a lower required confidence level. -void memberFunctionCalled() { - for (int i = 0; i < v.size(); ++i) { - sum += v[i]; - v.foo(); - } - - for (int i = 0; i < v.size(); ++i) { - sum += v[i]; - dependent<int>::iterator it = v.begin(); - } -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray.cpp deleted file mode 100644 index cbc67be24af..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative-pseudoarray.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) - -const int N = 6; -dependent<int> v; -dependent<int> *pv; - -transparent<dependent<int> > cv; -int sum = 0; - -// Checks for the index start and end: -void indexStartAndEnd() { - for (int i = 0; i < v.size() + 1; ++i) - sum += v[i]; - - for (int i = 0; i < v.size() - 1; ++i) - sum += v[i]; - - for (int i = 1; i < v.size(); ++i) - sum += v[i]; - - for (int i = 1; i < v.size(); ++i) - sum += v[i]; - - for (int i = 0; ; ++i) - sum += (*pv)[i]; -} - -// Checks for invalid increment steps: -void increment() { - for (int i = 0; i < v.size(); --i) - sum += v[i]; - - for (int i = 0; i < v.size(); i) - sum += v[i]; - - for (int i = 0; i < v.size();) - sum += v[i]; - - for (int i = 0; i < v.size(); i += 2) - sum ++; -} - -// Checks to make sure that the index isn't used outside of the container: -void indexUse() { - for (int i = 0; i < v.size(); ++i) - v[i] += 1 + i; -} - -// Checks for incorrect loop variables. -void mixedVariables() { - int badIndex; - for (int i = 0; badIndex < v.size(); ++i) - sum += v[i]; - - for (int i = 0; i < v.size(); ++badIndex) - sum += v[i]; - - for (int i = 0; badIndex < v.size(); ++badIndex) - sum += v[i]; - - for (int i = 0; badIndex < v.size(); ++badIndex) - sum += v[badIndex]; -} - -// Checks for an array indexed in addition to the container. -void multipleArrays() { - int badArr[N]; - - for (int i = 0; i < v.size(); ++i) - sum += v[i] + badArr[i]; - - for (int i = 0; i < v.size(); ++i) - sum += badArr[i]; - - for (int i = 0; i < v.size(); ++i) { - int k = badArr[i]; - sum += k + 2; - } - - for (int i = 0; i < v.size(); ++i) { - int k = badArr[i]; - sum += v[i] + k; - } -} - -// Checks for multiple containers being indexed container. -void multipleContainers() { - dependent<int> badArr; - - for (int i = 0; i < v.size(); ++i) - sum += v[i] + badArr[i]; - - for (int i = 0; i < v.size(); ++i) - sum += badArr[i]; - - for (int i = 0; i < v.size(); ++i) { - int k = badArr[i]; - sum += k + 2; - } - - for (int i = 0; i < v.size(); ++i) { - int k = badArr[i]; - sum += v[i] + k; - } -} - -// Check to make sure that dereferenced pointers-to-containers behave nicely -void derefContainer() { - // Note the dependent<T>::operator*() returns another dependent<T>. - // This test makes sure that we don't allow an arbitrary number of *'s. - for (int i = 0; i < pv->size(); ++i) - sum += (**pv).at(i); - - for (int i = 0; i < pv->size(); ++i) - sum += (**pv)[i]; -} - -void wrongEnd() { - int bad; - for (int i = 0, e = v.size(); i < bad; ++i) - sum += v[i]; -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative.cpp deleted file mode 100644 index 0075f5eab69..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/negative.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/negative-header.h > \ -// RUN: %T/negative-header.h -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs/ -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: FileCheck -input-file=%T/negative-header.h %S/Inputs/negative-header.h - -#include "negative-header.h" -#include "structures.h" - -// Single FileCheck line to make sure that no loops are converted. -// CHECK-NOT: for ({{.*[^:]:[^:].*}}) - -const int N = 6; -int arr[N] = {1, 2, 3, 4, 5, 6}; -int (*pArr)[N] = &arr; -int sum = 0; - -// Checks for the index start and end: -void indexStartAndEnd() { - for (int i = 0; i < N + 1; ++i) - sum += arr[i]; - - for (int i = 0; i < N - 1; ++i) - sum += arr[i]; - - for (int i = 1; i < N; ++i) - sum += arr[i]; - - for (int i = 1; i < N; ++i) - sum += arr[i]; - - for (int i = 0; ; ++i) - sum += (*pArr)[i]; -} - -// Checks for invalid increment steps: -void increment() { - for (int i = 0; i < N; --i) - sum += arr[i]; - - for (int i = 0; i < N; i) - sum += arr[i]; - - for (int i = 0; i < N;) - sum += arr[i]; - - for (int i = 0; i < N; i += 2) - sum ++; -} - -// Checks to make sure that the index isn't used outside of the array: -void indexUse() { - for (int i = 0; i < N; ++i) - arr[i] += 1 + i; -} - -// Check for loops that don't mention arrays -void noArray() { - for (int i = 0; i < N; ++i) - sum += i; - - for (int i = 0; i < N; ++i) { } - - for (int i = 0; i < N; ++i) ; -} - -// Checks for incorrect loop variables. -void mixedVariables() { - int badIndex; - for (int i = 0; badIndex < N; ++i) - sum += arr[i]; - - for (int i = 0; i < N; ++badIndex) - sum += arr[i]; - - for (int i = 0; badIndex < N; ++badIndex) - sum += arr[i]; - - for (int i = 0; badIndex < N; ++badIndex) - sum += arr[badIndex]; -} - -// Checks for multiple arrays indexed. -void multipleArrays() { - int badArr[N]; - - for (int i = 0; i < N; ++i) - sum += arr[i] + badArr[i]; - - for (int i = 0; i < N; ++i) { - int k = badArr[i]; - sum += arr[i] + k; - } -} - -struct HasArr { - int Arr[N]; - Val ValArr[N]; -}; - -struct HasIndirectArr { - HasArr HA; - void implicitThis() { - for (int i = 0; i < N; ++i) { - printf("%d", HA.Arr[i]); - } - - for (int i = 0; i < N; ++i) { - printf("%d", HA.ValArr[i].x); - } - } - - void explicitThis() { - for (int i = 0; i < N; ++i) { - printf("%d", this->HA.Arr[i]); - } - - for (int i = 0; i < N; ++i) { - printf("%d", this->HA.ValArr[i].x); - } - } -}; diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp deleted file mode 100644 index 33ab5d401b3..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nesting.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -void f() { - const int N = 10; - const int M = 15; - Val Arr[N]; - for (int i = 0; i < N; ++i) { - for (int j = 0; j < N; ++j) { - int k = Arr[i].x + Arr[j].x; - // The repeat is there to allow FileCheck to make sure the two variable - // names aren't the same. - int l = Arr[i].x + Arr[j].x; - } - } - // CHECK: for (auto & elem : Arr) - // CHECK-NEXT: for (auto & Arr_j : Arr) - // CHECK-NEXT: int k = elem.x + Arr_j.x; - // CHECK-NOT: int l = elem.x + elem.x; - - Val Nest[N][M]; - for (int i = 0; i < N; ++i) { - for (int j = 0; j < M; ++j) { - printf("Got item %d", Nest[i][j].x); - } - } - // The inner loop is also convertible, but doesn't need to be converted - // immediately. Update this test when that changes! - // CHECK: for (auto & elem : Nest) - // CHECK-NEXT: for (int j = 0; j < M; ++j) - // CHECK-NEXT: printf("Got item %d", elem[j].x); - - // Note that the order of M and N are switched for this test. - for (int j = 0; j < M; ++j) { - for (int i = 0; i < N; ++i) { - printf("Got item %d", Nest[i][j].x); - } - } - // CHECK-NOT: for (auto & {{[a-zA-Z_]+}} : Nest[i]) - // CHECK: for (int j = 0; j < M; ++j) - // CHECK-NEXT: for (auto & elem : Nest) - // CHECK-NEXT: printf("Got item %d", elem[j].x); - Nested<T> NestT; - for (Nested<T>::iterator I = NestT.begin(), E = NestT.end(); I != E; ++I) { - for (T::iterator TI = (*I).begin(), TE = (*I).end(); TI != TE; ++TI) { - printf("%d", *TI); - } - } - // The inner loop is also convertible, but doesn't need to be converted - // immediately. Update this test when that changes! - // CHECK: for (auto & elem : NestT) { - // CHECK-NEXT: for (T::iterator TI = (elem).begin(), TE = (elem).end(); TI != TE; ++TI) { - // CHECK-NEXT: printf("%d", *TI); - - Nested<S> NestS; - for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) { - for (S::const_iterator SI = (*I).begin(), SE = (*I).end(); SI != SE; ++SI) { - printf("%d", *SI); - } - } - // The inner loop is also convertible, but doesn't need to be converted - // immediately. Update this test when that changes! - // CHECK: for (const auto & elem : NestS) { - // CHECK-NEXT: for (S::const_iterator SI = (elem).begin(), SE = (elem).end(); SI != SE; ++SI) { - // CHECK-NEXT: printf("%d", *SI); -} diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nocompile.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/nocompile.cpp deleted file mode 100644 index ea102877557..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/nocompile.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: not cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -void valid() { - const int arr[5]; - int sum = 0; - for (int i = 0; i < 5; ++i) { - sum += arr[i]; - } -} -void hasSyntaxError = 3; -// CHECK: void valid() { -// CHECK-NEXT: const int arr[5]; -// CHECK-NEXT: int sum = 0; -// CHECK-NEXT: for (int i = 0; i < 5; ++i) { -// CHECK-NEXT: sum += arr[i]; -// CHECK-NEXT: } -// CHECK-NEXT: } - -// CHECK-NEXT: void hasSyntaxError = 3; diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp deleted file mode 100644 index 5aeaf79fc9f..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/pseudoarray.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -#include "structures.h" - -const int N = 6; -dependent<int> v; -dependent<int> *pv; - -transparent<dependent<int> > cv; - -void f() { - int sum = 0; - for (int i = 0, e = v.size(); i < e; ++i) { - printf("Fibonacci number is %d\n", v[i]); - sum += v[i] + 2; - } - // CHECK: for (auto & elem : v) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; - - for (int i = 0, e = v.size(); i < e; ++i) { - printf("Fibonacci number is %d\n", v.at(i)); - sum += v.at(i) + 2; - } - // CHECK: for (auto & elem : v) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; - - for (int i = 0, e = pv->size(); i < e; ++i) { - printf("Fibonacci number is %d\n", pv->at(i)); - sum += pv->at(i) + 2; - } - // CHECK: for (auto & elem : *pv) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; - - // This test will fail if size() isn't called repeatedly, since it - // returns unsigned int, and 0 is deduced to be signed int. - // FIXME: Insert the necessary explicit conversion, or write out the types - // explicitly. - for (int i = 0; i < pv->size(); ++i) { - printf("Fibonacci number is %d\n", (*pv).at(i)); - sum += (*pv)[i] + 2; - } - // CHECK: for (auto & elem : *pv) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; - - for (int i = 0; i < cv->size(); ++i) { - printf("Fibonacci number is %d\n", cv->at(i)); - sum += cv->at(i) + 2; - } - // CHECK: for (auto & elem : *cv) - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - // CHECK-NEXT: sum += elem + 2; -} - -// Check for loops that don't mention containers -void noContainer() { - for (auto i = 0; i < v.size(); ++i) { } - // CHECK: for (auto & elem : v) { } - - for (auto i = 0; i < v.size(); ++i) ; - // CHECK: for (auto & elem : v) ; -} - -struct NoBeginEnd { - unsigned size() const; -}; - -struct NoConstBeginEnd { - NoConstBeginEnd(); - unsigned size() const; - unsigned begin(); - unsigned end(); -}; - -struct ConstBeginEnd { - ConstBeginEnd(); - unsigned size() const; - unsigned begin() const; - unsigned end() const; -}; - -// Shouldn't transform pseudo-array uses if the container doesn't provide -// begin() and end() of the right const-ness. -void NoBeginEndTest() { - NoBeginEnd NBE; - for (unsigned i = 0, e = NBE.size(); i < e; ++i) {} - // CHECK: for (unsigned i = 0, e = NBE.size(); i < e; ++i) {} - - const NoConstBeginEnd const_NCBE; - for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {} - // CHECK: for (unsigned i = 0, e = const_NCBE.size(); i < e; ++i) {} - - ConstBeginEnd CBE; - for (unsigned i = 0, e = CBE.size(); i < e; ++i) {} - // CHECK: for (auto & elem : CBE) {} - - const ConstBeginEnd const_CBE; - for (unsigned i = 0, e = const_CBE.size(); i < e; ++i) {} - // CHECK: for (auto & elem : const_CBE) {} -} - diff --git a/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp b/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp deleted file mode 100644 index a5a74c1a859..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/LoopConvert/single-iterator.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -loop-convert %t.cpp -- -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#include "structures.h" - -void complexContainer() { - X exes[5]; - int index = 0; - - for (S::iterator i = exes[index].getS().begin(), e = exes[index].getS().end(); i != e; ++i) { - MutableVal k = *i; - MutableVal j = *i; - } - // CHECK: for (auto & elem : exes[index].getS()) - // CHECK-NEXT: MutableVal k = elem; - // CHECK-NEXT: MutableVal j = elem; -} - -void f() { - /// begin()/end() - based for loops here: - T t; - for (T::iterator it = t.begin(); it != t.end(); ++it) { - printf("I found %d\n", *it); - } - // CHECK: for (auto & elem : t) - // CHECK-NEXT: printf("I found %d\n", elem); - - T *pt; - for (T::iterator it = pt->begin(); it != pt->end(); ++it) { - printf("I found %d\n", *it); - } - // CHECK: for (auto & elem : *pt) - // CHECK-NEXT: printf("I found %d\n", elem); - - S s; - for (S::iterator it = s.begin(); it != s.end(); ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - S *ps; - for (S::iterator it = ps->begin(); it != ps->end(); ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & p : *ps) - // CHECK-NEXT: printf("s has value %d\n", (p).x); - - for (S::iterator it = s.begin(); it != s.end(); ++it) { - printf("s has value %d\n", it->x); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", elem.x); - - for (S::iterator it = s.begin(); it != s.end(); ++it) { - it->x = 3; - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: elem.x = 3; - - for (S::iterator it = s.begin(); it != s.end(); ++it) { - (*it).x = 3; - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: (elem).x = 3; - - for (S::iterator it = s.begin(); it != s.end(); ++it) { - it->nonConstFun(4, 5); - } - // CHECK: for (auto & elem : s) - // CHECK-NEXT: elem.nonConstFun(4, 5); - - U u; - for (U::iterator it = u.begin(); it != u.end(); ++it) { - printf("s has value %d\n", it->x); - } - // CHECK: for (auto & elem : u) - // CHECK-NEXT: printf("s has value %d\n", elem.x); - - for (U::iterator it = u.begin(); it != u.end(); ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (auto & elem : u) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - U::iterator A; - for (U::iterator i = u.begin(); i != u.end(); ++i) - int k = A->x + i->x; - // CHECK: for (auto & elem : u) - // CHECK-NEXT: int k = A->x + elem.x; - - dependent<int> v; - for (dependent<int>::iterator it = v.begin(); - it != v.end(); ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (auto & elem : v) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - - for (dependent<int>::iterator it(v.begin()); - it != v.end(); ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (auto & elem : v) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", elem); - - doublyDependent<int,int> intmap; - for (doublyDependent<int,int>::iterator it = intmap.begin(); - it != intmap.end(); ++it) { - printf("intmap[%d] = %d", it->first, it->second); - } - // CHECK: for (auto & elem : intmap) - // CHECK-NEXT: printf("intmap[%d] = %d", elem.first, elem.second); -} - -void different_type() { - // Tests to verify the proper use of auto where the init variable type and the - // initializer type differ or are mostly the same except for const qualifiers. - - // s.begin() returns a type 'iterator' which is just a non-const pointer and - // differs from const_iterator only on the const qualification. - S s; - for (S::const_iterator it = s.begin(); it != s.end(); ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (const auto & elem : s) - // CHECK-NEXT: printf("s has value %d\n", (elem).x); - - S *ps; - for (S::const_iterator it = ps->begin(); it != ps->end(); ++it) { - printf("s has value %d\n", (*it).x); - } - // CHECK: for (const auto & p : *ps) - // CHECK-NEXT: printf("s has value %d\n", (p).x); - - // v.begin() returns a user-defined type 'iterator' which, since it's - // different from const_iterator, disqualifies these loops from - // transformation. - dependent<int> v; - for (dependent<int>::const_iterator it = v.begin(); it != v.end(); ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (dependent<int>::const_iterator it = v.begin(); it != v.end(); ++it) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", *it); - - for (dependent<int>::const_iterator it(v.begin()); it != v.end(); ++it) { - printf("Fibonacci number is %d\n", *it); - } - // CHECK: for (dependent<int>::const_iterator it(v.begin()); it != v.end(); ++it) { - // CHECK-NEXT: printf("Fibonacci number is %d\n", *it); -} diff --git a/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.cpp b/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.cpp deleted file mode 100644 index ce23f047edb..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Since -fdelayed-template-parsing is enabled by default on Windows (as a -// Microsoft extension), -fno-delayed-template-parsing is used for the tests in -// order to have the same behavior on all systems. -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -pass-by-value %t.cpp -- -std=c++11 -fno-delayed-template-parsing -I %S -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -pass-by-value %t.cpp -- -std=c++11 -fno-delayed-template-parsing -I %S -// RUN: FileCheck -check-prefix=SAFE_RISK -input-file=%t.cpp %s - -#include "basic.h" -// CHECK: #include <utility> - -// Test that when the class declaration can't be modified we won't modify the -// definition either. -UnmodifiableClass::UnmodifiableClass(const Movable &M) : M(M) {} -// CHECK: UnmodifiableClass::UnmodifiableClass(const Movable &M) : M(M) {} - -struct A { - A(const Movable &M) : M(M) {} - // CHECK: A(Movable M) : M(std::move(M)) {} - // SAFE_RISK: A(const Movable &M) : M(M) {} - Movable M; -}; - -// Test that we aren't modifying other things than a parameter -Movable GlobalObj; -struct B { - B(const Movable &M) : M(GlobalObj) {} - // CHECK: B(const Movable &M) : M(GlobalObj) {} - Movable M; -}; - -// Test that a parameter with more than one reference to it won't be changed. -struct C { - // Tests extra-reference in body - C(const Movable &M) : M(M) { this->i = M.a; } - // CHECK: C(const Movable &M) : M(M) { this->i = M.a; } - - // Tests extra-reference in init-list - C(const Movable &M, int) : M(M), i(M.a) {} - // CHECK: C(const Movable &M, int) : M(M), i(M.a) {} - Movable M; - int i; -}; - -// Test that both declaration and definition are updated -struct D { - D(const Movable &M); - // CHECK: D(Movable M); - Movable M; -}; -D::D(const Movable &M) : M(M) {} -// CHECK: D::D(Movable M) : M(std::move(M)) {} - -// Test with default parameter -struct E { - E(const Movable &M = Movable()) : M(M) {} - // CHECK: E(Movable M = Movable()) : M(std::move(M)) {} - Movable M; -}; - -// Test with object that can't be moved -struct F { - F(const NotMovable &NM) : NM(NM) {} - // CHECK: F(const NotMovable &NM) : NM(NM) {} - NotMovable NM; -}; - -// Test unnamed parameter in declaration -struct G { - G(const Movable &); - // CHECK: G(Movable ); - Movable M; -}; -G::G(const Movable &M) : M(M) {} -// CHECK: G::G(Movable M) : M(std::move(M)) {} - -// Test parameter with and without qualifier -namespace ns_H { -typedef ::Movable HMovable; -} -struct H { - H(const ns_H::HMovable &M); - // CHECK: H(ns_H::HMovable M); - ns_H::HMovable M; -}; -using namespace ns_H; -H::H(const HMovable &M) : M(M) {} -// CHECK: H(HMovable M) : M(std::move(M)) {} - -// Try messing up with macros -#define MOVABLE_PARAM(Name) const Movable & Name -// CHECK: #define MOVABLE_PARAM(Name) const Movable & Name -struct I { - I(MOVABLE_PARAM(M)) : M(M) {} - // CHECK: I(MOVABLE_PARAM(M)) : M(M) {} - Movable M; -}; -#undef MOVABLE_PARAM - -// Test that templates aren't modified -template <typename T> struct J { - J(const T &M) : M(M) {} - // CHECK: J(const T &M) : M(M) {} - T M; -}; -J<Movable> j1(Movable()); -J<NotMovable> j2(NotMovable()); - -struct K_Movable { - K_Movable() = default; - K_Movable(const K_Movable &) = default; - K_Movable(K_Movable &&o) { dummy = o.dummy; } - int dummy; -}; - -// Test with movable type with an user defined move constructor. -struct K { - K(const K_Movable &M) : M(M) {} - // CHECK: K(K_Movable M) : M(std::move(M)) {} - K_Movable M; -}; - -template <typename T> struct L { - L(const Movable &M) : M(M) {} - // CHECK: L(Movable M) : M(std::move(M)) {} - Movable M; -}; -L<int> l(Movable()); - -// Test with a non-instantiated template class -template <typename T> struct N { - N(const Movable &M) : M(M) {} - // CHECK: N(Movable M) : M(std::move(M)) {} - - Movable M; - T A; -}; - -// Test with value parameter -struct O { - O(Movable M) : M(M) {} - // CHECK: O(Movable M) : M(std::move(M)) {} - Movable M; -}; - -// Test with a const-value parameter -struct P { - P(const Movable M) : M(M) {} - // CHECK: P(Movable M) : M(std::move(M)) {} - Movable M; -}; - -// Test with multiples parameters where some need to be changed and some don't -// need to. -struct Q { - Q(const Movable &A, const Movable &B, const Movable &C, double D) - : A(A), B(B), C(C), D(D) {} - // CHECK: Q(const Movable &A, Movable B, Movable C, double D) - // CHECK-NEXT: : A(A), B(std::move(B)), C(std::move(C)), D(D) {} - const Movable &A; - Movable B; - Movable C; - double D; -}; diff --git a/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.h b/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.h deleted file mode 100644 index 4b551f7d908..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/PassByValue/basic.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BASIC_H -#define BASIC_H - -// POD types are trivially move constructible -struct Movable { - int a, b, c; -}; - -struct NotMovable { - NotMovable() = default; - NotMovable(const NotMovable &) = default; - NotMovable(NotMovable &&) = delete; - int a, b, c; -}; - -// The test runs the migrator without header modifications enabled for this -// header making the constructor parameter M unmodifiable. -struct UnmodifiableClass { - UnmodifiableClass(const Movable &M); - Movable M; -}; - -#endif // BASIC_H diff --git a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/basic.h b/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/basic.h deleted file mode 100644 index 48b0ee4f67c..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/basic.h +++ /dev/null @@ -1,56 +0,0 @@ -#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 diff --git a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/memory_stub.h b/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/memory_stub.h deleted file mode 100644 index 89e4e0ec533..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/Inputs/memory_stub.h +++ /dev/null @@ -1,61 +0,0 @@ -//===-----------------------------------------------------------*- C++ -*--===// -// -// This file contains a shell implementation of the 'auto_ptr' type from the -// standard library. This shell aims to support the variations between standard -// library implementations. -// -// Variations for how 'auto_ptr' is presented: -// 1. Defined directly in namespace std -// 2. Use a versioned inline namespace in std (default on libc++). -// -// Use the preprocessor to define USE_INLINE_NAMESPACE=1 and use the second -// variation. -// -//===----------------------------------------------------------------------===// - -namespace std { - -#if USE_INLINE_NAMESPACE -inline namespace _1 { -#endif - -template <class Y> struct auto_ptr_ref { - Y *y_; -}; - -template <class X> class auto_ptr { -public: - typedef X element_type; - // D.10.1.1 construct/copy/destroy: - explicit auto_ptr(X *p = 0) throw() {} - auto_ptr(auto_ptr &) throw() {} - template <class Y> auto_ptr(auto_ptr<Y> &) throw() {} - auto_ptr &operator=(auto_ptr &) throw() { return *this; } - template <class Y> auto_ptr &operator=(auto_ptr<Y> &) throw() { - return *this; - } - auto_ptr &operator=(auto_ptr_ref<X> r) throw() { return *this; } - ~auto_ptr() throw() {} - // D.10.1.3 conversions: - auto_ptr(auto_ptr_ref<X> r) throw() : x_(r.y_) {} - template <class Y> operator auto_ptr_ref<Y>() throw() { - auto_ptr_ref<Y> r; - r.y_ = x_; - return r; - } - template <class Y> operator auto_ptr<Y>() throw() { return auto_ptr<Y>(x_); } - -private: - X *x_; -}; - -template <> class auto_ptr<void> { -public: - typedef void element_type; -}; - -#if USE_INLINE_NAMESPACE -} // namespace _1 -#endif - -} // end namespace std diff --git a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/basic.cpp b/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/basic.cpp deleted file mode 100644 index 690ede26533..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/basic.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// RUN: mkdir -p %T/Inputs -// -// Without inline namespace: -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/memory_stub.h > %T/Inputs/memory_stub.h -// RUN: cpp11-migrate -headers -include=%T -replace-auto_ptr %t.cpp -- \ -// RUN: -std=c++11 -I %T -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h -// -// With inline namespace: -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/memory_stub.h > %T/Inputs/memory_stub.h -// RUN: cpp11-migrate -headers -include=%T -replace-auto_ptr %t.cpp -- \ -// RUN: -DUSE_INLINE_NAMESPACE=1 -std=c++11 -I %T -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h - -#include "Inputs/basic.h" - -void f_1() { - std::auto_ptr<int> a; - // CHECK: std::unique_ptr<int> a; - - // check that spaces aren't modified unnecessarily - std:: auto_ptr <int> b; - // CHECK: std:: unique_ptr <int> b; - std :: auto_ptr < char > c(new char()); - // CHECK: std :: unique_ptr < char > c(new char()); - - // Test construction from a temporary - std::auto_ptr<char> d = std::auto_ptr<char>(); - // CHECK: std::unique_ptr<char> d = std::unique_ptr<char>(); - - typedef std::auto_ptr<int> int_ptr_t; - // CHECK: typedef std::unique_ptr<int> int_ptr_t; - int_ptr_t e(new int()); - // CHECK: int_ptr_t e(new int()); - - // Test pointers - std::auto_ptr<int> *f; - // CHECK: std::unique_ptr<int> *f; - - // Test 'static' declarations - static std::auto_ptr<int> g; - // CHECK: static std::unique_ptr<int> g; - - // Test with cv-qualifiers - const std::auto_ptr<int> h; - // CHECK: const std::unique_ptr<int> h; - volatile std::auto_ptr<int> i; - // CHECK: volatile std::unique_ptr<int> i; - const volatile std::auto_ptr<int> j; - // CHECK: const volatile std::unique_ptr<int> j; - - // Test auto and initializer-list - auto k = std::auto_ptr<int>{}; - // CHECK: auto k = std::unique_ptr<int>{}; - std::auto_ptr<int> l{std::auto_ptr<int>()}; - // CHECK: std::unique_ptr<int> l{std::unique_ptr<int>()}; - - // Test interlocked auto_ptr - std::auto_ptr<std::auto_ptr<int> > m; - // CHECK: std::unique_ptr<std::unique_ptr<int> > m; - - // Test temporaries - std::auto_ptr<char>(); - // CHECK: std::unique_ptr<char>(); - - // Test void-specialization - std::auto_ptr<void> n; - // CHECK: std::unique_ptr<void> n; - - // Test template WITH instantiation (instantiation) - B<double> o; - std::auto_ptr<double> p(o.create()); - // CHECK: std::unique_ptr<double> p(o.create()); - - // Test 'using' in a namespace ("definition") - ns_1::auto_ptr<int> q; - // CHECK: ns_1::unique_ptr<int> q; - - // Test construction with an 'auto_ptr_ref' - std::auto_ptr<Base> r(create_derived_ptr()); - // CHECK: std::unique_ptr<Base> r(create_derived_ptr()); -} - -// Test without the nested name specifiers -void f_2() { - using namespace std; - - auto_ptr<int> a; - // CHECK: unique_ptr<int> a; -} - -// Test using declaration -void f_3() { - using std::auto_ptr; - // CHECK: using std::unique_ptr; - - auto_ptr<int> a; - // CHECK: unique_ptr<int> a; -} - -// Test messing-up with macros -void f_4() { -#define MACRO_1 <char> - std::auto_ptr MACRO_1 p(new char()); -// CHECK: std::unique_ptr MACRO_1 p(new char()); -#define MACRO_2 auto_ptr - std::MACRO_2<int> q; -// CHECK: #define MACRO_2 unique_ptr -#define MACRO_3(Type) std::auto_ptr<Type> - MACRO_3(float)r(new float()); -// CHECK: #define MACRO_3(Type) std::unique_ptr<Type> -#define MACRO_4 std::auto_ptr - using MACRO_4; -// CHECK: #define MACRO_4 std::unique_ptr -#undef MACRO_1 -#undef MACRO_2 -#undef MACRO_3 -#undef MACRO_4 -} - -// Test function return values (definition) -std::auto_ptr<char> f_5() -// CHECK: std::unique_ptr<char> f_5() -{ - // Test constructor - return std::auto_ptr<char>(new char()); - // CHECK: return std::unique_ptr<char>(new char()); -} - -// Test that non-std auto_ptr aren't replaced -void f_8() { - ns_2::auto_ptr<char> a; - // CHECK: ns_2::auto_ptr<char> a; - using namespace ns_2; - auto_ptr<int> b; - // CHECK: auto_ptr<int> b; -} - -namespace std { -template <typename T> using aaaaaaaa = auto_ptr<T>; -} -// We want to avoid replacing 'aaaaaaaa' by unique_ptr here. It's better to -// change the type alias directly. -// XXX: maybe another test will be more relevant to test this potential error. -std::aaaaaaaa<int> d; -// CHECK: std::aaaaaaaa<int> d; diff --git a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/move.cpp b/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/move.cpp deleted file mode 100644 index d0e9ce14098..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/move.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// 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" - -void takes_ownership_fn(std::auto_ptr<int> x); -// CHECK: void takes_ownership_fn(std::unique_ptr<int> x); - -std::auto_ptr<int> get_by_value(); -// CHECK: std::unique_ptr<int> get_by_value(); - -class Wrapper { -public: - std::auto_ptr<int> &get_wrapped(); - -private: - std::auto_ptr<int> wrapped; -}; - -void f() { - std::auto_ptr<int> a, b, c; - // CHECK: std::unique_ptr<int> a, b, c; - Wrapper wrapper_a, wrapper_b; - - a = b; - // CHECK: a = std::move(b); - - wrapper_a.get_wrapped() = wrapper_b.get_wrapped(); - // CHECK: wrapper_a.get_wrapped() = std::move(wrapper_b.get_wrapped()); - - // Test that 'std::move()' is inserted when call to the - // copy-constructor are made. - takes_ownership_fn(c); - // CHECK: takes_ownership_fn(std::move(c)); - takes_ownership_fn(wrapper_a.get_wrapped()); - // CHECK: takes_ownership_fn(std::move(wrapper_a.get_wrapped())); - - std::auto_ptr<int> d[] = { std::auto_ptr<int>(new int(1)), - std::auto_ptr<int>(new int(2)) }; - std::auto_ptr<int> e = d[0]; - // CHECK: std::unique_ptr<int> d[] = { std::unique_ptr<int>(new int(1)), - // CHECK-NEXT: std::unique_ptr<int>(new int(2)) }; - // CHECK-NEXT: std::unique_ptr<int> e = std::move(d[0]); - - // Test that std::move() is not used when assigning an rvalue - std::auto_ptr<int> f; - f = std::auto_ptr<int>(new int(0)); - // CHECK: std::unique_ptr<int> f; - // CHECK-NEXT: f = std::unique_ptr<int>(new int(0)); - - std::auto_ptr<int> g = get_by_value(); - // CHECK: std::unique_ptr<int> g = get_by_value(); -} diff --git a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/template_fail.cpp b/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/template_fail.cpp deleted file mode 100644 index cdbf272c26b..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/ReplaceAutoPtr/template_fail.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// 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>; diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/Inputs/test_std_container.h b/clang-tools-extra/test/cpp11-migrate/UseAuto/Inputs/test_std_container.h deleted file mode 100644 index 5c92f6e194f..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseAuto/Inputs/test_std_container.h +++ /dev/null @@ -1,119 +0,0 @@ -//===-----------------------------------------------------------*- C++ -*--===// -// -// This file contains a shell implementation of a standard container with -// iterators. This shell is targeted at supporting the container interfaces -// recognized by cpp11-migrate's use-auto transformation. It requires the -// preprocessor to parameterize the name of the container, and allows the -// preprocessor to parameterize various mechanisms used in the implementation -// of the container / iterator. -// -// Variations for how iterator types are presented: -// * Typedef (array, deque, forward_list, list, vector) -// * Nested class (map, multimap, set, multiset) -// * Using declaration {unordered_} X {map, multimap, set, multiset} -// -// Variations for how container types are presented: -// * Defined directly in namespace std -// * Imported into namespace std with using declarations (a la libc++). -// -//===----------------------------------------------------------------------===// - -#ifndef CONTAINER -#error You must define CONTAINER to the name of the desired container. -#endif - -// If the test code needs multiple containers, only define our helpers once. -#ifndef TEST_STD_CONTAINER_HELPERS -#define TEST_STD_CONTAINER_HELPERS - -namespace internal { - -template <typename T, int i> -struct iterator_wrapper { - iterator_wrapper() {} - - // These are required for tests using iteration statements. - bool operator!=(const iterator_wrapper<T, i>&) { return false; } - iterator_wrapper& operator++() { return *this; } - typename T::value_type operator*() { return typename T::value_type(); } -}; - -template <typename T> -class iterator_provider { -public: - class iterator { - public: - iterator() {} - iterator(const iterator&) {} - }; - class const_iterator { - public: - const_iterator(int i=0) {} - const_iterator(const iterator &) {} - const_iterator(const const_iterator &) {} - operator iterator() { return iterator(); } - }; - class reverse_iterator {}; - class const_reverse_iterator {}; -}; - -} // namespace internal - -#endif // TEST_STD_CONTAINER_HELPERS - -namespace std { - -#if USE_INLINE_NAMESPACE -inline namespace _1 { -#endif - -template <typename T> -class CONTAINER -#if USE_BASE_CLASS_ITERATORS - : internal::iterator_provider<CONTAINER<T> > -#endif -{ -public: - -#if USE_BASE_CLASS_ITERATORS - using typename internal::iterator_provider<CONTAINER<T> >::iterator; - using typename internal::iterator_provider<CONTAINER<T> >::const_iterator; - using typename internal::iterator_provider<CONTAINER<T> >::reverse_iterator; - using typename internal::iterator_provider<CONTAINER<T> >::const_reverse_iterator; -#elif USE_INNER_CLASS_ITERATORS - class iterator {}; - class const_iterator {}; - class reverse_iterator {}; - class const_reverse_iterator {}; -#else - typedef T value_type; - typedef typename internal::iterator_wrapper<CONTAINER<T>, 0> iterator; - typedef typename internal::iterator_wrapper<CONTAINER<T>, 1> const_iterator; - typedef typename internal::iterator_wrapper<CONTAINER<T>, 3> reverse_iterator; - typedef typename internal::iterator_wrapper<CONTAINER<T>, 2> const_reverse_iterator; -#endif - - // Every class requires these functions. - CONTAINER() {} - - iterator begin() { return iterator(); } - iterator end() { return iterator(); } - - const_iterator begin() const { return const_iterator(); } - const_iterator end() const { return const_iterator(); } - - reverse_iterator rbegin() { return reverse_iterator(); } - reverse_iterator rend() { return reverse_iterator(); } - - const_reverse_iterator rbegin() const { return const_reverse_iterator(); } - const_reverse_iterator rend() const { return const_reverse_iterator(); } - - template <typename K> - iterator find(const K &Key) { return iterator(); } -}; - -#if USE_INLINE_NAMESPACE -} // namespace _1 -#endif - -} // namespace std diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/basic_iterator_tests.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/basic_iterator_tests.cpp deleted file mode 100644 index 30199e93f44..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseAuto/basic_iterator_tests.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// This file contains basic positive tests for the use-auto transform's ability -// to replace standard iterators. Variables considered: -// * All std container names -// * All std iterator names -// * Different patterns of defining iterators and containers -// -// // The most basic test. -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=array -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// -// Test variations on how the container and its iterators might be defined. -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=array \ -// RUN: -DUSE_INLINE_NAMESPACE=1 -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=array \ -// RUN: -DUSE_BASE_CLASS_ITERATORS=1 -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=array \ -// RUN: -DUSE_INNER_CLASS_ITERATORS=1 -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// -// Test all of the other container names in a basic configuration. -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=deque -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=forward_list -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=list -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=vector -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=map -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=multimap -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=set -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=multiset -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=unordered_map -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=unordered_multimap -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=unordered_set -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=unordered_multiset -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=queue -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=priority_queue -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -DCONTAINER=stack -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s - -#ifndef CONTAINER -#error You must define CONTAINER to the name of the container for testing. -#endif - -#include "test_std_container.h" - -int main(int argc, char **argv) { - { - std::CONTAINER<int> C; - std::CONTAINER<int>::iterator I = C.begin(); - // CHECK: auto I = C.begin(); - } - { - std::CONTAINER<int> C; - std::CONTAINER<int>::reverse_iterator I = C.rbegin(); - // CHECK: auto I = C.rbegin(); - } - { - const std::CONTAINER<int> C; - std::CONTAINER<int>::const_iterator I = C.begin(); - // CHECK: auto I = C.begin(); - } - { - const std::CONTAINER<int> C; - std::CONTAINER<int>::const_reverse_iterator I = C.rbegin(); - // CHECK: auto I = C.rbegin(); - } - - return 0; -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/iterator.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/iterator.cpp deleted file mode 100644 index 8871bc1eb36..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseAuto/iterator.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- --std=c++11 -I %S/Inputs -// RUN: FileCheck -input-file=%t.cpp %s -// -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- --std=c++11 -I %S/Inputs \ -// RUN: -DUSE_INLINE_NAMESPACE=1 -// RUN: FileCheck -input-file=%t.cpp %s - - -#define CONTAINER array -#include "test_std_container.h" -#undef CONTAINER - -#define CONTAINER vector -#include "test_std_container.h" -#undef CONTAINER - -#define CONTAINER unordered_map -#define USE_BASE_CLASS_ITERATORS 1 -#include "test_std_container.h" -#undef USE_BASE_CLASS_ITERATORS -#undef CONTAINER - -typedef std::vector<int>::iterator int_iterator; - -namespace foo { - template <typename T> - class vector { - public: - class iterator {}; - - iterator begin() { return iterator(); } - }; -} // namespace foo - -int main(int argc, char **argv) { - std::vector<int> Vec; - // CHECK: std::vector<int> Vec; - - std::unordered_map<int> Map; - // CHECK: std::unordered_map<int> Map; - - // Types with more sugar should work. Types with less should not. - { - int_iterator more_sugar = Vec.begin(); - // CHECK: auto more_sugar = Vec.begin(); - - internal::iterator_wrapper<std::vector<int>, 0> less_sugar = Vec.begin(); - // CHECK: internal::iterator_wrapper<std::vector<int>, 0> less_sugar = Vec.begin(); - } - - // Initialization from initializer lists isn't allowed. Using 'auto' - // would result in std::initializer_list being deduced for the type. - { - std::unordered_map<int>::iterator I{Map.begin()}; - // CHECK: std::unordered_map<int>::iterator I{Map.begin()}; - - std::unordered_map<int>::iterator I2 = {Map.begin()}; - // CHECK: std::unordered_map<int>::iterator I2 = {Map.begin()}; - } - - // Various forms of construction. Default constructors and constructors with - // all-default parameters shouldn't get transformed. Construction from other - // types is also not allowed. - { - std::unordered_map<int>::iterator copy(Map.begin()); - // CHECK: auto copy(Map.begin()); - - std::unordered_map<int>::iterator def; - // CHECK: std::unordered_map<int>::iterator def; - - // const_iterator has no default constructor, just one that has >0 params - // with defaults. - std::unordered_map<int>::const_iterator constI; - // CHECK: std::unordered_map<int>::const_iterator constI; - - // Uses iterator_provider::const_iterator's conversion constructor. - - std::unordered_map<int>::const_iterator constI2 = def; - // CHECK: std::unordered_map<int>::const_iterator constI2 = def; - - std::unordered_map<int>::const_iterator constI3(def); - // CHECK: std::unordered_map<int>::const_iterator constI3(def); - - // Explicit use of conversion constructor - - std::unordered_map<int>::const_iterator constI4 = std::unordered_map<int>::const_iterator(def); - // CHECK: auto constI4 = std::unordered_map<int>::const_iterator(def); - - // Uses iterator_provider::iterator's const_iterator conversion operator. - - std::unordered_map<int>::iterator I = constI; - // CHECK: std::unordered_map<int>::iterator I = constI; - - std::unordered_map<int>::iterator I2(constI); - // CHECK: std::unordered_map<int>::iterator I2(constI); - } - - // Weird cases of pointers and references to iterators are not transformed. - { - int_iterator I = Vec.begin(); - - int_iterator *IPtr = &I; - // CHECK: int_iterator *IPtr = &I; - - int_iterator &IRef = I; - // CHECK: int_iterator &IRef = I; - } - - { - // Variable declarations in iteration statements. - for (std::vector<int>::iterator I = Vec.begin(); I != Vec.end(); ++I) { - // CHECK: for (auto I = Vec.begin(); I != Vec.end(); ++I) { - } - - // Range-based for loops. - std::array<std::vector<int>::iterator> iter_arr; - for (std::vector<int>::iterator I: iter_arr) { - // CHECK: for (auto I: iter_arr) { - } - - // Test with init-declarator-list. - for (int_iterator I = Vec.begin(), - E = Vec.end(); I != E; ++I) { - // CHECK: for (auto I = Vec.begin(), - // CHECK-NEXT: E = Vec.end(); I != E; ++I) { - } - } - - // Only std containers should be changed. - { - using namespace foo; - vector<int> foo_vec; - vector<int>::iterator I = foo_vec.begin(); - // CHECK: vector<int>::iterator I = foo_vec.begin(); - } - - // Ensure using directives don't interfere with replacement. - { - using namespace std; - vector<int> std_vec; - vector<int>::iterator I = std_vec.begin(); - // CHECK: auto I = std_vec.begin(); - } - - // Make sure references and cv qualifiers don't get removed (i.e. replaced - // with just 'auto'). - { - const auto & I = Vec.begin(); - // CHECK: const auto & I = Vec.begin(); - - auto && I2 = Vec.begin(); - // CHECK: auto && I2 = Vec.begin(); - } - - // Passing a string as an argument to introduce a temporary object - // that will create an expression with cleanups. Bugzilla: 15550 - { - std::unordered_map<int> MapFind; - std::unordered_map<int>::iterator I = MapFind.find("foo"); - // CHECK: auto I = MapFind.find("foo"); - } - - // Test for declaration lists - { - // Ensusre declaration lists that matches the declaration type with written - // no-list initializer are transformed. - std::vector<int>::iterator I = Vec.begin(), E = Vec.end(); - // CHECK: auto I = Vec.begin(), E = Vec.end(); - - // Declaration lists with non-initialized variables should not be - // transformed. - std::vector<int>::iterator J = Vec.begin(), K; - // CHECK: std::vector<int>::iterator J = Vec.begin(), K; - } - return 0; -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp deleted file mode 100644 index 3fca05df29b..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseAuto/new.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s - -class MyType { -}; - -class MyDerivedType : public MyType { -}; - -int main(int argc, char **argv) { - MyType *a = new MyType(); - // CHECK: auto a = new MyType(); - - static MyType *a_static = new MyType(); - // CHECK: static auto a_static = new MyType(); - - MyType *b = new MyDerivedType(); - // CHECK: MyType *b = new MyDerivedType(); - - void *c = new MyType(); - // CHECK: void *c = new MyType(); - - // CV-qualifier tests. - // - // NOTE : the form "type const" is expected here because of a deficiency in - // TypeLoc where CV qualifiers are not considered part of the type location - // info. That is, all that is being replaced in each case is "MyType *" and - // not "MyType * const". - { - static MyType * const d_static = new MyType(); - // CHECK: static auto const d_static = new MyType(); - - MyType * const d3 = new MyType(); - // CHECK: auto const d3 = new MyType(); - - MyType * volatile d4 = new MyType(); - // CHECK: auto volatile d4 = new MyType(); - } - - int (**func)(int, int) = new (int(*[5])(int,int)); - // CHECK: int (**func)(int, int) = new (int(*[5])(int,int)); - - int *e = new int[5]; - // CHECK: auto e = new int[5]; - - MyType *f(new MyType); - // CHECK: auto f(new MyType); - - MyType *g{new MyType}; - // CHECK: MyType *g{new MyType}; - - // Test for declaration lists. - { - MyType *a = new MyType(), *b = new MyType(), *c = new MyType(); - // CHECK: auto a = new MyType(), b = new MyType(), c = new MyType(); - - // Non-initialized declaration should not be transformed. - MyType *d = new MyType(), *e; - // CHECK: MyType *d = new MyType(), *e; - - MyType **f = new MyType*(), **g = new MyType*(); - // CHECK: auto f = new MyType*(), g = new MyType*(); - - // Mismatching types in declaration lists should not be transformed. - MyType *h = new MyType(), **i = new MyType*(); - // CHECK: MyType *h = new MyType(), **i = new MyType*(); - - // '*' shouldn't be removed in case of mismatching types with multiple - // declarations. - MyType *j = new MyType(), *k = new MyType(), **l = new MyType*(); - // CHECK: MyType *j = new MyType(), *k = new MyType(), **l = new MyType*(); - } - - // Test for typedefs. - { - typedef int * int_p; - - int_p a = new int; - // CHECK: auto a = new int; - int_p *b = new int*; - // CHECK: auto b = new int*; - - // Test for typedefs in declarations lists. - int_p c = new int, d = new int; - // CHECK: auto c = new int, d = new int; - - // Different types should not be transformed. - int_p e = new int, *f = new int_p; - // CHECK: int_p e = new int, *f = new int_p; - - int_p *g = new int*, *h = new int_p; - // CHECK: auto g = new int*, h = new int_p; - } - - return 0; -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp b/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp deleted file mode 100644 index 8e21018ef90..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseAuto/new_cv_failing.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-auto %t.cpp -- -std=c++11 -// RUN: FileCheck -input-file=%t.cpp %s -// XFAIL: * - -// None of these tests can pass right now because TypeLoc information where CV -// qualifiers are concerned is not reliable/available. - -class MyType { -}; - -int main (int argc, char **argv) { - const MyType *d = new MyType(); - // CHECK: const auto *d = new MyType(); - - volatile MyType *d2 = new MyType(); - // CHECK: volatile auto *d2 = new MyType(); - - const MyType * volatile e = new MyType(); - // CHECK: const auto * volatile d = new MyType(); - - volatile MyType * const f = new MyType(); - // CHECK: volatile auto * const d2 = new MyType(); - - const MyType *d5 = new const MyType(); - // CHECK: auto d5 = new const MyType(); - - volatile MyType *d6 = new volatile MyType(); - // CHECK: auto d6 = new volatile MyType(); - - const MyType * const d7 = new const MyType(); - // CHECK: const auto d7 = new const MyType(); - - volatile MyType * volatile d8 = new volatile MyType(); - // CHECK: volatile auto d8 = new volatile MyType(); -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/Inputs/basic.h b/clang-tools-extra/test/cpp11-migrate/UseNullptr/Inputs/basic.h deleted file mode 100644 index 144db769c29..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/Inputs/basic.h +++ /dev/null @@ -1,3 +0,0 @@ -int *global_p = 0; -// CHECK: int *global_p = 0; -// HEADERS: int *global_p = nullptr; diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp deleted file mode 100644 index 9057c1a17d7..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// RUN: mkdir -p %T/Inputs -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h -// RUN: cpp11-migrate -use-nullptr %t.cpp -- -std=c++98 -I %T -Wno-non-literal-null-conversion -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h -// RUN: cpp11-migrate -headers -include=%T -use-nullptr %t.cpp -- -std=c++98 -I %T -Wno-non-literal-null-conversion -// RUN: FileCheck -check-prefix=HEADERS -input-file=%T/Inputs/basic.h %S/Inputs/basic.h - -#include "Inputs/basic.h" - -const unsigned int g_null = 0; -#define NULL 0 -// CHECK: #define NULL 0 - -void test_assignment() { - int *p1 = 0; - // CHECK: int *p1 = nullptr; - p1 = 0; - // CHECK: p1 = nullptr; - - int *p2 = NULL; - // CHECK: int *p2 = nullptr; - - p2 = p1; - // CHECK: p2 = p1; - - const int null = 0; - int *p3 = null; - // CHECK: int *p3 = nullptr; - - p3 = NULL; - // CHECK: p3 = nullptr; - - int *p4 = p3; - // CHECK: int *p4 = p3; - - p4 = null; - // CHECK: p4 = nullptr; - - int i1 = 0; - // CHECK: int i1 = 0; - - int i2 = NULL; - // CHECK: int i2 = NULL; - - int i3 = null; - // CHECK: int i3 = null; - - int *p5, *p6, *p7; - p5 = p6 = p7 = NULL; - // CHECK: p5 = p6 = p7 = nullptr; -} - -struct Foo { - Foo(int *p = NULL) : m_p1(p) {} - // CHECK: Foo(int *p = nullptr) : m_p1(p) {} - - void bar(int *p = 0) {} - // CHECK: void bar(int *p = nullptr) {} - - void baz(int i = 0) {} - // CHECK: void baz(int i = 0) {} - - int *m_p1; - static int *m_p2; -}; - -int *Foo::m_p2 = NULL; -// CHECK: int *Foo::m_p2 = nullptr; - -template <typename T> -struct Bar { - Bar(T *p) : m_p(p) { - m_p = static_cast<T*>(NULL); - // CHECK: m_p = static_cast<T*>(nullptr); - - m_p = static_cast<T*>(reinterpret_cast<int*>((void*)NULL)); - // CHECK: m_p = static_cast<T*>(nullptr); - - m_p = static_cast<T*>(p ? p : static_cast<void*>(g_null)); - // CHECK: m_p = static_cast<T*>(p ? p : static_cast<void*>(nullptr)); - - T *p2 = static_cast<T*>(reinterpret_cast<int*>((void*)NULL)); - // CHECK: T *p2 = static_cast<T*>(nullptr); - - m_p = NULL; - // CHECK: m_p = nullptr; - - int i = static_cast<int>(0.f); - // CHECK: int i = static_cast<int>(0.f); - T *i2 = static_cast<int>(0.f); - // CHECK: T *i2 = nullptr; - } - - T *m_p; -}; - -struct Baz { - Baz() : i(0) {} - int i; -}; - -void test_cxx_cases() { - Foo f(g_null); - // CHECK: Foo f(nullptr); - - f.bar(NULL); - // CHECK: f.bar(nullptr); - - f.baz(g_null); - // CHECK: f.baz(g_null); - - f.m_p1 = 0; - // CHECK: f.m_p1 = nullptr; - - Bar<int> b(g_null); - // CHECK: Bar<int> b(nullptr); - - Baz b2; - int Baz::*memptr(0); - // CHECK: int Baz::*memptr(nullptr); - - memptr = 0; - // CHECK: memptr = nullptr; -} - -void test_function_default_param1(void *p = 0); -// CHECK: void test_function_default_param1(void *p = nullptr); - -void test_function_default_param2(void *p = NULL); -// CHECK: void test_function_default_param2(void *p = nullptr); - -void test_function_default_param3(void *p = g_null); -// CHECK: void test_function_default_param3(void *p = nullptr); - -void test_function(int *p) {} -// CHECK: void test_function(int *p) {} - -void test_function_no_ptr_param(int i) {} - -void test_function_call() { - test_function(0); - // CHECK: test_function(nullptr); - - test_function(NULL); - // CHECK: test_function(nullptr); - - test_function(g_null); - // CHECK: test_function(nullptr); - - test_function_no_ptr_param(0); - // CHECK: test_function_no_ptr_param(0); -} - -char *test_function_return1() { - return 0; - // CHECK: return nullptr; -} - -void *test_function_return2() { - return NULL; - // CHECK: return nullptr; -} - -long *test_function_return3() { - return g_null; - // CHECK: return nullptr; -} - -int test_function_return4() { - return 0; - // CHECK: return 0; -} - -int test_function_return5() { - return NULL; - // CHECK: return NULL; -} - -int test_function_return6() { - return g_null; - // CHECK: return g_null; -} - -int *test_function_return_cast1() { - return(int)0; - // CHECK: return nullptr; -} - -int *test_function_return_cast2() { - #define RET return - RET(int)0; - // CHECK: RET nullptr; - #undef RET -} - -// Test parentheses expressions resulting in a nullptr. -int *test_parentheses_expression1() { - return(0); - // CHECK: return(nullptr); -} - -int *test_parentheses_expression2() { - return(int(0.f)); - // CHECK: return(nullptr); -} - -int *test_nested_parentheses_expression() { - return((((0)))); - // CHECK: return((((nullptr)))); -} - -void *test_parentheses_explicit_cast() { - return(static_cast<void*>(0)); - // CHECK: return(static_cast<void*>(nullptr)); -} - -void *test_parentheses_explicit_cast_sequence1() { - return(static_cast<void*>(static_cast<int*>((void*)NULL))); - // CHECK: return(static_cast<void*>(nullptr)); -} - -void *test_parentheses_explicit_cast_sequence2() { - return(static_cast<void*>(reinterpret_cast<int*>((float*)int(0.f)))); - // CHECK: return(static_cast<void*>(nullptr)); -} - -// Test explicit cast expressions resulting in nullptr -struct Bam { - Bam(int *a) {} - Bam(float *a) {} - Bam operator=(int *a) { return Bam(a); } - Bam operator=(float *a) { return Bam(a); } -}; - -void ambiguous_function(int *a) {} -void ambiguous_function(float *a) {} -void const_ambiguous_function(const int *p) {} -void const_ambiguous_function(const float *p) {} - -void test_explicit_cast_ambiguous1() { - ambiguous_function((int*)0); - // CHECK: ambiguous_function((int*)nullptr); -} - -void test_explicit_cast_ambiguous2() { - ambiguous_function((int*)(0)); - // CHECK: ambiguous_function((int*)nullptr); -} - -void test_explicit_cast_ambiguous3() { - ambiguous_function(static_cast<int*>(reinterpret_cast<int*>((float*)0))); - // CHECK: ambiguous_function(static_cast<int*>(nullptr)); -} - -Bam test_explicit_cast_ambiguous4() { - return(((int*)(0))); - // CHECK: return(((int*)nullptr)); -} - -void test_explicit_cast_ambiguous5() { - // Test for ambiguous overloaded constructors - Bam k((int*)(0)); - // CHECK: Bam k((int*)nullptr); - - // Test for ambiguous overloaded operators - k = (int*)0; - // CHECK: k = (int*)nullptr; -} - -void test_const_pointers_abiguous() { - const_ambiguous_function((int*)0); - // CHECK: const_ambiguous_function((int*)nullptr); -} - -// Test where the implicit cast to null is surrounded by another implict cast -// with possible explict casts in-between. -void test_const_pointers() { - const int *const_p1 = 0; - // CHECK: const int *const_p1 = nullptr; - const int *const_p2 = NULL; - // CHECK: const int *const_p2 = nullptr; - const int *const_p3 = (int)0; - // CHECK: const int *const_p3 = nullptr; - const int *const_p4 = (int)0.0f; - // CHECK: const int *const_p4 = nullptr; - const int *const_p5 = (int*)0; - // CHECK: const int *const_p5 = (int*)nullptr; - int *t; - const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(0)); - // CHECK: const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(nullptr)); -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic_failing.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic_failing.cpp deleted file mode 100644 index 32663ffde12..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic_failing.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-nullptr %t.cpp -- -I %S -// RUN: FileCheck -input-file=%t.cpp %s -// XFAIL: * - -#define NULL 0 - -template <typename T> -class A { -public: - A(T *p = NULL) {} - // CHECK: A(T *p = nullptr) {} - - void f() { - Ptr = NULL; - // CHECK: Ptr = nullptr; - } - - T *Ptr; -}; - -template <typename T> -T *f2(T *a = NULL) { - // CHECK: T *f2(T *a = nullptr) { - return a ? a : NULL; - // CHECK: return a ? a : nullptr; -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/macros.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/macros.cpp deleted file mode 100644 index 3c1550d0f07..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/macros.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -use-nullptr %t.cpp -- -I %S -// RUN: FileCheck -input-file=%t.cpp %s -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp -// RUN: cpp11-migrate -use-nullptr -user-null-macros=MY_NULL %t2.cpp -- -I %S -// RUN: FileCheck -check-prefix=USER-SUPPLIED-NULL -input-file=%t2.cpp %s - -#define NULL 0 -// CHECK: #define NULL 0 - -void dummy(int*) {} -void side_effect() {} - -#define MACRO_EXPANSION_HAS_NULL \ - void foo() { \ - dummy(0); \ - dummy(NULL); \ - side_effect(); \ - } - // CHECK: void foo() { \ - // CHECK-NEXT: dummy(0); \ - // CHECK-NEXT: dummy(NULL); \ - -MACRO_EXPANSION_HAS_NULL; -// CHECK: MACRO_EXPANSION_HAS_NULL; -#undef MACRO_EXPANSION_HAS_NULL - - -void test_macro_expansion1() { -#define MACRO_EXPANSION_HAS_NULL \ - dummy(NULL); \ - side_effect(); - // CHECK: dummy(NULL); \ - // CHECK-NEXT: side_effect(); - - MACRO_EXPANSION_HAS_NULL; - // CHECK: MACRO_EXPANSION_HAS_NULL; - -#undef MACRO_EXPANSION_HAS_NULL -} - -// Test macro expansion with cast sequence, PR15572 -void test_macro_expansion2() { -#define MACRO_EXPANSION_HAS_NULL \ - dummy((int*)0); \ - side_effect(); - // CHECK: dummy((int*)0); \ - // CHECK-NEXT: side_effect(); - - MACRO_EXPANSION_HAS_NULL; - // CHECK: MACRO_EXPANSION_HAS_NULL; - -#undef MACRO_EXPANSION_HAS_NULL -} - -void test_macro_expansion3() { -#define MACRO_EXPANSION_HAS_NULL \ - dummy(NULL); \ - side_effect(); - // CHECK: dummy(NULL); \ - // CHECK-NEXT: side_effect(); - -#define OUTER_MACRO \ - MACRO_EXPANSION_HAS_NULL; \ - side_effect(); - - OUTER_MACRO; - // CHECK: OUTER_MACRO; - -#undef OUTER_MACRO -#undef MACRO_EXPANSION_HAS_NULL -} - -void test_macro_expansion4() { -#define MY_NULL NULL - int *p = MY_NULL; - // CHECK: int *p = MY_NULL; - // USER-SUPPLIED-NULL: int *p = nullptr; -#undef MY_NULL -} - -#define IS_EQ(x, y) if (x != y) return; -void test_macro_args() { - int i = 0; - int *Ptr; - - IS_EQ(static_cast<int*>(0), Ptr); - // CHECK: IS_EQ(static_cast<int*>(nullptr), Ptr); - IS_EQ(0, Ptr); // literal - // CHECK: IS_EQ(nullptr, Ptr); - IS_EQ(NULL, Ptr); // macro - // CHECK: IS_EQ(nullptr, Ptr); - - // These are ok since the null literal is not spelled within a macro. -#define myassert(x) if (!(x)) return; - myassert(0 == Ptr); - // CHECK: myassert(nullptr == Ptr); - myassert(NULL == Ptr); - // CHECK: myassert(nullptr == Ptr); - - // These are bad as the null literal is buried in a macro. -#define BLAH(X) myassert(0 == (X)); - // CHECK: #define BLAH(X) myassert(0 == (X)); -#define BLAH2(X) myassert(NULL == (X)); - // CHECK: #define BLAH2(X) myassert(NULL == (X)); - BLAH(Ptr); - // CHECK: BLAH(Ptr); - BLAH2(Ptr); - // CHECK: BLAH2(Ptr); - - // Same as above but testing extra macro expansion. -#define EXPECT_NULL(X) IS_EQ(0, X); - // CHECK: #define EXPECT_NULL(X) IS_EQ(0, X); -#define EXPECT_NULL2(X) IS_EQ(NULL, X); - // CHECK: #define EXPECT_NULL2(X) IS_EQ(NULL, X); - EXPECT_NULL(Ptr); - // CHECK: EXPECT_NULL(Ptr); - EXPECT_NULL2(Ptr); - // CHECK: EXPECT_NULL2(Ptr); - - // Almost the same as above but now null literal is not in a macro so ok - // to transform. -#define EQUALS_PTR(X) IS_EQ(X, Ptr); - EQUALS_PTR(0); - EQUALS_PTR(NULL); - - // Same as above but testing extra macro expansion. -#define EQUALS_PTR_I(X) EQUALS_PTR(X) - EQUALS_PTR_I(0); - // CHECK: EQUALS_PTR_I(nullptr); - EQUALS_PTR_I(NULL); - // CHECK: EQUALS_PTR_I(nullptr); - - // Ok since null literal not within macro. However, now testing macro - // used as arg to another macro. -#define decorate(EXPR) side_effect(); EXPR; - decorate(IS_EQ(NULL, Ptr)); - // CHECK: decorate(IS_EQ(nullptr, Ptr)); - decorate(IS_EQ(0, Ptr)); - // CHECK: decorate(IS_EQ(nullptr, Ptr)); - - // This macro causes a NullToPointer cast to happen where 0 is assigned to z - // but the 0 literal cannot be replaced because it is also used as an - // integer in the comparison. -#define INT_AND_PTR_USE(X) do { int *z = X; if (X == 4) break; } while(false) - INT_AND_PTR_USE(0); - // CHECK: INT_AND_PTR_USE(0); - - // Both uses of X in this case result in NullToPointer casts so replacement - // is possible. -#define PTR_AND_PTR_USE(X) do { int *z = X; if (X != z) break; } while(false) - PTR_AND_PTR_USE(0); - // CHECK: PTR_AND_PTR_USE(nullptr); - PTR_AND_PTR_USE(NULL); - // CHECK: PTR_AND_PTR_USE(nullptr); - -#define OPTIONAL_CODE(...) __VA_ARGS__ -#define NOT_NULL dummy(0) -#define CALL(X) X - OPTIONAL_CODE(NOT_NULL); - // CHECK: OPTIONAL_CODE(NOT_NULL); - CALL(NOT_NULL); - // CHECK: CALL(NOT_NULL); -} diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/nullptr_t.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/nullptr_t.cpp deleted file mode 100644 index a973fb39817..00000000000 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/nullptr_t.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp -// RUN: cpp11-migrate -final-syntax-check -use-nullptr %t.cpp -- --std=c++11 -I %S -// RUN: FileCheck -input-file=%t.cpp %s - -namespace std { - -typedef decltype(nullptr) nullptr_t; - -} // namespace std - -// Just to make sure make_null() could have side effects. -void external(); - -std::nullptr_t make_null() { - external(); - return nullptr; -} - -void func() { - void *CallTest = make_null(); - // CHECK: void *CallTest = make_null(); - - int var = 1; - void *CommaTest = (var+=2, make_null()); - // CHECK: void *CommaTest = (var+=2, make_null()); - - int *CastTest = static_cast<int*>(make_null()); - // CHECK: int *CastTest = static_cast<int*>(make_null()); -} |