loplugin:stringconstant: Also handle u8"..." strings

(just in case)

Change-Id: Id8ce7436bacba874d9bc04915e42622e3cfca67a
This commit is contained in:
Stephan Bergmann 2017-09-27 07:52:11 +02:00
parent 9444671f1e
commit f79123a823
2 changed files with 3 additions and 1 deletions

View File

@ -1163,7 +1163,7 @@ bool StringConstant::isStringConstant(
}
clang::StringLiteral const * lit = dyn_cast<clang::StringLiteral>(expr);
if (lit != nullptr) {
if (!lit->isAscii()) {
if (!(lit->isAscii() || lit->isUTF8())) {
return false;
}
unsigned n = lit->getLength();

View File

@ -66,6 +66,8 @@ int main() {
(void) OUString("x\xA0x", 3, RTL_TEXTENCODING_ISO_8859_1);
(void) OUString("xxx", 2, RTL_TEXTENCODING_ASCII_US); // expected-error {{suspicious 'rtl::OUString' constructor with literal of length 3 and non-matching length argument 2 [loplugin:stringconstant]}}
(void) OUString(u8"xxx", 3, RTL_TEXTENCODING_ASCII_US); // expected-error {{simplify construction of 'OUString' with string constant argument [loplugin:stringconstant]}}
}