summaryrefslogtreecommitdiffstats
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-09-27 07:52:11 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-09-27 07:53:00 +0200
commitf79123a823f44a8b70f94e31714e6aade019feb9 (patch)
tree0b72b9915e19b91ec311411cb84bd7f7ff5ae348 /compilerplugins
parentMake these tests part of the regular 'make check' (diff)
downloadcore-f79123a823f44a8b70f94e31714e6aade019feb9.tar.gz
core-f79123a823f44a8b70f94e31714e6aade019feb9.zip
loplugin:stringconstant: Also handle u8"..." strings
(just in case) Change-Id: Id8ce7436bacba874d9bc04915e42622e3cfca67a
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/stringconstant.cxx2
-rw-r--r--compilerplugins/clang/test/stringconstant.cxx2
2 files changed, 3 insertions, 1 deletions
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index a4e0b79438b2..31cccb9b2c4a 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -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();
diff --git a/compilerplugins/clang/test/stringconstant.cxx b/compilerplugins/clang/test/stringconstant.cxx
index 41112d836520..8a830f12c717 100644
--- a/compilerplugins/clang/test/stringconstant.cxx
+++ b/compilerplugins/clang/test/stringconstant.cxx
@@ -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]}}
}