mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-27 03:48:33 +00:00
[clang-tidy] misc-string-integer-assignment: fix false positive
Summary: using CodePoint = uint32_t; CodePoint cp; basic_string<CodePoint> s; s += cp; See PR27723. Reviewers: xazax.hun, alexfh Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58606 llvm-svn: 355076
This commit is contained in:
parent
c6846b8800
commit
ff5e4bcad0
@ -26,7 +26,8 @@ void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) {
|
||||
hasOverloadedOperatorName("+=")),
|
||||
callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
|
||||
hasName("::std::basic_string"),
|
||||
hasTemplateArgument(0, refersToType(qualType().bind("type"))))))),
|
||||
hasTemplateArgument(0, refersToType(hasCanonicalType(
|
||||
qualType().bind("type")))))))),
|
||||
hasArgument(
|
||||
1,
|
||||
ignoringImpCasts(
|
||||
@ -34,7 +35,11 @@ void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Ignore calls to tolower/toupper (see PR27723).
|
||||
unless(callExpr(callee(functionDecl(
|
||||
hasAnyName("tolower", "std::tolower", "toupper",
|
||||
"std::toupper"))))))
|
||||
"std::toupper"))))),
|
||||
// Do not warn if assigning e.g. `CodePoint` to
|
||||
// `basic_string<CodePoint>`
|
||||
unless(hasType(qualType(
|
||||
hasCanonicalType(equalsBoundNode("type"))))))
|
||||
.bind("expr"))),
|
||||
unless(isInTemplateInstantiation())),
|
||||
this);
|
||||
|
@ -53,8 +53,8 @@ int main() {
|
||||
|
||||
std::basic_string<MyArcaneChar> as;
|
||||
as = 6;
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
|
||||
// CHECK-FIXES: {{^}} as = 6;{{$}}
|
||||
as = static_cast<MyArcaneChar>(6);
|
||||
as = 'a';
|
||||
|
||||
s += toupper(x);
|
||||
s += tolower(x);
|
||||
|
Loading…
x
Reference in New Issue
Block a user