summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/bufferadd.cxx9
-rw-r--r--compilerplugins/clang/test/bufferadd.cxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_statement.cxx15
3 files changed, 20 insertions, 10 deletions
diff --git a/compilerplugins/clang/bufferadd.cxx b/compilerplugins/clang/bufferadd.cxx
index bc8c7065b2a1..cf2b6a011b4a 100644
--- a/compilerplugins/clang/bufferadd.cxx
+++ b/compilerplugins/clang/bufferadd.cxx
@@ -347,6 +347,15 @@ bool BufferAdd::isSideEffectFree(Expr const* expr)
if (isSideEffectFree(callExpr->getArg(0)))
return true;
}
+ // O[U]String::operator std::[u16]string_view:
+ if (auto const d = dyn_cast_or_null<CXXConversionDecl>(callExpr->getCalleeDecl()))
+ {
+ auto tc = loplugin::TypeCheck(d->getParent());
+ if (tc.Class("OString") || tc.Class("OUString"))
+ {
+ return true;
+ }
+ }
}
// sometimes we have a constructor call on the RHS
diff --git a/compilerplugins/clang/test/bufferadd.cxx b/compilerplugins/clang/test/bufferadd.cxx
index a9f28b13b55a..c8057a6f497b 100644
--- a/compilerplugins/clang/test/bufferadd.cxx
+++ b/compilerplugins/clang/test/bufferadd.cxx
@@ -52,6 +52,12 @@ void f5(OUStringBuffer& input)
OUStringBuffer v(input);
v.append("aaaa");
}
+void f6(OString const& s)
+{
+ // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
+ OUStringBuffer b("foo");
+ b.append(OStringToOUString(s, RTL_TEXTENCODING_ASCII_US));
+}
struct Footer
{
OStringBuffer m_descriptorStart;
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index 48fd7b062c8b..9fc87bc761c2 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -44,7 +44,6 @@
#include <osl/time.h>
#include <rtl/ustrbuf.hxx>
-#include <rtl/strbuf.hxx>
#include <comphelper/sequence.hxx>
@@ -456,15 +455,11 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data )
}
else if( !sourceTableKeys.empty() )
{
- OStringBuffer buf( 128 );
- buf.append( "can't support updateable resultset for table " );
- buf.append( OUStringToOString( schema, ConnectionSettings::encoding ) );
- buf.append( "." );
- buf.append( OUStringToOString( table, ConnectionSettings::encoding ) );
- buf.append( ", because resultset does not contain a part of the primary key ( column " );
- buf.append( OUStringToOString( sourceTableKeys[i], ConnectionSettings::encoding ) );
- buf.append( " is missing )" );
- aReason = buf.makeStringAndClear();
+ aReason = "can't support updateable resultset for table "
+ + OUStringToOString( schema, ConnectionSettings::encoding ) + "."
+ + OUStringToOString( table, ConnectionSettings::encoding )
+ + ", because resultset does not contain a part of the primary key ( column "
+ + OUStringToOString( sourceTableKeys[i], ConnectionSettings::encoding );
}
else
{