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

Noel Grandin noel.grandin at collabora.co.uk
Fri Apr 7 07:08:05 UTC 2017


 compilerplugins/clang/redundantcast.cxx |   13 +++++++++++--
 include/tools/vcompat.hxx               |   13 ++++++++-----
 2 files changed, 19 insertions(+), 7 deletions(-)

New commits:
commit 26e7c6d6abf889a7e5bbc0fa4f73034f9cbd07b9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Apr 6 13:42:59 2017 +0200

    loplugin:redundantcast check for c-style char casts
    
    Change-Id: Id6881262e370fd563ec29db95e4af5cfcb04ea34
    Reviewed-on: https://gerrit.libreoffice.org/36247
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 20a04b2176c7..72391256b285 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -330,9 +330,18 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
             << t1 << t2 << expr->getSourceRange();
         return true;
     }
-    bool bBuiltinType = t1->isSpecificBuiltinType(BuiltinType::Bool) || t1->isSpecificBuiltinType(BuiltinType::Double)
+    bool bBuiltinType = t1->isSpecificBuiltinType(BuiltinType::Bool)
+                        || t1->isSpecificBuiltinType(BuiltinType::Void)
                         || t1->isSpecificBuiltinType(BuiltinType::Float)
-                        || t1->isSpecificBuiltinType(BuiltinType::Void);
+                        || t1->isSpecificBuiltinType(BuiltinType::Double)
+                        || t1->isSpecificBuiltinType(BuiltinType::UChar)
+                        || t1->isSpecificBuiltinType(BuiltinType::Char_U)
+                        || t1->isSpecificBuiltinType(BuiltinType::SChar)
+                        || t1->isSpecificBuiltinType(BuiltinType::Char_S)
+                        || t1->isSpecificBuiltinType(BuiltinType::Char16)
+                        || t1->isSpecificBuiltinType(BuiltinType::Char32)
+                        || t1->isSpecificBuiltinType(BuiltinType::WChar_U)
+                        || t1->isSpecificBuiltinType(BuiltinType::WChar_S);
     if ((bBuiltinType || loplugin::TypeCheck(t1).Typedef()) && t1 == t2)
     {
         // Ignore FD_ISSET expanding to "...(SOCKET)(fd)..." in some Microsoft
diff --git a/include/tools/vcompat.hxx b/include/tools/vcompat.hxx
index 71b64beef916..0adf6913ea86 100644
--- a/include/tools/vcompat.hxx
+++ b/include/tools/vcompat.hxx
@@ -21,11 +21,14 @@
 
 #include <tools/toolsdllapi.h>
 
-#define COMPAT_FORMAT( char1, char2, char3, char4 ) \
-    ((sal_uInt32)((((sal_uInt32)(char)(char1)))|                \
-    (((sal_uInt32)(char)(char2))<<8UL)|                 \
-    (((sal_uInt32)(char)(char3))<<16UL)|                    \
-    ((sal_uInt32)(char)(char4))<<24UL))
+inline sal_uInt32 COMPAT_FORMAT( char char1, char char2, char char3, char char4 )
+{
+    return
+        ((sal_uInt32)char1) |
+        (((sal_uInt32)char2) <<  8) |
+        (((sal_uInt32)char3) << 16) |
+        (((sal_uInt32)char4) << 24);
+};
 
 class SvStream;
 enum class StreamMode;


More information about the Libreoffice-commits mailing list