[PATCH] D15411: [clang-tidy] Check for suspicious string assignments.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 14 17:04:42 PST 2015
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.
Looks good with a few nits.
Thank you for the new awesome check!
================
Comment at: clang-tidy/misc/StringIntegerAssignmentCheck.cpp:74
@@ +73,3 @@
+ return;
+ } else if (IsLiteral) {
+ Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L\"" : "\"")
----------------
Don't use `else` after a `return`.
================
Comment at: test/clang-tidy/misc-string-integer-assignment.cpp:27
@@ +26,3 @@
+ s = 66;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: an integer is interpreted as a character code when assigning {{.*}} [misc-string-integer-assignment]
+// CHECK-FIXES: {{^}} s = "66";{{$}}
----------------
I'd also remove the check name from all CHECK lines after the first one to fit the CHECK lines to 80 columns.
================
Comment at: test/clang-tidy/misc-string-integer-assignment.cpp:46
@@ +45,3 @@
+ ws += L'c';
+ ws += (wchar_t)6;
+
----------------
LegalizeAdulthood wrote:
> Use `static_cast<>` instead of C-style cast?
I think, both casts should be tested at least once. And it doesn't matter what cast style is used in the rest of the test.
http://reviews.llvm.org/D15411
More information about the cfe-commits
mailing list