[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang include/svx svx/source

Stephan Bergmann sbergman at redhat.com
Fri Sep 12 05:47:23 PDT 2014


 compilerplugins/clang/salbool.cxx   |   47 ++++++++++++++++++++++++++++++++++++
 include/svx/pagectrl.hxx            |    4 +--
 svx/source/dialog/pagectrl.cxx      |    6 ++--
 svx/source/form/formcontrolling.cxx |    2 -
 svx/source/form/tbxform.cxx         |    6 ++--
 svx/source/inc/tbxform.hxx          |    2 -
 6 files changed, 57 insertions(+), 10 deletions(-)

New commits:
commit 03d92f1ca38aa3873158ddec86ad8beebaf928bb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 12 14:46:39 2014 +0200

    svx: sal_Bool -> bool
    
    Change-Id: I5b9b730d7060ec146ed0f54c7fe7eb0ca09f7d9c

diff --git a/include/svx/pagectrl.hxx b/include/svx/pagectrl.hxx
index eb83db6..ee1ffbb 100644
--- a/include/svx/pagectrl.hxx
+++ b/include/svx/pagectrl.hxx
@@ -41,8 +41,8 @@ private:
     long        nRight;
 
     SvxBoxItem*     pBorder;
-    sal_Bool        bResetBackground;
-    sal_Bool        bFrameDirection;
+    bool        bResetBackground;
+    bool        bFrameDirection;
     sal_Int32       nFrameDirection;
 
     long        nHdLeft;
diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx
index 3a1145d..dafd739 100644
--- a/svx/source/dialog/pagectrl.cxx
+++ b/svx/source/dialog/pagectrl.cxx
@@ -46,8 +46,8 @@ SvxPageWindow::SvxPageWindow(Window* pParent)
 
     //UUUU
     pBorder(0),
-    bResetBackground(sal_False),
-    bFrameDirection(sal_False),
+    bResetBackground(false),
+    bFrameDirection(false),
     nFrameDirection(0),
 
     nHdLeft(0),
@@ -169,7 +169,7 @@ void SvxPageWindow::DrawPage(const Point& rOrg, const bool bSecond, const bool b
         DrawRect(Rectangle(Point(0,0),winSize));
 
         if(bResetBackground)
-            bResetBackground = sal_False;
+            bResetBackground = false;
     }
     SetLineColor(rFieldTextColor);
     // Shadow
diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx
index dfa6e91..893c7f6 100644
--- a/svx/source/form/formcontrolling.cxx
+++ b/svx/source/form/formcontrolling.cxx
@@ -341,7 +341,7 @@ namespace svx
 
             case COMMIT_RECORD:
             {
-                sal_Bool bDummy( sal_False );
+                sal_Bool bDummy( false );
                 bSuccess = m_xFormOperations->commitCurrentRecord( bDummy );
             }
             break;
diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx
index f519dd4..6e202f7 100644
--- a/svx/source/form/tbxform.cxx
+++ b/svx/source/form/tbxform.cxx
@@ -64,7 +64,7 @@ SvxFmAbsRecWin::~SvxFmAbsRecWin()
 }
 
 
-void SvxFmAbsRecWin::FirePosition( sal_Bool _bForce )
+void SvxFmAbsRecWin::FirePosition( bool _bForce )
 {
     if ( _bForce || IsValueChangedFromSaved() )
     {
@@ -92,14 +92,14 @@ void SvxFmAbsRecWin::FirePosition( sal_Bool _bForce )
 
 void SvxFmAbsRecWin::LoseFocus()
 {
-    FirePosition( sal_False );
+    FirePosition( false );
 }
 
 
 void SvxFmAbsRecWin::KeyInput( const KeyEvent& rKeyEvent )
 {
     if( rKeyEvent.GetKeyCode() == KEY_RETURN && !GetText().isEmpty() )
-        FirePosition( sal_True );
+        FirePosition( true );
     else
         NumericField::KeyInput( rKeyEvent );
 }
diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx
index 8640b7d..adb279f 100644
--- a/svx/source/inc/tbxform.hxx
+++ b/svx/source/inc/tbxform.hxx
@@ -38,7 +38,7 @@ public:
     virtual void LoseFocus() SAL_OVERRIDE;
 
 protected:
-    virtual void FirePosition( sal_Bool _bForce );
+    virtual void FirePosition( bool _bForce );
 };
 
 
commit e333adb1ff0ffc36a78e50dc4061c1dfb0593d71
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 12 14:46:23 2014 +0200

    loplugin:salbool: exclude sal_Bool vars passed to non-const ref
    
    Change-Id: I45b323b326cc56cfc48e0abaa52d51fd86adbf79

diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index 5eddba6..6cca0fa 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -119,6 +119,8 @@ public:
 
     bool VisitUnaryAddrOf(UnaryOperator const * op);
 
+    bool VisitCallExpr(CallExpr * expr);
+
     bool VisitCStyleCastExpr(CStyleCastExpr * expr);
 
     bool VisitCXXStaticCastExpr(CXXStaticCastExpr * expr);
@@ -210,6 +212,51 @@ bool SalBool::VisitUnaryAddrOf(UnaryOperator const * op) {
     return true;
 }
 
+bool SalBool::VisitCallExpr(CallExpr * expr) {
+    Decl const * d = expr->getCalleeDecl();
+    FunctionProtoType const * ft = nullptr;
+    if (d != nullptr) {
+        FunctionDecl const * fd = dyn_cast<FunctionDecl>(d);
+        if (fd != nullptr) {
+            PointerType const * pt = fd->getType()->getAs<PointerType>();
+            QualType t2(pt == nullptr ? fd->getType() : pt->getPointeeType());
+            ft = t2->getAs<FunctionProtoType>();
+            assert(
+                ft != nullptr || !compiler.getLangOpts().CPlusPlus
+                || (fd->getBuiltinID() != Builtin::NotBuiltin
+                    && isa<FunctionNoProtoType>(t2)));
+                // __builtin_*s have no proto type?
+        } else {
+            VarDecl const * vd = dyn_cast<VarDecl>(d);
+            if (vd != nullptr) {
+                PointerType const * pt = vd->getType()->getAs<PointerType>();
+                ft = (pt == nullptr ? vd->getType() : pt->getPointeeType())
+                    ->getAs<FunctionProtoType>();
+            }
+        }
+    }
+    if (ft != nullptr) {
+        for (unsigned i = 0; i != compat::getNumParams(*ft); ++i) {
+            QualType t(compat::getParamType(*ft, i));
+            if (t->isLValueReferenceType()) {
+                t = t.getNonReferenceType();
+                if (!t.isConstQualified() && isSalBool(t)
+                    && i < expr->getNumArgs())
+                {
+                    DeclRefExpr * ref = dyn_cast<DeclRefExpr>(expr->getArg(i));
+                    if (ref != nullptr) {
+                        VarDecl const * d = dyn_cast<VarDecl>(ref->getDecl());
+                        if (d != nullptr) {
+                            varDecls_.erase(d);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    return true;
+}
+
 bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
     if (ignoreLocation(expr)) {
         return true;


More information about the Libreoffice-commits mailing list