summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/change-namespace/lambda-function.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-11-16 16:54:53 +0000
committerEric Liu <ioeric@google.com>2016-11-16 16:54:53 +0000
commitff51f011d1edb2de79a2448f68e9de1788596184 (patch)
treef81c6e2696885fbd785e66cde1abcd61a2a981a1 /clang-tools-extra/test/change-namespace/lambda-function.cpp
parent3a83e76811d7d8b8a4bfd45943dbd89cb08ee522 (diff)
downloadbcm5719-llvm-ff51f011d1edb2de79a2448f68e9de1788596184.tar.gz
bcm5719-llvm-ff51f011d1edb2de79a2448f68e9de1788596184.zip
[change-namespace] handle constructor initializer: Derived : Base::Base() {} and added conflict detections
Summary: namespace nx { namespace ny { class Base { public: Base(i) {}} } } namespace na { namespace nb { class X : public nx::ny { public: X() : Base::Base(1) {} }; } } When changing from na::nb to x::y, "Base::Base" will be changed to "nx::ny::Base" and "Base::" in "Base::Base" will be replaced with "nx::ny::Base" too, which causes conflict. This conflict should've been detected when adding replacements but was hidden by `addOrMergeReplacement`. We now also detect conflict when adding replacements where conflict must not happen. The namespace lookup is tricky here, we simply replace "Base::Base()" with "nx::ny::Base()" as a workaround, which compiles but not perfect. Reviewers: hokein Subscribers: bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D26637 llvm-svn: 287118
Diffstat (limited to 'clang-tools-extra/test/change-namespace/lambda-function.cpp')
-rw-r--r--clang-tools-extra/test/change-namespace/lambda-function.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang-tools-extra/test/change-namespace/lambda-function.cpp b/clang-tools-extra/test/change-namespace/lambda-function.cpp
new file mode 100644
index 00000000000..484989ef41a
--- /dev/null
+++ b/clang-tools-extra/test/change-namespace/lambda-function.cpp
@@ -0,0 +1,22 @@
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" %s -- -std=c++11 | sed 's,// CHECK.*,,' | FileCheck %s
+
+template <class T>
+class function;
+template <class R, class... ArgTypes>
+class function<R(ArgTypes...)> {
+public:
+ template <typename Functor>
+ function(Functor f) {}
+ R operator()(ArgTypes...) const {}
+};
+
+// CHECK: namespace x {
+// CHECK-NEXT: namespace y {
+namespace na {
+namespace nb {
+void f(function<void(int)> func, int param) { func(param); }
+void g() { f([](int x) {}, 1); }
+// CHECK: } // namespace y
+// CHECK-NEXT: } // namespace x
+}
+}
OpenPOWER on IntegriCloud