xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/llvmlibc/callee-namespace.rst (revision daca97216cf132d733513f992d49e3c722aabf40)
1.. title:: clang-tidy - llvmlibc-callee-namespace
2
3llvmlibc-callee-namespace
4====================================
5
6Checks all calls resolve to functions within correct namespace.
7
8.. code-block:: c++
9
10    // Implementation inside the LIBC_NAMESPACE namespace.
11    // Correct if:
12    // - LIBC_NAMESPACE is a macro
13    // - LIBC_NAMESPACE expansion starts with `__llvm_libc`
14    namespace LIBC_NAMESPACE {
15
16    // Allow calls with the fully qualified name.
17    LIBC_NAMESPACE::strlen("hello");
18
19    // Allow calls to compiler provided functions.
20    (void)__builtin_abs(-1);
21
22    // Bare calls are allowed as long as they resolve to the correct namespace.
23    strlen("world");
24
25    // Disallow calling into functions in the global namespace.
26    ::strlen("!");
27
28    } // namespace LIBC_NAMESPACE
29