diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 13:24:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-02-01 07:57:16 +0000 |
commit | dce867e8c4863c969eea3515a988630b74708a43 (patch) | |
tree | 340cb8408241fe34bf1c76f54b9ca41ca95a72ab | |
parent | 27832947f0d9406c1757182ffa57262f3f03af4b (diff) |
loplugin:stringconstant handle calls to constructors with one arg
Change-Id: Ide9148a908bef46ba14640dfa6f556beaf6e3f60
Reviewed-on: https://gerrit.libreoffice.org/33772
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | compilerplugins/clang/stringconstant.cxx | 11 | ||||
-rw-r--r-- | compilerplugins/clang/test/stringconstant.cxx | 3 | ||||
-rw-r--r-- | cppuhelper/source/unourl.cxx | 25 | ||||
-rw-r--r-- | cui/source/tabpages/tpbitmap.cxx | 2 | ||||
-rw-r--r-- | forms/source/component/GroupManager.cxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ViewsWindow.cxx | 2 | ||||
-rw-r--r-- | sc/qa/extras/check_data_pilot_table.cxx | 2 | ||||
-rw-r--r-- | sc/qa/extras/scdatapilottableobj.cxx | 2 | ||||
-rw-r--r-- | sc/qa/extras/scnamedrangeobj.cxx | 2 | ||||
-rw-r--r-- | sc/qa/extras/sctablesheetsobj.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/dlg/navigatr.cxx | 2 | ||||
-rw-r--r-- | sw/qa/core/uwriter.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/basflt/iodetect.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/gloshdl.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 2 |
17 files changed, 41 insertions, 34 deletions
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 3238246125c5..9ae672ae9050 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -66,6 +66,10 @@ bool hasOverloads(FunctionDecl const * decl, unsigned arguments) { if (f != nullptr && f->getMinRequiredArguments() <= arguments && f->getNumParams() >= arguments) { + auto consDecl = dyn_cast<CXXConstructorDecl>(f); + if (consDecl && consDecl->isCopyConstructor()) { + break; + } ++n; if (n == 2) { return true; @@ -1058,12 +1062,17 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { return true; } - std::string file(compiler.getSourceManager().getFilename( + StringRef file(compiler.getSourceManager().getFilename( compiler.getSourceManager().getSpellingLoc(expr->getLocStart()))); if (file == SRCDIR "/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx") { return true; } + // there is some template magic here I don't know how to work around + if (file.startswith(SRCDIR "/connectivity")) + { + return true; + } if (isInUnoIncludeFile(expr->getLocStart())) { return true; } diff --git a/compilerplugins/clang/test/stringconstant.cxx b/compilerplugins/clang/test/stringconstant.cxx index f2cf48c602a7..392567fa3cab 100644 --- a/compilerplugins/clang/test/stringconstant.cxx +++ b/compilerplugins/clang/test/stringconstant.cxx @@ -18,6 +18,7 @@ extern void foo(OUString const &); // expected-error {{extern prototype in main struct Foo { Foo(OUString const &, int) {} + Foo(OUString const &) {} }; int main() { @@ -57,6 +58,8 @@ int main() { foo(OUString("xxx")); // expected-error {{in call of 'foo', replace 'OUString' constructed from a string literal directly with the string literal [loplugin:stringconstant}} Foo aFoo(OUString("xxx"), 1); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} (void)aFoo; + Foo aFoo2(OUString("xxx")); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} + (void)aFoo2; } diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx index b73f17614058..8895119e45bc 100644 --- a/cppuhelper/source/unourl.cxx +++ b/cppuhelper/source/unourl.cxx @@ -79,7 +79,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) case STATE_NAME0: if (bEnd || !isAlphanum(c)) throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains bad descriptor name")); + "UNO URL contains bad descriptor name"); nStart = i; eState = STATE_NAME; break; @@ -93,13 +93,13 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) } else if (!isAlphanum(c)) throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains bad descriptor name")); + "UNO URL contains bad descriptor name"); break; case STATE_KEY0: if (bEnd || !isAlphanum(c)) throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains bad parameter key")); + "UNO URL contains bad parameter key"); nStart = i; eState = STATE_KEY; break; @@ -113,7 +113,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) } else if (bEnd || !isAlphanum(c)) throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains bad parameter key")); + "UNO URL contains bad parameter key"); break; case STATE_VALUE: @@ -127,7 +127,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8))).second) throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains duplicated parameter")); + "UNO URL contains duplicated parameter"); eState = STATE_KEY0; } break; @@ -207,24 +207,20 @@ private: inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) { if (!rUrl.startsWithIgnoreAsciiCase("uno:")) - throw rtl::MalformedUriException( - rtl::OUString("UNO URL does not start with \"uno:\"")); + throw rtl::MalformedUriException("UNO URL does not start with \"uno:\""); sal_Int32 i = RTL_CONSTASCII_LENGTH("uno:"); sal_Int32 j = rUrl.indexOf(';', i); if (j < 0) - throw rtl::MalformedUriException( - rtl::OUString("UNO URL has too few semicolons")); + throw rtl::MalformedUriException("UNO URL has too few semicolons"); rtl::OUString aConnection(rUrl.copy(i, j - i)); i = j + 1; j = rUrl.indexOf(0x3B, i); // ';' if (j < 0) - throw rtl::MalformedUriException( - rtl::OUString("UNO URL has too few semicolons")); + throw rtl::MalformedUriException("UNO URL has too few semicolons"); rtl::OUString aProtocol(rUrl.copy(i, j - i)); i = j + 1; if (i == rUrl.getLength()) - throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains empty ObjectName")); + throw rtl::MalformedUriException("UNO URL contains empty ObjectName"); for (j = i; j < rUrl.getLength(); ++j) { sal_Unicode c = rUrl[j]; @@ -235,8 +231,7 @@ inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) && c != 0x2F && c != 0x3A && c != 0x3D // '/', ':', '=' && c != 0x3F && c != 0x40 && c != 0x5F // '?', '@', '_' && c != 0x7E) // '~' - throw rtl::MalformedUriException( - rtl::OUString("UNO URL contains invalid ObjectName")); + throw rtl::MalformedUriException("UNO URL contains invalid ObjectName"); } return new Impl(aConnection, aProtocol, rUrl.copy(i)); } diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index a703aef8ede2..7b51f59a34e1 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -750,7 +750,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyTileOffsetHdl, Edit&, void) IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, Button*, void) { ResMgr& rMgr = CUI_MGR(); - SvxOpenGraphicDialog aDlg( OUString("Import") ); + SvxOpenGraphicDialog aDlg( "Import" ); aDlg.EnableLink(false); long nCount = m_pBitmapList->Count(); diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index d3281221615d..3444686670cd 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -193,7 +193,7 @@ Sequence< Reference<XControlModel> > OGroup::GetControlModels() const } OGroupManager::OGroupManager(const Reference< XContainer >& _rxContainer) - :m_pCompGroup( new OGroup( OUString("AllComponentGroup") ) ) + :m_pCompGroup( new OGroup( "AllComponentGroup" ) ) ,m_xContainer(_rxContainer) { osl_atomic_increment(&m_refCount); diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index f251a3f9cfb0..c7e4234e2e9f 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -1014,7 +1014,7 @@ void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _ if ( &rView != &_rSection ) { - SdrObject *pNewObj = new SdrUnoObj(OUString("com.sun.star.form.component.FixedText")); + SdrObject *pNewObj = new SdrUnoObj("com.sun.star.form.component.FixedText"); pNewObj->SetLogicRect(_aRect); pNewObj->Move(Size(0, aNewPos.Y())); diff --git a/sc/qa/extras/check_data_pilot_table.cxx b/sc/qa/extras/check_data_pilot_table.cxx index 11c3ee336eff..d69fd5d21abe 100644 --- a/sc/qa/extras/check_data_pilot_table.cxx +++ b/sc/qa/extras/check_data_pilot_table.cxx @@ -73,7 +73,7 @@ private: CheckDataPilotTable::CheckDataPilotTable() : CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XNamed(OUString("DataPilotTable")) + apitest::XNamed("DataPilotTable") { } diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx index 8464e2fa2661..8ce6d6be9028 100644 --- a/sc/qa/extras/scdatapilottableobj.cxx +++ b/sc/qa/extras/scdatapilottableobj.cxx @@ -68,7 +68,7 @@ uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent; ScDataPilotTableObj::ScDataPilotTableObj() : CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XNamed(OUString("DataPilotTable")) + apitest::XNamed("DataPilotTable") { } diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx index c1cbc9306016..efca322b0331 100644 --- a/sc/qa/extras/scnamedrangeobj.cxx +++ b/sc/qa/extras/scnamedrangeobj.cxx @@ -58,7 +58,7 @@ uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent; ScNamedRangeObj::ScNamedRangeObj(): CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XNamed(OUString("NamedRange")), + apitest::XNamed("NamedRange"), apitest::XCellRangeReferrer(table::CellRangeAddress(0,1,7,1,7)) { } diff --git a/sc/qa/extras/sctablesheetsobj.cxx b/sc/qa/extras/sctablesheetsobj.cxx index 51636f2e2568..a67bf2dda1ba 100644 --- a/sc/qa/extras/sctablesheetsobj.cxx +++ b/sc/qa/extras/sctablesheetsobj.cxx @@ -57,7 +57,7 @@ sal_Int32 ScTableSheetsObj::nTest = 0; ScTableSheetsObj::ScTableSheetsObj(): CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XNameContainer(OUString("Sheet2")) + apitest::XNameContainer("Sheet2") { } diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index c12529f830ec..9d67660ba6e9 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -499,7 +499,7 @@ bool SdNavigatorWin::InsertFile(const OUString& rFileName) if (aFileName != maDropFileName) { SfxMedium aMed(aFileName, (StreamMode::READ | StreamMode::SHARE_DENYNONE)); - SfxFilterMatcher aMatch( OUString("simpress") ); + SfxFilterMatcher aMatch( "simpress" ); aMed.UseInteractionHandler( true ); nErr = aMatch.GuessFilter(aMed, pFilter); } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 4a123fc462eb..7de5c5d946c2 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -701,7 +701,7 @@ void SwDocTest::testSwScanner() const sal_Int32 nNextPos = aPaM.GetPoint()->nContent.GetIndex(); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nPos+1), nNextPos); - SwFormatRefMark aRef(OUString("refmark")); + SwFormatRefMark aRef("refmark"); pTA = pTextNode->InsertItem(aRef, nNextPos, nNextPos); CPPUNIT_ASSERT(pTA); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index da819d402a23..eb49924ee181 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -1816,7 +1816,7 @@ void SwUiWriterTest::testTdf78742() //testing with service type and any .ods file OUString path = m_directories.getURLFromSrc(DATA_DIRECTORY) + "calc-data-source.ods"; SfxMedium aMedium(path, StreamMode::READ | StreamMode::SHARE_DENYWRITE); - SfxFilterMatcher aMatcher(OUString("com.sun.star.text.TextDocument")); + SfxFilterMatcher aMatcher("com.sun.star.text.TextDocument"); std::shared_ptr<const SfxFilter> pFilter; sal_uInt32 filter = aMatcher.DetectFilter(aMedium, pFilter); CPPUNIT_ASSERT_EQUAL(ERRCODE_IO_ABORT, filter); @@ -1833,7 +1833,7 @@ void SwUiWriterTest::testTdf78742() //testing with service type and any .odt file OUString path2 = m_directories.getURLFromSrc(DATA_DIRECTORY) + "fdo69893.odt"; SfxMedium aMedium3(path2, StreamMode::READ | StreamMode::SHARE_DENYWRITE); - SfxFilterMatcher aMatcher3(OUString("com.sun.star.text.TextDocument")); + SfxFilterMatcher aMatcher3("com.sun.star.text.TextDocument"); std::shared_ptr<const SfxFilter> pFilter3; sal_uInt32 filter3 = aMatcher3.DetectFilter(aMedium3, pFilter3); CPPUNIT_ASSERT_EQUAL(ERRCODE_CLASS_NONE, filter3); diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx index 6522a92045af..c9cf78c2eac2 100644 --- a/sw/source/filter/basflt/iodetect.cxx +++ b/sw/source/filter/basflt/iodetect.cxx @@ -63,8 +63,8 @@ const OUString SwIoSystem::GetSubStorageName( const SfxFilter& rFltr ) std::shared_ptr<const SfxFilter> SwIoSystem::GetFilterOfFormat(const OUString& rFormatNm, const SfxFilterContainer* pCnt) { - SfxFilterContainer aCntSw( OUString(sSWRITER) ); - SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) ); + SfxFilterContainer aCntSw( sSWRITER ); + SfxFilterContainer aCntSwWeb( sSWRITERWEB ); const SfxFilterContainer* pFltCnt = pCnt ? pCnt : ( IsDocShellRegistered() ? &aCntSw : &aCntSwWeb ); do { @@ -143,8 +143,8 @@ bool SwIoSystem::IsValidStgFilter(SotStorage& rStg, const SfxFilter& rFilter) // Returns the internal FilterName. std::shared_ptr<const SfxFilter> SwIoSystem::GetFileFilter(const OUString& rFileName) { - SfxFilterContainer aCntSw( OUString(sSWRITER) ); - SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) ); + SfxFilterContainer aCntSw( sSWRITER ); + SfxFilterContainer aCntSwWeb( sSWRITERWEB ); const SfxFilterContainer* pFCntnr = IsDocShellRegistered() ? &aCntSw : &aCntSwWeb; SfxFilterMatcher aMatcher( pFCntnr->GetName() ); diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx index eea2fc3dd121..402af7f9dff0 100644 --- a/sw/source/uibase/dochdl/gloshdl.cxx +++ b/sw/source/uibase/dochdl/gloshdl.cxx @@ -706,7 +706,7 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName ) { std::shared_ptr<const SfxFilter> pFilter; std::unique_ptr<SfxMedium> pMed(new SfxMedium( rName, StreamMode::READ, nullptr, nullptr )); - SfxFilterMatcher aMatcher( OUString("swriter") ); + SfxFilterMatcher aMatcher( "swriter" ); pMed->UseInteractionHandler( true ); if (!aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE)) { diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index 9e25f428c9c1..f12fca5f1c9b 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -1475,7 +1475,7 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe std::vector<beans::PropertyValue> aVector; sal_uInt16 nViewID( GetViewFrame()->GetCurViewId()); - OUStringBuffer sBuffer ( OUString( "view" ) ); + OUStringBuffer sBuffer( "view" ); ::sax::Converter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID)); aVector.push_back(comphelper::makePropertyValue("ViewId", sBuffer.makeStringAndClear())); diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 117b99ffd323..9318025ad9f6 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -1488,7 +1488,7 @@ namespace xmloff PropertyValueArray::iterator aDefaultControlPropertyPos = ::std::find_if( m_aValues.begin(), m_aValues.end(), - EqualName( OUString( "DefaultControl" ) ) + EqualName( "DefaultControl" ) ); if ( aDefaultControlPropertyPos != m_aValues.end() ) { |