diff options
| author | Edwin Vane <edwin.vane@intel.com> | 2013-05-10 14:04:58 +0000 |
|---|---|---|
| committer | Edwin Vane <edwin.vane@intel.com> | 2013-05-10 14:04:58 +0000 |
| commit | b8c38756180df345534d4c816f648a9d74760f42 (patch) | |
| tree | f1e202458b7722d4d54c9ce2825be86d3e2997d1 /clang-tools-extra/test/cpp11-migrate | |
| parent | 66e4f83c072b9dc552f35cf31add92d9f382feba (diff) | |
| download | bcm5719-llvm-b8c38756180df345534d4c816f648a9d74760f42.tar.gz bcm5719-llvm-b8c38756180df345534d4c816f648a9d74760f42.zip | |
cpp11-migrate: Fix crash in AddOverride due to template instantiations
This patch fixes different issues:
- override is not added in template 'contexts' (this will be further improved
to handle safe situations, a test for this has been written already)
- the main file is now checked before the modifications are applied
- override is not applied now when dealing with pure methods since it was
misplaced (ignoring it isn't the perfect solution but it seems difficult to
find the location just before the pure-specifier)
Fixes PR15827
Author: Guillaume Papin <guillaume.papin@epitech.eu>
llvm-svn: 181596
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate')
| -rw-r--r-- | clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp | 38 | ||||
| -rw-r--r-- | clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp | 20 |
2 files changed, 58 insertions, 0 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp b/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp index 1c3616bfcbb..1c1c95d8146 100644 --- a/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp +++ b/clang-tools-extra/test/cpp11-migrate/AddOverride/basic.cpp @@ -108,3 +108,41 @@ public: // CHECK: void h() const LLVM_OVERRIDE; }; +// 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: void f(); +}; +Derived<Base1> d1; +Derived<Base2> d2; + +template <typename T> +class M : public A { +public: + virtual void i(); + // CHECK: class M : public A { + // CHECK: virtual void i() override; +}; +M<int> b; 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 new file mode 100644 index 00000000000..a9d4c912ff1 --- /dev/null +++ b/clang-tools-extra/test/cpp11-migrate/AddOverride/pure_specifier_fail.cpp @@ -0,0 +1,20 @@ +// 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(); } +}; |

