Skip to content

Commit 9033197

Browse files
committed
fix review
1 parent 22b8bd8 commit 9033197

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ void UnintendedCharOstreamOutputCheck::check(
6060
const auto *Call = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("x");
6161
const Expr *Value = Call->getArg(1);
6262
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. "
6464
"cast to 'unsigned' to print numeric value or cast to 'char' to print "
65-
"as character)")
65+
"as character")
6666
<< Value->getType() << Value->getSourceRange();
6767
}
6868

clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ It could be fixed as
2121

2222
.. code-block:: c++
2323

24-
std::cout << (uint32_t)v;
24+
std::cout << static_cast<uint32_t>(v);
2525

2626
Or cast to char to explicitly indicate the intent
2727

2828
.. code-block:: c++
2929

30-
std::cout << (char)v;
30+
std::cout << static_cast<char>(v);

clang-tools-extra/test/clang-tidy/checkers/bugprone/unintended-char-ostream-output.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class A : public std::ostream {};
3030
void origin_ostream(std::ostream &os) {
3131
unsigned char unsigned_value = 9;
3232
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
3434
// 'operator<<' outputs as character instead of integer
3535

3636
signed char signed_value = 9;
3737
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
3939
// 'operator<<' outputs as character instead of integer
4040

4141
char char_value = 9;
@@ -45,12 +45,12 @@ void origin_ostream(std::ostream &os) {
4545
void based_on_ostream(A &os) {
4646
unsigned char unsigned_value = 9;
4747
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
4949
// 'operator<<' outputs as character instead of integer
5050

5151
signed char signed_value = 9;
5252
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
5454
// 'operator<<' outputs as character instead of integer
5555

5656
char char_value = 9;

0 commit comments

Comments
 (0)