summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/stringconstant.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-09-21 22:11:29 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-09-22 08:19:55 +0200
commit7b45044fd14661202c658923842dd629cf52961c (patch)
tree446d1daf9b6ba3795bbbbb534d3d29aba1d47174 /compilerplugins/clang/stringconstant.cxx
parente590e4dd5e8d9e2fb94a5fff80fb5fd468a01de4 (diff)
Also handle OUString with non-RTL_TEXTENCODING_ASCII_US encoding
(just in case) Change-Id: I7ba2967c1cef81a3f6604077d876c8b993f7f16a Reviewed-on: https://gerrit.libreoffice.org/42609 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/stringconstant.cxx')
-rw-r--r--compilerplugins/clang/stringconstant.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index a5ea9506f153..2eab378e443f 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -756,6 +756,8 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
ChangeKind kind;
PassThrough pass;
bool simplify;
+ bool encIsAscii;
+ std::string enc;
switch (expr->getConstructor()->getNumParams()) {
case 1:
if (!loplugin::TypeCheck(
@@ -846,11 +848,12 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
return true;
}
if (!expr->getArg(2)->EvaluateAsInt(
- res, compiler.getASTContext())
- || res != 11) // RTL_TEXTENCODING_ASCII_US
+ res, compiler.getASTContext()))
{
return true;
}
+ encIsAscii = res == 11; // RTL_TEXTENCODING_ASCII_US
+ enc = res.toString(10);
if (!expr->getArg(3)->EvaluateAsInt(
res, compiler.getASTContext())
|| res != 0x333) // OSTRING_TO_OUSTRING_CVTFLAGS
@@ -1056,9 +1059,10 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
if (simplify) {
report(
DiagnosticsEngine::Warning,
- "simplify construction of %0 with %1",
+ ("simplify construction of %0 with %1%select{ (but beware, the"
+ " given textencoding %3 is not RTL_TEXTENCODING_ASCII_US)|}2"),
expr->getExprLoc())
- << classdecl << describeChangeKind(kind)
+ << classdecl << describeChangeKind(kind) << encIsAscii << enc
<< expr->getSourceRange();
}
return true;