1// RUN: %check_clang_tidy %s google-readability-namespace-comments %t \
2// RUN: -config='{CheckOptions: { \
3// RUN: google-readability-namespace-comments.AllowOmittingNamespaceComments: true, \
4// RUN: google-readability-namespace-comments.ShortNamespaceLines: 0, \
5// RUN: }}'
6
7// accept if namespace comments are fully omitted
8namespace n1 {
9namespace /* a comment */ n2 /* another comment */ {
10void f();
11}}
12
13#define MACRO macro_expansion
14namespace MACRO {
15void f();
16}
17
18namespace [[deprecated("foo")]] namespace_with_attr {
19inline namespace inline_namespace {
20void f();
21}
22}
23
24namespace [[]] {
25void f();
26}
27
28// accept if namespace comments are partly omitted (e.g. only for nested namespace)
29namespace n3 {
30namespace n4 {
31void f();
32} // n4
33}
34
35// fail if namespace comment is different than expected
36namespace n1 {
37void f();
38} // namespace n2
39// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: namespace 'n1' ends with a comment that refers to a wrong namespace 'n2' [google-readability-namespace-comments]
40
41

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of clang-tools-extra/test/clang-tidy/checkers/google/readability-namespace-comments-missing.cpp