compilerplugins/clang/nullptr.cxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
New commits: commit b8711a13834d4b141bb41de915702131dcc494e7 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Oct 7 09:23:51 2016 +0200 loplugin:nullptr: remove duplicate warnings Change-Id: I859d9ac8f7e4134bdac59b39e95eb563d1291e8b diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx index 0ebbcde..3ab3203 100644 --- a/compilerplugins/clang/nullptr.cxx +++ b/compilerplugins/clang/nullptr.cxx @@ -39,6 +39,16 @@ bool isAnyKindOfPointerType(QualType type) { || type->isMemberPointerType(); } +bool isNullPointerCast(CastExpr const * expr) { + switch (expr->getCastKind()) { + case CK_NullToPointer: + case CK_NullToMemberPointer: + return true; + default: + return false; + } +} + class Nullptr: public RecursiveASTVisitor<Nullptr>, public loplugin::RewritePlugin { @@ -92,11 +102,7 @@ bool Nullptr::VisitImplicitCastExpr(CastExpr const * expr) { if (ignoreLocation(expr)) { return true; } - switch (expr->getCastKind()) { - case CK_NullToPointer: - case CK_NullToMemberPointer: - break; - default: + if (!isNullPointerCast(expr)) { return true; } Expr::NullPointerConstantKind k = expr->isNullPointerConstant( @@ -268,6 +274,13 @@ void Nullptr::visitCXXCtorInitializer(CXXCtorInitializer const * init) { void Nullptr::handleZero(Expr const * expr) { //TODO: detect NPCK_ZeroExpression where appropriate + // Filter out ImplicitCastExpr that will be handled by + // VisitImplicitCastExpr: + if (auto ice = dyn_cast<ImplicitCastExpr>(expr)) { + if (isNullPointerCast(ice)) { + return; + } + } auto const lit = dyn_cast<IntegerLiteral>(expr->IgnoreParenImpCasts()); if (lit != nullptr && !lit->getValue().getBoolValue()) { handleNull(expr, nullptr, Expr::NPCK_ZeroLiteral); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits