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

2019-07-16 Thread Noel Grandin (via logerrit)
 compilerplugins/clang/salunicodeliteral.cxx   |   22 -
 compilerplugins/clang/sfxpoolitem.cxx |7 
 compilerplugins/clang/sharedvisitor/sharedvisitor.cxx |  267 ++
 compilerplugins/clang/staticaccess.cxx|8 
 compilerplugins/clang/staticanonymous.cxx |   10 
 compilerplugins/clang/stringconcat.cxx|8 
 compilerplugins/clang/typedefparam.cxx|   11 
 compilerplugins/clang/unicodetochar.cxx   |   52 ++-
 compilerplugins/clang/unnecessarycatchthrow.cxx   |8 
 compilerplugins/clang/unoany.cxx  |   17 +
 compilerplugins/clang/unoquery.cxx|   20 +
 compilerplugins/clang/weakbase.cxx|   19 +
 sw/qa/extras/rtfexport/data/page-border.rtf   |4 
 sw/qa/extras/rtfexport/rtfexport4.cxx |   17 +
 14 files changed, 429 insertions(+), 41 deletions(-)

New commits:
commit 8d4fbc532e2058a906b06471501385404ff31541
Author: Noel Grandin 
AuthorDate: Tue Jul 16 08:13:59 2019 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 16 09:15:01 2019 +0200

convert some plugins to LO_CLANG_SHARED_PLUGINS

Change-Id: I7451a95377101004c7c53c918f3234415e06f555
Reviewed-on: https://gerrit.libreoffice.org/75670
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/compilerplugins/clang/salunicodeliteral.cxx 
b/compilerplugins/clang/salunicodeliteral.cxx
index bdf83694b77e..4c2a00669ab0 100644
--- a/compilerplugins/clang/salunicodeliteral.cxx
+++ b/compilerplugins/clang/salunicodeliteral.cxx
@@ -6,6 +6,7 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
+#ifndef LO_CLANG_SHARED_PLUGINS
 
 #include "check.hxx"
 #include "plugin.hxx"
@@ -41,16 +42,18 @@ public:
 return true;
 }
 
-private:
-void run() override {
-if (compiler.getLangOpts().CPlusPlus
+bool preRun() override {
+return compiler.getLangOpts().CPlusPlus
 && compiler.getPreprocessor().getIdentifierInfo(
-"LIBO_INTERNAL_ONLY")->hasMacroDefinition())
-{
+"LIBO_INTERNAL_ONLY")->hasMacroDefinition();
+}
+
+void run() override {
+if (preRun())
 TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
-}
 }
 
+private:
 void check(ExplicitCastExpr const * expr) {
 if (ignoreLocation(expr)
 || isInUnoIncludeFile(expr->getExprLoc()))
@@ -90,9 +93,10 @@ private:
 }
 };
 
-static loplugin::Plugin::Registration reg(
-"salunicodeliteral");
+static loplugin::Plugin::Registration 
salunicodeliteral("salunicodeliteral");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/sfxpoolitem.cxx 
b/compilerplugins/clang/sfxpoolitem.cxx
index bd2870fe06d3..ce52336c8e04 100644
--- a/compilerplugins/clang/sfxpoolitem.cxx
+++ b/compilerplugins/clang/sfxpoolitem.cxx
@@ -6,6 +6,7 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
+#ifndef LO_CLANG_SHARED_PLUGINS
 
 #include 
 #include 
@@ -124,8 +125,10 @@ bool SfxPoolItem::VisitCXXRecordDecl(const CXXRecordDecl* 
decl)
 }
 
 
-loplugin::Plugin::Registration< SfxPoolItem > X("sfxpoolitem");
+loplugin::Plugin::Registration< SfxPoolItem > sfxpoolitem("sfxpoolitem");
 
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx 
b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
index a6df13ca33b4..4532bbe250ca 100644
--- a/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
+++ b/compilerplugins/clang/sharedvisitor/sharedvisitor.cxx
@@ -26,13 +26,24 @@
 #include "../loopvartoosmall.cxx"
 #include "../privatebase.cxx"
 #include "../reservedid.cxx"
+#include "../salunicodeliteral.cxx"
+#include "../sfxpoolitem.cxx"
 #include "../simplifyconstruct.cxx"
+#include "../staticaccess.cxx"
+#include "../staticanonymous.cxx"
+#include "../stringconcat.cxx"
 #include "../stringstatic.cxx"
 #include "../subtlezeroinit.cxx"
+#include "../typedefparam.cxx"
+#include "../unicodetochar.cxx"
+#include "../unnecessarycatchthrow.cxx"
 #include "../unnecessaryoverride.cxx"
 #include "../unnecessaryparen.cxx"
+#include "../unoany.cxx"
+#include "../unoquery.cxx"
 #include "../unreffun.cxx"
 #include "../unusedvariablecheck.cxx"
+#include "../weakbase.cxx"
 #include "../weakobject.cxx"
 #include "../dyncastvisibility.cxx"
 #include "../vclwidgets.cxx"
@@ -64,13 +75,24 @@ public:
 , loopVarTooSmall( nullptr )
 , privateBase( nullptr )
 , reservedId( nullptr )
+, salUnicodeLiteral( nullptr )
+, 

[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang sw/qa sw/source

2015-12-02 Thread Stephan Bergmann
 compilerplugins/clang/stringconcat.cxx  |   72 +++-
 sw/qa/extras/uiwriter/uiwriter.cxx  |2 
 sw/source/filter/html/css1atr.cxx   |   26 +--
 sw/source/filter/html/htmlatr.cxx   |   38 
 sw/source/filter/html/htmlforw.cxx  |   66 ++---
 sw/source/filter/html/htmlftn.cxx   |   14 +++---
 sw/source/filter/html/htmlnumwriter.cxx |6 +-
 sw/source/filter/html/wrthtml.cxx   |   12 ++---
 8 files changed, 135 insertions(+), 101 deletions(-)

New commits:
commit 0e54605e6160826c966d2b40d989e027553f0b70
Author: Stephan Bergmann 
Date:   Wed Dec 2 14:01:29 2015 +0100

loplugin:stringconcat: Also look through O[U]String ctors

Change-Id: I4f07c7c61d324a85f9f5dee0f25a7358facebd41

diff --git a/compilerplugins/clang/stringconcat.cxx 
b/compilerplugins/clang/stringconcat.cxx
index cd33bab..f58e8c4 100644
--- a/compilerplugins/clang/stringconcat.cxx
+++ b/compilerplugins/clang/stringconcat.cxx
@@ -11,6 +11,35 @@
 
 namespace {
 
+Expr const * stripCtor(Expr const * expr) {
+auto e0 = expr;
+auto const e1 = dyn_cast(e0);
+if (e1 != nullptr) {
+e0 = e1->getSubExpr()->IgnoreParenImpCasts();
+}
+auto const e2 = dyn_cast(e0);
+if (e2 == nullptr) {
+return expr;
+}
+auto const e3 = dyn_cast(
+e2->getSubExpr()->IgnoreParenImpCasts());
+if (e3 == nullptr) {
+return expr;
+}
+auto const n = e3->getConstructor()->getQualifiedNameAsString();
+if (n != "rtl::OString::OString" && n != "rtl::OUString::OUString") {
+return expr;
+}
+if (e3->getNumArgs() != 2) {
+return expr;
+}
+return e3->getArg(0)->IgnoreParenImpCasts();
+}
+
+bool isStringLiteral(Expr const * expr) {
+return isa(stripCtor(expr));
+}
+
 class StringConcat:
 public RecursiveASTVisitor, public loplugin::Plugin
 {
@@ -35,13 +64,13 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
 if ((oo != OverloadedOperatorKind::OO_Plus
  && oo != OverloadedOperatorKind::OO_LessLess)
 || fdecl->getNumParams() != 2 || expr->getNumArgs() != 2
-|| !isa(expr->getArg(1)->IgnoreParenImpCasts()))
+|| !isStringLiteral(expr->getArg(1)->IgnoreParenImpCasts()))
 {
 return true;
 }
 SourceLocation leftLoc;
 auto const leftExpr = expr->getArg(0)->IgnoreParenImpCasts();
-if (isa(leftExpr)) {
+if (isStringLiteral(leftExpr)) {
 leftLoc = leftExpr->getLocStart();
 } else {
 CallExpr const * left = dyn_cast(leftExpr);
@@ -56,7 +85,7 @@ bool StringConcat::VisitCallExpr(CallExpr const * expr) {
 if ((loo != OverloadedOperatorKind::OO_Plus
  && loo != OverloadedOperatorKind::OO_LessLess)
 || ldecl->getNumParams() != 2 || left->getNumArgs() != 2
-|| !isa(left->getArg(1)->IgnoreParenImpCasts()))
+|| !isStringLiteral(left->getArg(1)->IgnoreParenImpCasts()))
 {
 return true;
 }
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index a054738..3e40dff 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -632,7 +632,7 @@ void SwUiWriterTest::testExportRTF()
 CPPUNIT_ASSERT(aData.indexOf("bbb") != -1);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), aData.indexOf("ccc"));
 // Ensure there's no extra newline
-CPPUNIT_ASSERT(aData.endsWith(OString("bbb}") + 
OString(SAL_NEWLINE_STRING) + OString("}")));
+CPPUNIT_ASSERT(aData.endsWith("bbb}" SAL_NEWLINE_STRING "}"));
 }
 
 void SwUiWriterTest::testFdo74981()
diff --git a/sw/source/filter/html/css1atr.cxx 
b/sw/source/filter/html/css1atr.cxx
index b5690e8..202020f 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -220,8 +220,8 @@ void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
 {
 m_bFirstCSS1Rule = false;
 OutNewLine();
-sOut.append("<" + OString(OOO_STRING_SVTOOLS_HTML_style) + " " +
-OString(OOO_STRING_SVTOOLS_HTML_O_type) + 
"=\"text/css\">");
+sOut.append("<" OOO_STRING_SVTOOLS_HTML_style " "
+OOO_STRING_SVTOOLS_HTML_O_type "=\"text/css\">");
 //  Optional CSS2 code for dot leaders (dotted line between the Table of 
Contents titles and page numbers):
 //  (More inforation: http://www.w3.org/Style/Examples/007/leaders.en.html)
 //
@@ -254,14 +254,14 @@ void SwHTMLWriter::OutCSS1_Property( const sal_Char 
*pProp,
 
 if (m_bCfgPrintLayout) {
 sOut.append(
-"p." + OString(sCSS2_P_CLASS_leaders) + "{max-width:" + 
OString::number(DOT_LEADERS_MAX_WIDTH) +
+"p." sCSS2_P_CLASS_leaders "{max-width:" + 
OString::number(DOT_LEADERS_MAX_WIDTH) +
 "cm;padding:0;overflow-x:hidden;line-height:120%}"
-"p." +