Skip to content

Commit f10f7d8

Browse files
committed
Add caveat: symbol references not updated
1 parent ec825b4 commit f10f7d8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

clang-tools-extra/docs/clang-change-namespace.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,42 @@ But this will put the `inline` keyword in the wrong place resulting in:
227227
Apparently one cannot use `:program:`clang-change-namespace` to inline a
228228
namespace.
229229

230+
Symbol references not updated
231+
-----------------------------
232+
233+
Consider this `test.cc` file:
234+
235+
.. code-block:: c++
236+
237+
namespace old {
238+
struct foo {};
239+
} // namespace old
240+
241+
namespace b {
242+
old::foo g_foo;
243+
} // namespace b
244+
245+
Notice that namespace `b` defines a global variable of type `old::foo`. If we
246+
now change the name of the `old` namespace to `modern`, the reference will not
247+
be updated:
248+
249+
.. code-block:: console
250+
251+
clang-change-namespace --old_namespace 'old' --new_namespace 'modern' --file_pattern test.cc test.cc
252+
253+
.. code-block:: c++
254+
255+
namespace modern {
256+
struct foo {};
257+
} // namespace modern
258+
259+
namespace b {
260+
old::foo g_foo;
261+
} // namespace b
262+
263+
`g_foo` is still of the no longer existing type `old::foo` while instead it
264+
should use `modern::foo`.
265+
230266

231267
:program:`clang-change-namespace` Command Line Options
232268
======================================================

0 commit comments

Comments
 (0)