Using clang-rename to move a class from the global namespace

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using clang-rename to move a class from the global namespace

Tom Stellard via cfe-dev
Hi,

If I have this input:

----
class C;

class C {
public:
  C();
  ~C();
  void foo();
};

C::C() {}

C::~C() {}

void C::foo() {}

int main() {
  C c;
  c.foo();
  return 0;
}
----

The actual result of "clang-rename -qualified-name=C -new-name=ns::C
test.cpp --" is:

----
class ns::C;

class ns::C {
public:
  ns::C();
  ~ns::C();
  void foo();
};

ns::C::ns::C() {}

ns::C::~ns::C() {}

void ns::C::foo() {}

int main() {
  ns::C c;
  c.foo();
  return 0;
}
----

While I guess the expected output would be something like:

----
namespace ns {
class C;
}

namespace ns {
class C {
public:
  C();
  ~C();
  void foo();
};
}

ns::C::C() {}

ns::C::~C() {}

void ns::C::foo() {}

int main() {
  ns::C c;
  c.foo();
  return 0;
}
----

My questions:

- Is such a "move a class from global namespace" change in-scope for
  clang-rename? I'm asking, because if so, I would try to came up with
  patches to improve the situation.
- I'm a bit confused if <https://reviews.llvm.org/D31176> is related to
  the topic I bring up here or not. It sounds related by reading the
  patch, but I can't be sure, since as the commit message says the
  commandline behavior is so far unchanged.

Thanks,

Miklos

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (188 bytes) Download Attachment
Loading...