[PATCH] D58606: [clang-tidy] misc-string-integer-assignment: fix false positive

Clement Courbet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 25 04:27:53 PST 2019


courbet created this revision.
courbet added reviewers: xazax.hun, alexfh.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a project: clang.

using CodePoint = uint32_t;
CodePoint cp;
casic_string<CodePoint> s;
s += cp;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58606

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp


Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===================================================================
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -29,7 +29,9 @@
               hasTemplateArgument(0, refersToType(qualType().bind("type"))))))),
           hasArgument(1,
                       ignoringImpCasts(expr(hasType(isInteger()),
-                                            unless(hasType(isAnyCharacter())))
+                                            unless(hasType(isAnyCharacter())),
+                                            // Do not warn if assigning e.g. `CodePoint` to `basic_string<CodePoint>`
+                                            unless(hasType(type(equalsBoundNode("type")))))
                                            .bind("expr"))),
           unless(isInTemplateInstantiation())),
       this);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58606.188130.patch
Type: text/x-patch
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190225/7f477f45/attachment.bin>


More information about the cfe-commits mailing list