loplugin:buffereadd find stuff involving adding *StringBuffer
and create conversion methods on *StringBuffer to make this work Change-Id: I3cf5ee3e139826168894b46eff8ee4bcde00cb7e Reviewed-on: https://gerrit.libreoffice.org/80949 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -378,9 +378,7 @@ void MethodDescriptor::addTypeParameter(OUString const & name) {
|
||||
}
|
||||
|
||||
OString MethodDescriptor::getDescriptor() const {
|
||||
OStringBuffer buf(m_descriptorStart);
|
||||
buf.append(m_descriptorEnd);
|
||||
return buf.makeStringAndClear();
|
||||
return rtl::OStringView(m_descriptorStart) + m_descriptorEnd;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -175,19 +175,6 @@ void BufferAdd::findBufferAssignOrAdd(const Stmt* parentStmt, Stmt const* stmt)
|
||||
auto cxxConstructExpr = dyn_cast<CXXConstructExpr>(ignore(varDeclLHS->getInit()));
|
||||
if (cxxConstructExpr)
|
||||
{
|
||||
if (cxxConstructExpr->getNumArgs() == 0)
|
||||
{
|
||||
addToGoodMap(varDeclLHS, parentStmt);
|
||||
return;
|
||||
}
|
||||
auto tc2 = loplugin::TypeCheck(cxxConstructExpr->getArg(0)->getType());
|
||||
if (tc2.LvalueReference().Class("OUStringBuffer")
|
||||
|| tc2.LvalueReference().Class("OStringBuffer")
|
||||
|| tc2.Class("OUStringBuffer") || tc2.Class("OStringBuffer"))
|
||||
{
|
||||
badMap.insert(varDeclLHS);
|
||||
return;
|
||||
}
|
||||
addToGoodMap(varDeclLHS, parentStmt);
|
||||
return;
|
||||
}
|
||||
@@ -286,10 +273,6 @@ bool BufferAdd::isMethodOkToMerge(CXXMemberCallExpr const* memberCall)
|
||||
auto methodDecl = memberCall->getMethodDecl();
|
||||
if (methodDecl->getNumParams() == 0)
|
||||
return true;
|
||||
auto tc2 = loplugin::TypeCheck(methodDecl->getParamDecl(0)->getType());
|
||||
if (tc2.LvalueReference().Class("OUStringBuffer")
|
||||
|| tc2.LvalueReference().Class("OStringBuffer"))
|
||||
return false;
|
||||
|
||||
auto name = methodDecl->getName();
|
||||
if (name == "appendUninitialized" || name == "setLength" || name == "remove" || name == "insert"
|
||||
@@ -338,9 +321,7 @@ bool BufferAdd::isSideEffectFree(Expr const* expr)
|
||||
if (auto calleeMethodDecl = dyn_cast_or_null<CXXMethodDecl>(callExpr->getCalleeDecl()))
|
||||
if (calleeMethodDecl && calleeMethodDecl->getIdentifier())
|
||||
{
|
||||
auto name = calleeMethodDecl->getName();
|
||||
if (callExpr->getNumArgs() > 0
|
||||
&& (name == "number" || name == "unacquired" || name == "boolean"))
|
||||
if (callExpr->getNumArgs() > 0)
|
||||
{
|
||||
auto tc = loplugin::TypeCheck(calleeMethodDecl->getParent());
|
||||
if (tc.Class("OUString") || tc.Class("OString"))
|
||||
|
@@ -46,6 +46,24 @@ void f4(sal_Unicode const* pPathBegin)
|
||||
v.append(pPathBegin, 12);
|
||||
v.append("aaaa");
|
||||
}
|
||||
void f5(OUStringBuffer& input)
|
||||
{
|
||||
// expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
|
||||
OUStringBuffer v(input);
|
||||
v.append("aaaa");
|
||||
}
|
||||
struct Footer
|
||||
{
|
||||
OStringBuffer m_descriptorStart;
|
||||
OString m_descriptorEnd;
|
||||
OString f8() const
|
||||
{
|
||||
// expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
|
||||
OStringBuffer buf(m_descriptorStart);
|
||||
buf.append(m_descriptorEnd);
|
||||
return buf.makeStringAndClear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace test2
|
||||
|
@@ -1566,22 +1566,18 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
|
||||
SAL_INFO("connectivity.firebird", "getPrimaryKeys() with "
|
||||
"Table: " << sTable);
|
||||
|
||||
OUStringBuffer aQueryBuf("SELECT "
|
||||
OUString sAppend = "WHERE constr.RDB$RELATION_NAME = '%' ";
|
||||
OUString sQuery = "SELECT "
|
||||
"constr.RDB$RELATION_NAME, " // 1. Table Name
|
||||
"inds.RDB$FIELD_NAME, " // 2. Column Name
|
||||
"inds.RDB$FIELD_POSITION, " // 3. Sequence Number
|
||||
"constr.RDB$CONSTRAINT_NAME " // 4 Constraint name
|
||||
"FROM RDB$RELATION_CONSTRAINTS constr "
|
||||
"JOIN RDB$INDEX_SEGMENTS inds "
|
||||
"on (constr.RDB$INDEX_NAME = inds.RDB$INDEX_NAME) ");
|
||||
|
||||
OUString sAppend = "WHERE constr.RDB$RELATION_NAME = '%' ";
|
||||
aQueryBuf.append(sAppend.replaceAll("%", sTable));
|
||||
|
||||
aQueryBuf.append("AND constr.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
|
||||
"ORDER BY inds.RDB$FIELD_NAME");
|
||||
|
||||
OUString sQuery = aQueryBuf.makeStringAndClear();
|
||||
"on (constr.RDB$INDEX_NAME = inds.RDB$INDEX_NAME) " +
|
||||
sAppend.replaceAll("%", sTable) +
|
||||
"AND constr.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY' "
|
||||
"ORDER BY inds.RDB$FIELD_NAME";
|
||||
|
||||
uno::Reference< XStatement > xStatement = m_pConnection->createStatement();
|
||||
uno::Reference< XResultSet > xRs = xStatement->executeQuery(sQuery);
|
||||
|
@@ -139,8 +139,7 @@ namespace dbaccess
|
||||
o_rValue.clear();
|
||||
|
||||
// the characters building up th evalue
|
||||
OUStringBuffer aCharacters( getAccumulatedCharacters() );
|
||||
const OUString sValue = aCharacters.makeStringAndClear();
|
||||
const OUString sValue = getAccumulatedCharacters().toString();
|
||||
|
||||
const OUString& rItemType( getItemType() );
|
||||
ENSURE_OR_RETURN_VOID( !rItemType.isEmpty(), "no item type -> no item value" );
|
||||
|
@@ -1035,6 +1035,13 @@ public:
|
||||
*pInternalCapacity = &nCapacity;
|
||||
}
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
operator OStringView() const
|
||||
{
|
||||
return OStringView(getStr(), getLength());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
A pointer to the data structure which contains the data.
|
||||
|
@@ -1634,6 +1634,13 @@ public:
|
||||
return OUStringBuffer( pNew, count + 16 );
|
||||
}
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
operator OUStringView() const
|
||||
{
|
||||
return OUStringView(getStr(), getLength());
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
OUStringBuffer( rtl_uString * value, const sal_Int32 capacity )
|
||||
{
|
||||
|
@@ -1171,11 +1171,10 @@ void ScDocument::CompareDocument( ScDocument& rOtherDoc )
|
||||
GetName( nThisTab, aTabName );
|
||||
OUString aTemplate = ScResId(STR_PROGRESS_COMPARING);
|
||||
sal_Int32 nIndex = 0;
|
||||
OUStringBuffer aProText = aTemplate.getToken( 0, '#', nIndex );
|
||||
aProText.append(aTabName);
|
||||
aProText.append(aTemplate.getToken( 0, '#', nIndex ));
|
||||
ScProgress aProgress( GetDocumentShell(),
|
||||
aProText.makeStringAndClear(), 3*nThisEndRow, true ); // 2x FindOrder, 1x here
|
||||
OUString aProText = aTemplate.getToken( 0, '#', nIndex ) +
|
||||
aTabName +
|
||||
aTemplate.getToken( 0, '#', nIndex );
|
||||
ScProgress aProgress( GetDocumentShell(), aProText, 3*nThisEndRow, true ); // 2x FindOrder, 1x here
|
||||
long nProgressStart = 2*nThisEndRow; // start for here
|
||||
|
||||
std::unique_ptr<SCCOLROW[]> pTempRows(new SCCOLROW[nThisEndRow+1]);
|
||||
|
@@ -989,8 +989,8 @@ bool RequiresFixedFormula(ScConditionMode eMode)
|
||||
OString GetFixedFormula(ScConditionMode eMode, const ScAddress& rAddress, const OString& rText)
|
||||
{
|
||||
OStringBuffer aBuffer;
|
||||
OStringBuffer aPosBuffer = XclXmlUtils::ToOString(aBuffer, rAddress);
|
||||
OString aPos = aPosBuffer.makeStringAndClear();
|
||||
XclXmlUtils::ToOString(aBuffer, rAddress);
|
||||
OString aPos = aBuffer.makeStringAndClear();
|
||||
switch (eMode)
|
||||
{
|
||||
case ScConditionMode::Error:
|
||||
|
@@ -284,11 +284,11 @@ void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
|
||||
|
||||
void SfxLokHelper::notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext)
|
||||
{
|
||||
OStringBuffer aBuffer;
|
||||
aBuffer.append(OUStringToOString(aApplication.replace(' ', '_'), RTL_TEXTENCODING_UTF8));
|
||||
aBuffer.append(' ');
|
||||
aBuffer.append(OUStringToOString(aContext.replace(' ', '_'), RTL_TEXTENCODING_UTF8));
|
||||
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_CHANGED, aBuffer.makeStringAndClear().getStr());
|
||||
OString aBuffer =
|
||||
OUStringToOString(aApplication.replace(' ', '_'), RTL_TEXTENCODING_UTF8) +
|
||||
" " +
|
||||
OUStringToOString(aContext.replace(' ', '_'), RTL_TEXTENCODING_UTF8);
|
||||
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_CHANGED, aBuffer.getStr());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -891,21 +891,16 @@ UUIInteractionHelper::getInteractionHandlerList(
|
||||
// Iterate over children.
|
||||
for ( const auto& rElem : aElems )
|
||||
{
|
||||
OUStringBuffer aElemBuffer;
|
||||
aElemBuffer.append( "['" );
|
||||
aElemBuffer.append( rElem );
|
||||
|
||||
try
|
||||
{
|
||||
InteractionHandlerData aInfo;
|
||||
|
||||
// Obtain service name.
|
||||
OUStringBuffer aKeyBuffer = aElemBuffer;
|
||||
aKeyBuffer.append( "']/ServiceName" );
|
||||
OUString aKeyBuffer = "['" + rElem + "']/ServiceName";
|
||||
|
||||
OUString aValue;
|
||||
if ( !( xHierNameAccess->getByHierarchicalName(
|
||||
aKeyBuffer.makeStringAndClear() ) >>= aValue ) )
|
||||
aKeyBuffer ) >>= aValue ) )
|
||||
{
|
||||
OSL_FAIL( "GetInteractionHandlerList - "
|
||||
"Error getting item value!" );
|
||||
|
@@ -254,10 +254,10 @@ IMPL_LINK_NOARG( MyWin, SelectHdl, ListBox&, void)
|
||||
if( nPos == -1 )
|
||||
return;
|
||||
|
||||
OStringBuffer aCommand( 64 );
|
||||
aCommand.append( "get " );
|
||||
aCommand.append( OUStringToOString( aEntry.copy( nPos+2 ), RTL_TEXTENCODING_ASCII_US ) );
|
||||
OString aAnswer( processCommand( aCommand.makeStringAndClear() ) );
|
||||
OString aCommand =
|
||||
"get " +
|
||||
OUStringToOString( aEntry.copy( nPos+2 ), RTL_TEXTENCODING_ASCII_US );
|
||||
OString aAnswer( processCommand( aCommand ) );
|
||||
SvMemoryStream aStream( aAnswer.getLength() );
|
||||
aStream.WriteBytes( aAnswer.getStr(), aAnswer.getLength() );
|
||||
aStream.Seek( STREAM_SEEK_TO_BEGIN );
|
||||
|
Reference in New Issue
Block a user