1 // RUN: %check_clang_tidy %s llvmlibc-implementation-in-namespace %t
2 
3 #define MACRO_A "defining macros outside namespace is valid"
4 
5 class ClassB;
6 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be declared within the '__llvm_libc' namespace
7 struct StructC {};
8 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration must be declared within the '__llvm_libc' namespace
9 char *VarD = MACRO_A;
10 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be declared within the '__llvm_libc' namespace
11 typedef int typeE;
12 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: declaration must be declared within the '__llvm_libc' namespace
funcF()13 void funcF() {}
14 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration must be declared within the '__llvm_libc' namespace
15 
16 namespace namespaceG {
17 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: '__llvm_libc' needs to be the outermost namespace
18 namespace __llvm_libc{
19 namespace namespaceH {
20 class ClassB;
21 } // namespace namespaceH
22 struct StructC {};
23 } // namespace __llvm_libc
24 char *VarD = MACRO_A;
25 typedef int typeE;
funcF()26 void funcF() {}
27 } // namespace namespaceG
28 
29 // Wrapped in correct namespace.
30 namespace __llvm_libc {
31 // Namespaces within __llvim_libc namespace allowed.
32 namespace namespaceI {
33 class ClassB;
34 } // namespace namespaceI
35 struct StructC {};
36 char *VarD = MACRO_A;
37 typedef int typeE;
funcF()38 void funcF() {}
extern_funcJ()39 extern "C" void extern_funcJ() {}
40 } // namespace __llvm_libc
41