File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,9 @@ void UnintendedCharOstreamOutputCheck::check(
60
60
const auto *Call = Result.Nodes .getNodeAs <CXXOperatorCallExpr>(" x" );
61
61
const Expr *Value = Call->getArg (1 );
62
62
diag (Call->getOperatorLoc (),
63
- " ( %0 passed to 'operator<<' outputs as character instead of integer. "
63
+ " %0 passed to 'operator<<' outputs as character instead of integer. "
64
64
" cast to 'unsigned' to print numeric value or cast to 'char' to print "
65
- " as character) " )
65
+ " as character" )
66
66
<< Value->getType () << Value->getSourceRange ();
67
67
}
68
68
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ It could be fixed as
21
21
22
22
.. code-block :: c++
23
23
24
- std::cout << ( uint32_t)v ;
24
+ std::cout << static_cast< uint32_t>(v) ;
25
25
26
26
Or cast to char to explicitly indicate the intent
27
27
28
28
.. code-block :: c++
29
29
30
- std::cout << ( char)v ;
30
+ std::cout << static_cast< char>(v) ;
Original file line number Diff line number Diff line change @@ -30,12 +30,12 @@ class A : public std::ostream {};
30
30
void origin_ostream (std::ostream &os) {
31
31
unsigned char unsigned_value = 9 ;
32
32
os << unsigned_value;
33
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: ( 'unsigned char' passed to
33
+ // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to
34
34
// 'operator<<' outputs as character instead of integer
35
35
36
36
signed char signed_value = 9 ;
37
37
os << signed_value;
38
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: ( 'signed char' passed to
38
+ // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'signed char' passed to
39
39
// 'operator<<' outputs as character instead of integer
40
40
41
41
char char_value = 9 ;
@@ -45,12 +45,12 @@ void origin_ostream(std::ostream &os) {
45
45
void based_on_ostream (A &os) {
46
46
unsigned char unsigned_value = 9 ;
47
47
os << unsigned_value;
48
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: ( 'unsigned char' passed to
48
+ // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'unsigned char' passed to
49
49
// 'operator<<' outputs as character instead of integer
50
50
51
51
signed char signed_value = 9 ;
52
52
os << signed_value;
53
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: ( 'signed char' passed to
53
+ // CHECK-MESSAGES: [[@LINE-1]]:6: warning: 'signed char' passed to
54
54
// 'operator<<' outputs as character instead of integer
55
55
56
56
char char_value = 9 ;
You can’t perform that action at this time.
0 commit comments