1 .. title:: clang-tidy - llvmlibc-implementation-in-namespace
3 llvmlibc-implementation-in-namespace
4 ====================================
6 Checks that all declarations in the llvm-libc implementation are within the
11 // Implementation inside the LIBC_NAMESPACE_DECL namespace.
13 // - LIBC_NAMESPACE_DECL is a macro
14 // - LIBC_NAMESPACE_DECL expansion starts with `[[gnu::visibility("hidden")]] __llvm_libc`
15 namespace LIBC_NAMESPACE_DECL {
16 void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
17 // Namespaces within LIBC_NAMESPACE_DECL namespace are allowed.
21 // Functions with C linkage are allowed.
22 extern "C" void str_fuzz() {}
25 // Incorrect: implementation not in the LIBC_NAMESPACE_DECL namespace.
26 void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
28 // Incorrect: outer most namespace is not the LIBC_NAMESPACE_DECL macro.
29 namespace something_else {
30 void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
33 // Incorrect: outer most namespace expansion does not start with `[[gnu::visibility("hidden")]] __llvm_libc`.
34 #define LIBC_NAMESPACE_DECL custom_namespace
35 namespace LIBC_NAMESPACE_DECL {
36 void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}