1// RUN: %check_clang_tidy %s misc-use-anonymous-namespace %t -- -header-filter=.* -- -I%S/Inputs
2#include "use-anonymous-namespace.h"
3
4static void f1();
5// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function 'f1' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
6static int v1;
7// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'v1' declared 'static', move to anonymous namespace instead
8
9namespace a {
10 static void f3();
11 // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: function 'f3' declared 'static', move to anonymous namespace instead
12 static int v3;
13 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: variable 'v3' declared 'static', move to anonymous namespace instead
14}
15
16// OK
17void f5();
18int v5;
19
20// OK
21namespace {
22 void f6();
23 int v6;
24}
25
26// OK
27namespace a {
28namespace {
29 void f7();
30 int v7;
31}
32}
33
34// OK
35struct Foo {
36 static void f();
37 static int x;
38};
39
40// OK
41void foo()
42{
43 static int x;
44}
45
46// OK
47static const int v8{123};
48static constexpr int v9{123};
49

source code of clang-tools-extra/test/clang-tidy/checkers/misc/use-anonymous-namespace.cpp