Skip to content

Commit 5994fc0

Browse files
committed
more tests && fix the doc
1 parent 320f6c7 commit 5994fc0

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

clang-tools-extra/clang-tidy/misc/ShadowedNamespaceFunctionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void ShadowedNamespaceFunctionCheck::check(
7070
return;
7171

7272
// Generate warning message
73-
std::string NamespaceName = ShadowedNamespace->getNameAsString();
73+
std::string NamespaceName = ShadowedNamespace->getQualifiedNameAsString();
7474
auto Diag = diag(Func->getLocation(),
7575
"free function %0 shadows '%1::%2'")
7676
<< Func->getDeclName()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ Limitations
4343
- Does not warn about template functions
4444
- Does not warn about static functions or member functions
4545
- Does not warn about the ``main`` function
46-
- Only considers functions declared before the global definition
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %check_clang_tidy %s misc-shadowed-namespace-function %t
2+
3+
namespace { void f1(); }
4+
namespace foo {
5+
void f0();
6+
void f1();
7+
}
8+
namespace {
9+
void f0() {}
10+
void f1() {}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %check_clang_tidy %s misc-shadowed-namespace-function %t
2+
3+
void f1();
4+
namespace foo::foo2::foo3 {
5+
void f0();
6+
void f1();
7+
}
8+
void f0() {}
9+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: free function 'f0' shadows 'foo::foo2::foo3::f0' [misc-shadowed-namespace-function]
10+
// CHECK-FIXES: void foo::foo2::foo3::f0() {}
11+
void f1() {}
12+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: free function 'f1' shadows 'foo::foo2::foo3::f1' [misc-shadowed-namespace-function]
13+
// CHECK-MESSAGES-NOT: :[[@LINE-2]]:{{.*}}: note: FIX-IT applied suggested code changes
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %check_clang_tidy %s misc-shadowed-namespace-function %t
2+
3+
static void f1();
4+
namespace foo {
5+
void f0();
6+
void f1();
7+
}
8+
static void f0() {}
9+
static void f1() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %check_clang_tidy %s misc-shadowed-namespace-function %t
2+
3+
template<typename T>
4+
void f1();
5+
namespace foo {
6+
template<typename T>
7+
void f0();
8+
template<typename T>
9+
void f1();
10+
}
11+
template<typename T>
12+
void f0() {}
13+
template<typename T>
14+
void f1() {}

0 commit comments

Comments
 (0)