Skip to content

Commit 1f7748d

Browse files
committed
friend
1 parent 3b36a43 commit 1f7748d

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,32 @@ The check will suggest adding the appropriate namespace qualification:
3131
- void process() {}
3232
+ void utils::process() {}
3333
34-
Options
35-
-------
36-
37-
None
34+
The check will not warn about:
35+
- Static functions or member functions;
36+
- Functions in anonymous namespaces;
37+
- The ``main`` function.
3838

3939
Limitations
4040
-----------
4141

42-
- Does not warn about functions in anonymous namespaces
42+
- Does not warn about friend functions:
43+
44+
.. code-block:: c++
45+
46+
namespace llvm::gsym {
47+
struct MergedFunctionsInfo {
48+
friend bool operator==(const llvm::gsym::MergedFunctionsInfo &LHS,
49+
const llvm::gsym::MergedFunctionsInfo &RHS);
50+
};
51+
}
52+
53+
using namespace llvm::gsym;
54+
55+
bool operator==(const MergedFunctionsInfo &LHS, // no warning in this version
56+
const MergedFunctionsInfo &RHS) {
57+
return LHS.MergedFunctions == RHS.MergedFunctions;
58+
}
59+
4360
- Does not warn about template functions
44-
- Does not warn about static functions or member functions
4561
- Does not warn about variadic functions
46-
- Does not warn about the ``main`` function
62+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %check_clang_tidy %s misc-shadowed-namespace-function %t
2+
3+
4+
namespace foo { struct A; }
5+
void f1(foo::A);
6+
7+
namespace foo {
8+
struct A{
9+
friend void f0(A);
10+
friend void f1(A);
11+
};
12+
}
13+
14+
// FIXME: provide warning without fixit in these two cases
15+
void f0(foo::A) {}
16+
void f1(foo::A) {}

0 commit comments

Comments
 (0)