avmedia/source/opengl/oglplayer.cxx | 2 compilerplugins/clang/salbool.cxx | 546 +++++++++++++++++++++++++ compilerplugins/clang/store/salbool.cxx | 535 ------------------------ connectivity/source/drivers/kab/KResultSet.cxx | 2 svtools/source/uno/unogridcolumnfacade.cxx | 8 svx/source/dialog/pagectrl.cxx | 4 sw/qa/extras/rtfimport/rtfimport.cxx | 4 7 files changed, 556 insertions(+), 545 deletions(-)
New commits: commit 9263b101c39172cbcf04189c515bca80cb15f3aa Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Jul 1 17:38:02 2014 +0200 Activate the "suspicious cast to sal_Bool" parts of loplugin:salbool Change-Id: I78a368ef2899b2462251b45a327fc7b1f31fe764 diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx index 30c2641..3f33a6c 100644 --- a/avmedia/source/opengl/oglplayer.cxx +++ b/avmedia/source/opengl/oglplayer.cxx @@ -205,7 +205,7 @@ sal_Bool SAL_CALL OGLPlayer::isPlaybackLoop() throw ( uno::RuntimeException, std { osl::MutexGuard aGuard(m_aMutex); assert(m_pHandle); - return (sal_Bool)gltf_animation_get_looping(m_pHandle); + return gltf_animation_get_looping(m_pHandle) != 0; } void SAL_CALL OGLPlayer::setVolumeDB( sal_Int16 /*nVolumDB*/ ) throw ( uno::RuntimeException, std::exception ) diff --git a/compilerplugins/clang/store/salbool.cxx b/compilerplugins/clang/salbool.cxx similarity index 93% rename from compilerplugins/clang/store/salbool.cxx rename to compilerplugins/clang/salbool.cxx index abef250..a3476be 100644 --- a/compilerplugins/clang/store/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -9,6 +9,7 @@ #include <algorithm> #include <cassert> +#include <cstdlib> #include <set> #include <string> @@ -106,7 +107,10 @@ class SalBool: public RecursiveASTVisitor<SalBool>, public loplugin::RewritePlugin { public: - explicit SalBool(InstantiationData const & data): RewritePlugin(data) {} + explicit SalBool(InstantiationData const & data): + RewritePlugin(data), + fullMode_(std::getenv("loplugin:salbool") != nullptr) + {} virtual void run() override; @@ -139,6 +143,7 @@ private: bool rewrite(SourceLocation location); + bool fullMode_; std::set<VarDecl const *> varDecls_; }; @@ -178,7 +183,7 @@ void SalBool::run() { } } } - if (!rewrite(loc)) { + if (fullMode_ && !rewrite(loc)) { report( DiagnosticsEngine::Warning, "VarDecl, use \"bool\" instead of \"sal_Bool\"", loc) @@ -322,13 +327,15 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) { // with a "mismatch" error before the rewriter had a chance // to act upon the definition (but use the heuristic of // assuming pure virtual functions do not have definitions): - if (!((isInMainFile( - compiler.getSourceManager().getSpellingLoc( - dyn_cast<FunctionDecl>( - decl->getDeclContext()) - ->getNameInfo().getLoc())) - || f->isDefined() || f->isPure()) - && rewrite(loc))) + if (fullMode_ + && !((compat::isInMainFile( + compiler.getSourceManager(), + compiler.getSourceManager().getSpellingLoc( + dyn_cast<FunctionDecl>( + decl->getDeclContext()) + ->getNameInfo().getLoc())) + || f->isDefined() || f->isPure()) + && rewrite(loc))) { report( DiagnosticsEngine::Warning, @@ -409,7 +416,7 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) { } } } - if (!rewrite(loc)) { + if (fullMode_ && !rewrite(loc)) { report( DiagnosticsEngine::Warning, "FieldDecl, use \"bool\" instead of \"sal_Bool\"", loc) @@ -467,11 +474,13 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) { // rewriter had a chance to act upon the definition (but use the // heuristic of assuming pure virtual functions do not have // definitions): - if (!((isInMainFile( - compiler.getSourceManager().getSpellingLoc( - decl->getNameInfo().getLoc())) - || f->isDefined() || f->isPure()) - && rewrite(loc))) + if (fullMode_ + && !((compat::isInMainFile( + compiler.getSourceManager(), + compiler.getSourceManager().getSpellingLoc( + decl->getNameInfo().getLoc())) + || f->isDefined() || f->isPure()) + && rewrite(loc))) { report( DiagnosticsEngine::Warning, @@ -487,7 +496,9 @@ bool SalBool::VisitValueDecl(ValueDecl const * decl) { if (ignoreLocation(decl)) { return true; } - if (isSalBool(decl->getType()) && !rewrite(decl->getLocStart())) { + if (fullMode_ && isSalBool(decl->getType()) + && !rewrite(decl->getLocStart())) + { report( DiagnosticsEngine::Warning, "ValueDecl, use \"bool\" instead of \"sal_Bool\"", @@ -498,7 +509,7 @@ bool SalBool::VisitValueDecl(ValueDecl const * decl) { } bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const { - return compat::isInMainFile(spellingLocation) + return compat::isInMainFile(compiler.getSourceManager(), spellingLocation) && (compiler.getSourceManager().getFilename(spellingLocation) == SRCDIR "/cppu/qa/test_any.cxx"); } diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx index 08ca702..2e8cb8d 100644 --- a/connectivity/source/drivers/kab/KResultSet.cxx +++ b/connectivity/source/drivers/kab/KResultSet.cxx @@ -968,7 +968,7 @@ void KabResultSet::getFastPropertyValue( switch (nHandle) { case PROPERTY_ID_ISBOOKMARKABLE: - _rValue <<= (sal_Bool)sal_False; + _rValue <<= false; break; case PROPERTY_ID_CURSORNAME: case PROPERTY_ID_RESULTSETCONCURRENCY: diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx index 3acf350..6b98792 100644 --- a/svtools/source/uno/unogridcolumnfacade.cxx +++ b/svtools/source/uno/unogridcolumnfacade.cxx @@ -56,9 +56,9 @@ namespace svt { namespace table namespace { - template< class ATTRIBUTE_TYPE > - void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( ATTRIBUTE_TYPE ), - ATTRIBUTE_TYPE i_value ) + template< class T1, class T2 > + void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( T1 ), + T2 i_value ) { try { @@ -334,7 +334,7 @@ namespace svt { namespace table void UnoGridColumnFacade::setResizable( bool i_resizable ) { ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" ); - lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( i_resizable ) ); + lcl_set( m_xGridColumn, &XGridColumn::setResizeable, i_resizable ); } diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx index b376f5a..0094aed 100644 --- a/svx/source/dialog/pagectrl.cxx +++ b/svx/source/dialog/pagectrl.cxx @@ -152,9 +152,9 @@ void SvxPageWindow::Paint(const Rectangle&) else { // Left and right page are different -> draw two pages if possible - DrawPage(Point(0,nYPos),false,(sal_Bool)(eUsage & SVX_PAGE_LEFT)); + DrawPage(Point(0,nYPos),false,(eUsage & SVX_PAGE_LEFT) != 0); DrawPage(Point(aSize.Width() + aSize.Width() / 8,nYPos),true, - (sal_Bool)(eUsage & SVX_PAGE_RIGHT)); + (eUsage & SVX_PAGE_RIGHT) != 0); } } diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index d834fb8..05d618b 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -243,8 +243,8 @@ DECLARE_RTFIMPORT_TEST(testN750757, "n750757.rtf") uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin")); - CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin")); + CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"))); + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xParaEnum->nextElement(), "ParaContextMargin"))); } DECLARE_RTFIMPORT_TEST(testFdo45563, "fdo45563.rtf") _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits