loplugin:stringconstant: adapt to improved OUStringLiteral1
Change-Id: I5c9bfbb97f0eabe1ea691faf522d22070243d234
This commit is contained in:
@@ -659,20 +659,15 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
|
|||||||
PassThrough pass;
|
PassThrough pass;
|
||||||
switch (expr->getConstructor()->getNumParams()) {
|
switch (expr->getConstructor()->getNumParams()) {
|
||||||
case 1:
|
case 1:
|
||||||
|
if (!loplugin::TypeCheck(
|
||||||
|
expr->getConstructor()->getParamDecl(0)->getType())
|
||||||
|
.Typedef("sal_Unicode").GlobalNamespace())
|
||||||
{
|
{
|
||||||
APSInt v;
|
|
||||||
if (!expr->getArg(0)->isIntegerConstantExpr(
|
|
||||||
v, compiler.getASTContext()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (v.ugt(0xFFFF)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
kind = ChangeKind::SingleChar;
|
kind = ChangeKind::SingleChar;
|
||||||
pass = PassThrough::NonEmptyConstantString;
|
pass = PassThrough::NonEmptyConstantString;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
auto arg = expr->getArg(0);
|
auto arg = expr->getArg(0);
|
||||||
@@ -1436,24 +1431,21 @@ void StringConstant::handleOUStringCtor(
|
|||||||
<< callee->getQualifiedNameAsString() << expr->getSourceRange();
|
<< callee->getQualifiedNameAsString() << expr->getSourceRange();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
APSInt res;
|
|
||||||
if (e3->getNumArgs() == 1
|
if (e3->getNumArgs() == 1
|
||||||
&& e3->getArg(0)->IgnoreParenImpCasts()->isIntegerConstantExpr(
|
&& e3->getConstructor()->getNumParams() == 1
|
||||||
res, compiler.getASTContext()))
|
&& (loplugin::TypeCheck(
|
||||||
|
e3->getConstructor()->getParamDecl(0)->getType())
|
||||||
|
.Typedef("sal_Unicode").GlobalNamespace()))
|
||||||
{
|
{
|
||||||
// It may not be easy to rewrite OUString(c), esp. given there is no
|
// It may not be easy to rewrite OUString(c), esp. given there is no
|
||||||
// OUString ctor taking an OUStringLiteral1 arg, so don't warn there:
|
// OUString ctor taking an OUStringLiteral1 arg, so don't warn there:
|
||||||
if (!explicitFunctionalCastNotation) {
|
if (!explicitFunctionalCastNotation) {
|
||||||
uint64_t n = res.getZExtValue();
|
|
||||||
if (n <= 0xFFFF) {
|
|
||||||
report(
|
report(
|
||||||
DiagnosticsEngine::Warning,
|
DiagnosticsEngine::Warning,
|
||||||
("in call of %0, replace OUString constructed from a"
|
("in call of %0, replace OUString constructed from a"
|
||||||
" sal_Unicode constant with an OUStringLiteral1"),
|
" sal_Unicode with an OUStringLiteral1"),
|
||||||
e3->getExprLoc())
|
e3->getExprLoc())
|
||||||
<< callee->getQualifiedNameAsString()
|
<< callee->getQualifiedNameAsString() << expr->getSourceRange();
|
||||||
<< expr->getSourceRange();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user