Skip to content

Commit 199ecec

Browse files
committed
Docs written by DeepSeek
1 parent e9de03d commit 199ecec

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

clang-tools-extra/docs/clang-tidy/checks/misc/shadowed-namespace-function.rst

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,44 @@
33
misc-shadowed-namespace-function
44
================================
55

6-
FIXME: Describe what patterns does the check detect and why. Give examples.
6+
Detects free functions in the global namespace that shadow functions declared
7+
in other namespaces. This check helps prevent accidental shadowing of namespace
8+
functions, which can lead to confusion about which function is being called and
9+
potential linking errors.
10+
11+
Examples
12+
--------
13+
14+
.. code-block:: c++
15+
16+
namespace utils {
17+
void process();
18+
void calculate();
19+
}
20+
21+
// Warning: free function shadows utils::process
22+
void process() {}
23+
24+
// No warning - static function
25+
static void calculate() {}
26+
27+
The check will suggest adding the appropriate namespace qualification:
28+
29+
.. code-block:: diff
30+
31+
- void process() {}
32+
+ void utils::process() {}
33+
34+
Options
35+
-------
36+
37+
None
38+
39+
Limitations
40+
-----------
41+
42+
- Does not warn about functions in anonymous namespaces
43+
- Does not warn about template functions
44+
- Does not warn about static functions or member functions
45+
- Does not warn about the ``main`` function
46+
- Only considers functions declared before the global definition

0 commit comments

Comments
 (0)