1// RUN: clang-tidy %s -checks='-*,google-build-namespaces,google-build-using-namespace' -header-filter='.*' -- | FileCheck %s -implicit-check-not="{{warning|error}}:"
2#include "Inputs/google-namespaces.h"
3// CHECK: warning: do not use unnamed namespaces in header files [google-build-namespaces]
4
5using namespace spaaaace;
6// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
7
8using spaaaace::core; // no-warning
9
10namespace std {
11inline namespace literals {
12inline namespace chrono_literals {
13}
14inline namespace complex_literals {
15}
16inline namespace string_literals {
17}
18}
19}
20
21using namespace std::chrono_literals; // no-warning
22using namespace std::complex_literals; // no-warning
23using namespace std::literals; // no-warning
24using namespace std::literals::chrono_literals; // no-warning
25using namespace std::literals::complex_literals; // no-warning
26using namespace std::literals::string_literals; // no-warning
27using namespace std::string_literals; // no-warning
28
29namespace literals {}
30
31using namespace literals;
32// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
33
34namespace foo {
35inline namespace literals {
36inline namespace bar_literals {}
37}
38}
39
40using namespace foo::literals;
41// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
42
43using namespace foo::bar_literals;
44// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
45
46using namespace foo::literals::bar_literals;
47// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
48
49namespace foo_literals {}
50
51using namespace foo_literals;
52// CHECK: :[[@LINE-1]]:1: warning: do not use namespace using-directives; use using-declarations instead [google-build-using-namespace]
53

source code of clang-tools-extra/test/clang-tidy/checkers/google/namespaces.cpp