summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-11-05 11:34:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-11-05 15:50:43 +0100
commite0a5a201d4170f4dac23a0e1aa8df18918549991 (patch)
treeb26840477e40f74b31fbdbe3e1c28691aec53ef9 /compilerplugins
parent327d1b012f1c3d33fc4160576d25bb57488fca7b (diff)
loplugin:stringconcatauto: There's no dangling-ref issue with O[U]StringNumber
...so it's unclear why 2f5f45921b05904a4be1ff633be09c62cb44ff08 "support O(U)String::number() for fast string concatenation" added that here. On the contrary, variables of type OStringNumber can be useful replacements for calls to std::sprintf (which started to emit deprecation warnings with macOS 13 SDK now), so this is in preparation for follow-up commits that will replace many uses of that across the code base with various alternatives. Change-Id: I6f8508d49dc84773c50f4c33dba38fe08c4c8969 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142318 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/stringconcatauto.cxx6
-rw-r--r--compilerplugins/clang/test/stringconcatauto.cxx18
2 files changed, 2 insertions, 22 deletions
diff --git a/compilerplugins/clang/stringconcatauto.cxx b/compilerplugins/clang/stringconcatauto.cxx
index f228f865c677..934556271b4f 100644
--- a/compilerplugins/clang/stringconcatauto.cxx
+++ b/compilerplugins/clang/stringconcatauto.cxx
@@ -85,12 +85,6 @@ bool StringConcatAuto::checkDecl( const DeclaratorDecl* decl, QualType type, con
const char* typeString = nullptr;
if( tc.Struct("StringConcat").Namespace("rtl").GlobalNamespace())
typeString = "O(U)String";
- else if( tc.Struct("StringNumberBase").Namespace("rtl").GlobalNamespace())
- typeString = "O(U)String";
- else if( tc.Struct("OUStringNumber").Namespace("rtl").GlobalNamespace())
- typeString = "OUString";
- else if( tc.Struct("OStringNumber").Namespace("rtl").GlobalNamespace())
- typeString = "OString";
else
return true;
report( DiagnosticsEngine::Warning,
diff --git a/compilerplugins/clang/test/stringconcatauto.cxx b/compilerplugins/clang/test/stringconcatauto.cxx
index 9fed0b83c75c..dde4211eaee4 100644
--- a/compilerplugins/clang/test/stringconcatauto.cxx
+++ b/compilerplugins/clang/test/stringconcatauto.cxx
@@ -24,11 +24,7 @@ void foo()
// expected-error-re@-1 {{creating a variable of type {{.+}} will make it reference temporaries}}
// expected-note@-2 {{use O(U)String instead}}
auto str5 = OUString::number(50);
- // expected-error-re@-1 {{creating a variable of type '{{(rtl::)?}}OUStringNumber<{{.*}}>' will make it reference temporaries}}
- // expected-note@-2 {{use OUString instead}}
auto str6 = OUString::number(50).toAsciiUpperCase();
- // expected-error-re@-1 {{creating a variable of type '{{(rtl::)?}}StringNumberBase<{{.*}}>' will make it reference temporaries}}
- // expected-note@-2 {{use O(U)String instead}}
(void)str1;
(void)str2;
(void)str3;
@@ -45,18 +41,8 @@ struct A
{
return "bar" + OString::number(110);
}
- auto baz()
- // expected-error-re@-1 {{returning a variable of type '{{(rtl::)?}}OStringNumber<{{.*}}>' will make it reference temporaries}}
- // expected-note@-2 {{use OString instead}}
- {
- return OString::number(120);
- }
- auto baz2()
- // expected-error-re@-1 {{returning a variable of type '{{(rtl::)?}}StringNumberBase<{{.*}}>' will make it reference temporaries}}
- // expected-note@-2 {{use O(U)String instead}}
- {
- return OString::number(120).toAsciiUpperCase();
- }
+ auto baz() { return OString::number(120); }
+ auto baz2() { return OString::number(120).toAsciiUpperCase(); }
};
template <typename T> void fun(const T& par)