Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst

raw
1 .. title:: clang-tidy - bugprone-unused-return-value
2
3 bugprone-unused-return-value
4 ============================
5
6 Warns on unused function return values. The checked functions can be configured.
7
8 Options
9 -------
10
11 .. option:: CheckedFunctions
12
13 Semicolon-separated list of functions to check. The function is checked if
14 the name and scope matches, with any arguments.
15 By default the following functions are checked:
16 ``std::async, std::launder, std::remove, std::remove_if, std::unique,
17 std::unique_ptr::release, std::basic_string::empty, std::vector::empty,
18 std::back_inserter, std::distance, std::find, std::find_if, std::inserter,
19 std::lower_bound, std::make_pair, std::map::count, std::map::find,
20 std::map::lower_bound, std::multimap::equal_range,
21 std::multimap::upper_bound, std::set::count, std::set::find, std::setfill,
22 std::setprecision, std::setw, std::upper_bound, std::vector::at,
23 bsearch, ferror, feof, isalnum, isalpha, isblank, iscntrl, isdigit, isgraph,
24 islower, isprint, ispunct, isspace, isupper, iswalnum, iswprint, iswspace,
25 isxdigit, memchr, memcmp, strcmp, strcoll, strncmp, strpbrk, strrchr,
26 strspn, strstr, wcscmp, access, bind, connect, difftime, dlsym, fnmatch,
27 getaddrinfo, getopt, htonl, htons, iconv_open, inet_addr, isascii, isatty,
28 mmap, newlocale, openat, pathconf, pthread_equal, pthread_getspecific,
29 pthread_mutex_trylock, readdir, readlink, recvmsg, regexec, scandir,
30 semget, setjmp, shm_open, shmget, sigismember, strcasecmp, strsignal,
31 ttyname``
32
33 - ``std::async()``. Not using the return value makes the call synchronous.
34 - ``std::launder()``. Not using the return value usually means that the
35 function interface was misunderstood by the programmer. Only the returned
36 pointer is "laundered", not the argument.
37 - ``std::remove()``, ``std::remove_if()`` and ``std::unique()``. The returned
38 iterator indicates the boundary between elements to keep and elements to be
39 removed. Not using the return value means that the information about which
40 elements to remove is lost.
41 - ``std::unique_ptr::release()``. Not using the return value can lead to
42 resource leaks if the same pointer isn't stored anywhere else. Often,
43 ignoring the ``release()`` return value indicates that the programmer
44 confused the function with ``reset()``.
45 - ``std::basic_string::empty()`` and ``std::vector::empty()``. Not using the
46 return value often indicates that the programmer confused the function with
47 ``clear()``.
48
49 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
50 fixed and large set of standard library functions.