Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/llvmlibc/implementation-in-namespace.rst

raw
1 .. title:: clang-tidy - llvmlibc-implementation-in-namespace
2
3 llvmlibc-implementation-in-namespace
4 ====================================
5
6 Checks that all declarations in the llvm-libc implementation are within the
7 correct namespace.
8
9 .. code-block:: c++
10
11 // Implementation inside the LIBC_NAMESPACE_DECL namespace.
12 // Correct if:
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.
18 namespace inner {
19 int localVar = 0;
20 }
21 // Functions with C linkage are allowed.
22 extern "C" void str_fuzz() {}
23 }
24
25 // Incorrect: implementation not in the LIBC_NAMESPACE_DECL namespace.
26 void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
27
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) {}
31 }
32
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) {}
37 }