summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-08-30 15:30:36 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-08-30 15:30:36 +0200
commitc5d8cb41a5bb26927b183defdc36daef523c9ce6 (patch)
tree4649e0cc77b278be462d437183a3bda50300a8d3 /compilerplugins
parent6427b84b39d2f31f93615f9499c4a3d683e46a4d (diff)
loplugin:stringconstant: adapt to improved OUStringLiteral1
Change-Id: I5c9bfbb97f0eabe1ea691faf522d22070243d234
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/stringconstant.cxx42
1 files changed, 17 insertions, 25 deletions
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index d49920798508..9b9c934f589c 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -659,20 +659,15 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
PassThrough pass;
switch (expr->getConstructor()->getNumParams()) {
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;
- }
- kind = ChangeKind::SingleChar;
- pass = PassThrough::NonEmptyConstantString;
- break;
+ return true;
}
+ kind = ChangeKind::SingleChar;
+ pass = PassThrough::NonEmptyConstantString;
+ break;
case 2:
{
auto arg = expr->getArg(0);
@@ -1436,24 +1431,21 @@ void StringConstant::handleOUStringCtor(
<< callee->getQualifiedNameAsString() << expr->getSourceRange();
return;
}
- APSInt res;
if (e3->getNumArgs() == 1
- && e3->getArg(0)->IgnoreParenImpCasts()->isIntegerConstantExpr(
- res, compiler.getASTContext()))
+ && e3->getConstructor()->getNumParams() == 1
+ && (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
// OUString ctor taking an OUStringLiteral1 arg, so don't warn there:
if (!explicitFunctionalCastNotation) {
- uint64_t n = res.getZExtValue();
- if (n <= 0xFFFF) {
- report(
- DiagnosticsEngine::Warning,
- ("in call of %0, replace OUString constructed from a"
- " sal_Unicode constant with an OUStringLiteral1"),
- e3->getExprLoc())
- << callee->getQualifiedNameAsString()
- << expr->getSourceRange();
- }
+ report(
+ DiagnosticsEngine::Warning,
+ ("in call of %0, replace OUString constructed from a"
+ " sal_Unicode with an OUStringLiteral1"),
+ e3->getExprLoc())
+ << callee->getQualifiedNameAsString() << expr->getSourceRange();
}
return;
}