1// RUN: %check_clang_tidy %s bugprone-unintended-char-ostream-output %t -- \
2// RUN: -config="{CheckOptions: \
3// RUN: {bugprone-unintended-char-ostream-output.AllowedTypes: \"\"}}"
4
5namespace std {
6
7template <class _CharT, class _Traits = void> class basic_ostream {
8public:
9 basic_ostream &operator<<(int);
10 basic_ostream &operator<<(unsigned int);
11};
12
13template <class CharT, class Traits>
14basic_ostream<CharT, Traits> &operator<<(basic_ostream<CharT, Traits> &, CharT);
15template <class CharT, class Traits>
16basic_ostream<CharT, Traits> &operator<<(basic_ostream<CharT, Traits> &, char);
17template <class _Traits>
18basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &, char);
19template <class _Traits>
20basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &,
21 signed char);
22template <class _Traits>
23basic_ostream<char, _Traits> &operator<<(basic_ostream<char, _Traits> &,
24 unsigned char);
25
26using ostream = basic_ostream<char>;
27
28} // namespace std
29
30void origin_ostream(std::ostream &os) {
31 unsigned char unsigned_value = 9;
32 os << unsigned_value;
33 // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to 'operator<<' outputs as character instead of integer
34
35 signed char signed_value = 9;
36 os << signed_value;
37 // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'signed char' passed to 'operator<<' outputs as character instead of integer
38
39 char char_value = 9;
40 os << char_value;
41}
42

source code of clang-tools-extra/test/clang-tidy/checkers/bugprone/unintended-char-ostream-output-allowed-types.cpp