1// RUN: %check_clang_tidy %s bugprone-unused-return-value %t \
2// RUN: -config='{CheckOptions: \
3// RUN: {bugprone-unused-return-value.CheckedFunctions: "::*"}}' \
4// RUN: --
5
6struct S1 {
7 S1(){};
8 S1(S1 const &);
9 S1(S1 &&);
10 S1 &operator=(S1 const &);
11 S1 &operator=(S1 &&);
12 S1 &operator+=(S1);
13 S1 &operator++();
14 S1 &operator++(int);
15 S1 &operator--();
16 S1 &operator--(int);
17};
18
19struct S2 {
20 S2(){};
21 S2(S2 const &);
22 S2(S2 &&);
23};
24
25S2 &operator-=(S2&, int);
26S2 &operator++(S2 &);
27S2 &operator++(S2 &, int);
28
29S1 returnValue();
30S1 const &returnRef();
31
32void bar() {
33 returnValue();
34 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should not be disregarded; neglecting it may lead to errors
35
36 S1 a{};
37 a = returnValue();
38 a.operator=(returnValue());
39
40 a = returnRef();
41 a.operator=(returnRef());
42
43 a += returnRef();
44
45 a++;
46 ++a;
47 a--;
48 --a;
49
50 S2 b{};
51
52 b -= 1;
53 b++;
54 ++b;
55}
56

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value-avoid-assignment.cpp