[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Mon Jan 15 08:12:04 UTC 2018


 compilerplugins/clang/cstylecast.cxx |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit a409d32e7f6fc09e041079d6dbc3c927497adfed
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 15 09:10:25 2018 +0100

    More loplugin:cstylecast
    
    ...also warn about the remaining cases of C-style casts (other than idiomatic
    cast to void)
    
    Change-Id: I274be61ad038fc41ac470fc07ea703a0f071f456

diff --git a/compilerplugins/clang/cstylecast.cxx b/compilerplugins/clang/cstylecast.cxx
index f09ce81a2987..ba89c1aa02b5 100644
--- a/compilerplugins/clang/cstylecast.cxx
+++ b/compilerplugins/clang/cstylecast.cxx
@@ -232,16 +232,15 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
     if( expr->getCastKind() == CK_ToVoid ) {
         return true;
     }
-    // ignore integral-type conversions for now, there is insufficient agreement about
-    // the merits of C++ style casting in this case
-    if( expr->getCastKind() == CK_IntegralCast ) {
-        return true;
-    }
     if (isSharedCAndCppCode(expr->getLocStart())) {
         return true;
     }
     char const * perf = nullptr;
-    if( expr->getCastKind() == CK_NoOp ) {
+    if( expr->getCastKind() == CK_IntegralCast ) {
+        if (rewriteArithmeticCast(expr, &perf)) {
+            return true;
+        }
+    } else if( expr->getCastKind() == CK_NoOp ) {
         if (!((expr->getSubExpr()->getType()->isPointerType()
                && expr->getType()->isPointerType())
               || expr->getTypeAsWritten()->isReferenceType()))
@@ -530,6 +529,9 @@ bool CStyleCast::rewriteArithmeticCast(CStyleCastExpr const * expr, char const *
             while (compiler.getSourceManager().isMacroBodyExpansion(third)
                    && compiler.getSourceManager().isAtStartOfImmediateMacroExpansion(third, &third))
             {}
+        } else if (compiler.getSourceManager().isMacroBodyExpansion(fourth)) {
+            while (compiler.getSourceManager().isMacroArgExpansion(third)
+                   && compiler.getSourceManager().isAtStartOfImmediateMacroExpansion(third, &third)) {}
         }
         if (!third.isMacroID()) {
             while (compiler.getSourceManager().isMacroBodyExpansion(fourth)


More information about the Libreoffice-commits mailing list