summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-07-14 10:13:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-07-14 14:04:09 +0200
commit905559f3f45991a0538912c1ca77199aa52fc7cf (patch)
tree5bde73441ad061df51f54085b61df70837638775 /compilerplugins
parentdcded5774c02da6528cf2ff97b13a531c7cf6813 (diff)
Adapt to Clang 15 trunk increase in ElabortatedType sugar
...<https://github.com/llvm/llvm-project/commit/bdc6974f92304f4ed542241b9b89ba58ba6b20aa> "[clang] Implement ElaboratedType sugaring for types written bare". For one, it caused diagnostics to now emit 'OString' instead of 'rtl::OUString' etc., which required adapting a number of tests. For another, some tests started to fail because the relevant plugins didn't expect ElaboratedType sugar in places where it now occurs: > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/redundantcast.cxx Line 297: redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast] > File compilerplugins/clang/test/redundantcast.cxx Line 308: redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast] > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/referencecasting.cxx Line 25 (directive at compilerplugins/clang/test/referencecasting.cxx:24): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 37 (directive at compilerplugins/clang/test/referencecasting.cxx:36): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 48 (directive at compilerplugins/clang/test/referencecasting.cxx:47): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 100 (directive at compilerplugins/clang/test/referencecasting.cxx:99): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 120 (directive at compilerplugins/clang/test/referencecasting.cxx:119): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 188 (directive at compilerplugins/clang/test/referencecasting.cxx:187): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 200 (directive at compilerplugins/clang/test/referencecasting.cxx:199): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > File compilerplugins/clang/test/referencecasting.cxx Line 206 (directive at compilerplugins/clang/test/referencecasting.cxx:205): the source reference is already a subtype of the destination reference, just use = [loplugin:referencecasting] > error: 'error' diagnostics seen but not expected: > File compilerplugins/clang/test/typedefparam.cxx Line 42: function param 1 at definition site does not match function param at declaration site, 'FooT *' (aka 'test2::Foo *') vs 'struct Foo *' [loplugin:typedefparam] > File compilerplugins/clang/test/typedefparam.cxx Line 55: function param 1 at definition site does not match function param at declaration site, 'FooT *' (aka 'test3::Foo *') vs 'Foo *' [loplugin:typedefparam] > error: 'note' diagnostics seen but not expected: > File compilerplugins/clang/test/typedefparam.cxx Line 40: declaration site here [loplugin:typedefparam] > File compilerplugins/clang/test/typedefparam.cxx Line 53: declaration site here [loplugin:typedefparam] Hopefully, there are not too many places in our plugins left that similarly don't expect ElaboratedType sugar in certain places, but which are not covered by tests. At least, a full build didn't turn up any further false positives, but there may of course be false negatives now that would go undetected. Change-Id: I9bfb1cfb57df5f6e228b512c19c664d48285b675 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137049 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/redundantcast.cxx9
-rw-r--r--compilerplugins/clang/referencecasting.cxx2
-rw-r--r--compilerplugins/clang/test/cppunitassertequals.cxx8
-rw-r--r--compilerplugins/clang/test/elidestringvar.cxx12
-rw-r--r--compilerplugins/clang/test/getstr.cxx8
-rw-r--r--compilerplugins/clang/test/redundantfcast.cxx10
-rw-r--r--compilerplugins/clang/test/stringadd.cxx10
-rw-r--r--compilerplugins/clang/test/stringliteralvar.cxx20
-rw-r--r--compilerplugins/clang/test/stringview.cxx46
-rw-r--r--compilerplugins/clang/test/stringviewparam.cxx14
-rw-r--r--compilerplugins/clang/test/stringviewvar.cxx8
-rw-r--r--compilerplugins/clang/typedefparam.cxx2
12 files changed, 78 insertions, 71 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 87c4d14458fd..b95a742cb2a2 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -66,6 +66,13 @@ char const * printExprValueKind(ExprValueKind k) {
llvm_unreachable("unknown ExprValueKind");
}
+QualType desugarElaboratedType(QualType type) {
+ if (auto const t = dyn_cast<ElaboratedType>(type)) {
+ return t->desugar();
+ }
+ return type;
+}
+
enum class AlgebraicType { None, Integer, FloatingPoint };
AlgebraicType algebraicType(clang::Type const & type) {
@@ -320,7 +327,7 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
if (auto templateType = dyn_cast<SubstTemplateTypeParmType>(t1)) {
t1 = templateType->desugar();
}
- if (t1 != t2) {
+ if (desugarElaboratedType(t1) != desugarElaboratedType(t2)) {
return true;
}
if (!t1->isBuiltinType() && !loplugin::TypeCheck(t1).Enum() && !loplugin::TypeCheck(t1).Typedef()) {
diff --git a/compilerplugins/clang/referencecasting.cxx b/compilerplugins/clang/referencecasting.cxx
index 08895f723920..dae0ce89d81f 100644
--- a/compilerplugins/clang/referencecasting.cxx
+++ b/compilerplugins/clang/referencecasting.cxx
@@ -132,7 +132,7 @@ bool ReferenceCasting::VisitCXXConstructExpr(const CXXConstructExpr* cce)
// ignore the up-casting constructor, which has a std::enable_if second parameter
if (isUnoReference && cce->getNumArgs() == 2
- && !isa<EnumType>(cce->getConstructor()->getParamDecl(1)->getType()))
+ && !cce->getConstructor()->getParamDecl(1)->getType()->isEnumeralType())
return true;
// extract the type parameter passed to the template
diff --git a/compilerplugins/clang/test/cppunitassertequals.cxx b/compilerplugins/clang/test/cppunitassertequals.cxx
index 48bea83f6088..05d814c855c2 100644
--- a/compilerplugins/clang/test/cppunitassertequals.cxx
+++ b/compilerplugins/clang/test/cppunitassertequals.cxx
@@ -36,12 +36,12 @@ void test(
CPPUNIT_ASSERT(!(b1 == b2));
CPPUNIT_ASSERT(!!(b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT_MESSAGE("", b1 == b2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL_MESSAGE when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
- CPPUNIT_ASSERT(s1 == s2); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
+ CPPUNIT_ASSERT(s1 == s2); // expected-error-re {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const {{(rtl::)?}}OUString' and 'const {{(rtl::)?}}OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT(s1 != s2);
- CPPUNIT_ASSERT((s1 == s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
- CPPUNIT_ASSERT(!(s1 != s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator != call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
+ CPPUNIT_ASSERT((s1 == s2)); // expected-error-re {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const {{(rtl::)?}}OUString' and 'const {{(rtl::)?}}OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
+ CPPUNIT_ASSERT(!(s1 != s2)); // expected-error-re {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const {{(rtl::)?}}OUString' and 'const {{(rtl::)?}}OUString' (or rewrite as an explicit operator != call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
CPPUNIT_ASSERT(!(s1 == s2));
- CPPUNIT_ASSERT(!!(s1 == s2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const rtl::OUString' and 'const rtl::OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
+ CPPUNIT_ASSERT(!!(s1 == s2)); // expected-error-re {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'const {{(rtl::)?}}OUString' and 'const {{(rtl::)?}}OUString' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
TEST1; // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
TEST2(CPPUNIT_ASSERT(b1 == b2)); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
TEST2(TEST1); // expected-error {{rather call CPPUNIT_ASSERT_EQUAL when comparing 'bool' and 'bool' (or rewrite as an explicit operator == call when the operator itself is the topic) [loplugin:cppunitassertequals]}}
diff --git a/compilerplugins/clang/test/elidestringvar.cxx b/compilerplugins/clang/test/elidestringvar.cxx
index 0b21644724a4..913bfbc2ae03 100644
--- a/compilerplugins/clang/test/elidestringvar.cxx
+++ b/compilerplugins/clang/test/elidestringvar.cxx
@@ -15,12 +15,12 @@ template <sal_Unicode C> OUString f(sal_Unicode c, int n)
{
OUString s0(C);
OUString s1(c);
- // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
+ // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
OUString s2('a');
- // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
+ // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
OUString s3(u'a');
static constexpr OUStringLiteral s4lit(u"a");
- // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
+ // expected-note-re@+1 {{literal '{{(rtl::)?}}OUString' variable defined here [loplugin:elidestringvar]}}
OUString s4 = s4lit;
switch (n)
{
@@ -29,13 +29,13 @@ template <sal_Unicode C> OUString f(sal_Unicode c, int n)
case 1:
return s1;
case 2:
- // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
+ // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
return s2;
case 3:
- // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
+ // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
return s3;
default:
- // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
+ // expected-error-re@+1 {{replace single use of literal '{{(rtl::)?}}OUString' variable with a literal [loplugin:elidestringvar]}}
return s4;
}
}
diff --git a/compilerplugins/clang/test/getstr.cxx b/compilerplugins/clang/test/getstr.cxx
index 976d39c25c71..7522458c7011 100644
--- a/compilerplugins/clang/test/getstr.cxx
+++ b/compilerplugins/clang/test/getstr.cxx
@@ -37,11 +37,11 @@ void f(std::ostream& st, OString const& s1, OStringBuffer const& s2,
OString* p1, OStringBuffer* p2, OUString* p3[[maybe_unused]],
OUStringBuffer* p4[[maybe_unused]], S* p5, char const* (OString::*pf)() const)
{
- st << s1.getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
+ st << s1.getStr() // expected-error-re {{directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
<< s2.getStr()
#if !HAVE_DELETED_OPERATORS
- << s3.getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUString'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}}
- << s4.getStr() // expected-error {{suspicious use of 'getStr' on an object of type 'rtl::OUStringBuffer'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}}
+ << s3.getStr() // expected-error-re {{suspicious use of 'getStr' on an object of type '{{(rtl::)?}}OUString'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}}
+ << s4.getStr() // expected-error-re {{suspicious use of 'getStr' on an object of type '{{(rtl::)?}}OUStringBuffer'; the result is implicitly cast to a void pointer in a call of 'operator <<' [loplugin:getstr]}}
#endif
<< s5.getStr() // expected-error {{directly use object of type 'S' (aka 'rtl::OString') in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
<< p1->getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
@@ -52,7 +52,7 @@ void f(std::ostream& st, OString const& s1, OStringBuffer const& s2,
#endif
<< p5->getStr() // expected-error {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
<< (s1.*pf)();
- SAL_INFO( // expected-error 1+ {{directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
+ SAL_INFO( // expected-error-re 1+ {{directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr]}}
"test", s1.getStr());
}
diff --git a/compilerplugins/clang/test/redundantfcast.cxx b/compilerplugins/clang/test/redundantfcast.cxx
index 20c939cb2b42..a477e48f5308 100644
--- a/compilerplugins/clang/test/redundantfcast.cxx
+++ b/compilerplugins/clang/test/redundantfcast.cxx
@@ -44,23 +44,23 @@ int main()
{
OUString s;
(void)OUString(
- s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
+ s); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
using T1 = OUString;
(void)T1(
- s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:redundantfcast]}}
+ s); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to 'T1' (aka '{{(rtl::)?}}OUString') [loplugin:redundantfcast]}}
using T2 = OUString const;
(void)T2(
- s); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'T2' (aka 'const rtl::OUString') [loplugin:redundantfcast]}}
+ s); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to 'T2' (aka 'const {{(rtl::?)}}OUString') [loplugin:redundantfcast]}}
(void)std::unique_ptr<int>(std::unique_ptr<int>(
new int{})); // expected-error@-1 {{redundant functional cast from 'std::unique_ptr<int>' to 'std::unique_ptr<int>' [loplugin:redundantfcast]}}
OUString s1;
method1(OUString(
- s1)); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
+ s1)); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
OUString s2;
s2 = OUString(
- s1); // expected-error@-1 {{redundant functional cast from 'rtl::OUString' to 'rtl::OUString' [loplugin:redundantfcast]}}
+ s1); // expected-error-re@-1 {{redundant functional cast from '{{(rtl::)?}}OUString' to '{{(rtl::)?}}OUString' [loplugin:redundantfcast]}}
(void)s2;
Color col1;
diff --git a/compilerplugins/clang/test/stringadd.cxx b/compilerplugins/clang/test/stringadd.cxx
index f76464b9a96d..6381d47f8baf 100644
--- a/compilerplugins/clang/test/stringadd.cxx
+++ b/compilerplugins/clang/test/stringadd.cxx
@@ -40,7 +40,7 @@ void f1(OUString s1, int i, OString o)
s2 += OUString::number(i);
// expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:stringadd]}}
s2 += XXX1;
- // expected-error-re@+2 {{rather use O[U]String::Concat than constructing 'rtl::OUStringLiteral<4>' from 'const char16_t{{ ?}}[4]' on LHS of + (where RHS is of type 'const char{{ ?}}[4]') [loplugin:stringadd]}}
+ // expected-error-re@+2 {{rather use O[U]String::Concat than constructing '{{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'rtl::OUStringLiteral<4>'\))?}} from 'const char16_t{{ ?}}[4]' on LHS of + (where RHS is of type 'const char{{ ?}}[4]') [loplugin:stringadd]}}
// expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:stringadd]}}
s2 += OUStringLiteral(XXX1u) + XXX2;
@@ -205,9 +205,9 @@ void f1(OUString s, OUString t, int i, const char* pChar)
{
// no warning expected
t = t + "xxx";
- // expected-error-re@+1 {{rather use O[U]String::Concat than constructing 'rtl::OUString' from 'const char{{ ?}}[4]' on RHS of + (where LHS is of type 'rtl::OUString') [loplugin:stringadd]}}
+ // expected-error-re@+1 {{rather use O[U]String::Concat than constructing '{{(rtl::)?}}OUString' from 'const char{{ ?}}[4]' on RHS of + (where LHS is of type '{{(rtl::)?}}OUString') [loplugin:stringadd]}}
s = s + OUString("xxx");
- // expected-error@+1 {{rather use O[U]String::Concat than constructing 'rtl::OUString' from 'const rtl::OUString' on RHS of + (where LHS is of type 'rtl::OUString') [loplugin:stringadd]}}
+ // expected-error-re@+1 {{rather use O[U]String::Concat than constructing '{{(rtl::)?}}OUString' from 'const {{(rtl::)?}}OUString' on RHS of + (where LHS is of type '{{(rtl::)?}}OUString') [loplugin:stringadd]}}
s = s + OUString(getByRef());
// no warning expected
@@ -229,9 +229,9 @@ void f1(OUString s, OUString t, int i, const char* pChar)
void f2(char ch)
{
OString s;
- // expected-error-re@+1 {{rather use O[U]String::Concat than constructing 'rtl::OString' from 'const char{{ ?}}[4]' on RHS of + (where LHS is of type 'rtl::OString') [loplugin:stringadd]}}
+ // expected-error-re@+1 {{rather use O[U]String::Concat than constructing '{{(rtl::)?}}OString' from 'const char{{ ?}}[4]' on RHS of + (where LHS is of type '{{(rtl::)?}}OString') [loplugin:stringadd]}}
s = s + OString("xxx");
- // expected-error@+1 {{rather use O[U]String::Concat than constructing 'rtl::OString' from 'char' on RHS of + (where LHS is of type 'rtl::OString') [loplugin:stringadd]}}
+ // expected-error-re@+1 {{rather use O[U]String::Concat than constructing '{{(rtl::)?}}OString' from 'char' on RHS of + (where LHS is of type '{{(rtl::)?}}OString') [loplugin:stringadd]}}
s = s + OString(ch);
}
}
diff --git a/compilerplugins/clang/test/stringliteralvar.cxx b/compilerplugins/clang/test/stringliteralvar.cxx
index 6e181be025a8..f04e54756284 100644
--- a/compilerplugins/clang/test/stringliteralvar.cxx
+++ b/compilerplugins/clang/test/stringliteralvar.cxx
@@ -18,7 +18,7 @@
char const literal1[] = "foo";
OString f1()
{
- // expected-note@+1 {{first passed into a 'rtl::OString' constructor here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OString' constructor here [loplugin:stringliteralvar]}}
return literal1;
}
@@ -27,7 +27,7 @@ void f2()
{
// expected-error-re@+1 {{change type of variable 'literal' from constant character array ('const char{{ ?}}[4]') to OUStringLiteral, and make it static [loplugin:stringliteralvar]}}
char const literal[] = "foo";
- // expected-note@+1 {{first passed into a 'rtl::OUString' constructor here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OUString' constructor here [loplugin:stringliteralvar]}}
f(literal);
}
@@ -38,7 +38,7 @@ struct S3
};
void f3()
{
- // expected-note@+1 {{first passed into a 'rtl::OUString' constructor here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OUString' constructor here [loplugin:stringliteralvar]}}
f(S3::literal);
}
@@ -52,17 +52,17 @@ std::vector<OUString> f4()
void f5()
{
- // expected-error@+1 {{variable 'literal' of type 'const rtl::OUStringLiteral<4>' with automatic storage duration most likely needs to be static [loplugin:stringliteralvar]}}
+ // expected-error-re@+1 {{variable 'literal' of type 'const {{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'const rtl::OUStringLiteral<4>'\))?}} with automatic storage duration most likely needs to be static [loplugin:stringliteralvar]}}
OUStringLiteral const literal = u"foo";
- // expected-note@+1 {{first converted to 'rtl::OUString' here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first converted to '{{(rtl::)?}}OUString' here [loplugin:stringliteralvar]}}
f(literal);
}
void f6()
{
- // expected-error@+1 {{variable 'literal' of type 'const rtl::OUStringLiteral<4>' with automatic storage duration most likely needs to be static [loplugin:stringliteralvar]}}
+ // expected-error-re@+1 {{variable 'literal' of type 'const {{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'const rtl::OUStringLiteral<4>'\))?}} with automatic storage duration most likely needs to be static [loplugin:stringliteralvar]}}
constexpr OUStringLiteral literal = u"foo";
- // expected-note@+1 {{first converted to 'rtl::OUString' here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first converted to '{{(rtl::)?}}OUString' here [loplugin:stringliteralvar]}}
f(literal);
}
@@ -75,7 +75,7 @@ void f7()
void f8()
{
static constexpr OUStringLiteral const literal = u"foo";
- // expected-error@+1 {{variable 'literal' of type 'const rtl::OUStringLiteral<4>' suspiciously used in a sizeof expression [loplugin:stringliteralvar]}}
+ // expected-error-re@+1 {{variable 'literal' of type 'const {{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'const rtl::OUStringLiteral<4>'\))?}} suspiciously used in a sizeof expression [loplugin:stringliteralvar]}}
(void)sizeof literal;
}
@@ -83,7 +83,7 @@ void f9()
{
// expected-error-re@+1 {{change type of variable 'literal' from constant character array ('const sal_Unicode{{ ?}}[3]'{{( \(aka 'const char16_t\[3\]'\))?}}) to OUStringLiteral [loplugin:stringliteralvar]}}
static sal_Unicode const literal[] = { 'f', 'o', 'o' };
- // expected-note@+1 {{first passed into a 'rtl::OUString' constructor here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OUString' constructor here [loplugin:stringliteralvar]}}
f(OUString(literal, SAL_N_ELEMENTS(literal)));
}
@@ -91,7 +91,7 @@ void f10()
{
// expected-error-re@+1 {{change type of variable 'literal' from constant character array ('const sal_Unicode{{ ?}}[3]'{{( \(aka 'const char16_t\[3\]'\))?}}) to OUStringLiteral [loplugin:stringliteralvar]}}
static sal_Unicode const literal[] = { 'f', 'o', 'o' };
- // expected-note@+1 {{first passed into a 'rtl::OUString' constructor here [loplugin:stringliteralvar]}}
+ // expected-note-re@+1 {{first passed into a '{{(rtl::)?}}OUString' constructor here [loplugin:stringliteralvar]}}
f(OUString(literal, 3));
}
diff --git a/compilerplugins/clang/test/stringview.cxx b/compilerplugins/clang/test/stringview.cxx
index 398f14b3dd12..a2b07501a49e 100644
--- a/compilerplugins/clang/test/stringview.cxx
+++ b/compilerplugins/clang/test/stringview.cxx
@@ -150,49 +150,49 @@ void f4(OUString s1, OUString s2)
void f5(char const* s1, sal_Int32 n1, char16_t const* s2, sal_Int32 n2, OString s3, OUString s4)
{
- // expected-error@+1 {{instead of an 'rtl::OString', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString());
- // expected-error-re@+1 {{instead of an 'rtl::OString' constructed from a 'const char{{ ?}}[4]', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char{{ ?}}[4]', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString("foo"));
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'const char', pass a 'std::string_view' (or an 'rtl::OStringChar') [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char', pass a 'std::string_view' (or an 'rtl::OStringChar') [loplugin:stringview]}}
call_view(OString(*s1));
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(s1));
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const char *', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(s1, n1));
constexpr OStringLiteral l1("foo");
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'const rtl::OStringLiteral<4>', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'const {{(rtl::)?}}OStringLiteral<4>'{{( \(aka 'const rtl::OStringLiteral<4>'\))?}}, pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(l1));
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'std::string_view' (aka 'basic_string_view<char>'), pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'std::string_view' (aka 'basic_string_view<char>'), pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(std::string_view("foo")));
- // expected-error@+1 {{instead of an 'rtl::OString' constructed from a 'OStringNumber<int>', pass a 'std::string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'OStringNumber<int>', pass a 'std::string_view' [loplugin:stringview]}}
call_view(OString(OString::number(0)));
- // expected-error-re@+1 {{instead of an 'rtl::OString' constructed from a 'typename std::enable_if_t<ToStringHelper<OString>::allowOStringConcat && ToStringHelper<OString>::allowOStringConcat, OStringConcat<OString, OString>{{ ?}}>' (aka 'rtl::OStringConcat<rtl::OString, rtl::OString>'), pass a 'std::string_view' via 'rtl::OStringConcatenation' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OString' constructed from a 'typename std::enable_if_t<ToStringHelper<OString>::allowOStringConcat && ToStringHelper<OString>::allowOStringConcat, OStringConcat<OString, OString>{{ ?}}>' (aka 'rtl::OStringConcat<rtl::OString, rtl::OString>'), pass a 'std::string_view' via 'rtl::OStringConcatenation' [loplugin:stringview]}}
call_view(OString(s3 + s3));
- // expected-error@+1 {{instead of an 'rtl::OUString', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString());
- // expected-error-re@+1 {{instead of an 'rtl::OUString' constructed from a 'const char{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString("foo"));
- // expected-error-re@+1 {{instead of an 'rtl::OUString' constructed from a 'const char16_t{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t{{ ?}}[4]', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(u"foo"));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const char', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
call_view(OUString(*s1));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const char16_t', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
call_view(OUString(*s2));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(s2));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(s2, n2));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const char16_t *', pass a 'std::u16string_view' (or an 'rtl::OUStringChar') [loplugin:stringview]}}
call_view(OUString(s2, 1));
constexpr OUStringLiteral l2(u"foo");
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'const rtl::OUStringLiteral<4>', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'const {{(rtl::)?}}OUStringLiteral<4>'{{( \(aka 'const rtl::OUStringLiteral<4>'\))?}}, pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(l2));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(std::u16string_view(u"foo")));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'OUStringNumber<int>', pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'OUStringNumber<int>', pass a 'std::u16string_view' [loplugin:stringview]}}
call_view(OUString(OUString::number(0)));
- // expected-error-re@+1 {{instead of an 'rtl::OUString' constructed from a 'typename std::enable_if_t<ToStringHelper<OUString>::allowOUStringConcat && ToStringHelper<OUString>::allowOUStringConcat, OUStringConcat<OUString, OUString>{{ ?}}>' (aka 'rtl::OUStringConcat<rtl::OUString, rtl::OUString>'), pass a 'std::u16string_view' via 'rtl::OUStringConcatenation' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'typename std::enable_if_t<ToStringHelper<OUString>::allowOUStringConcat && ToStringHelper<OUString>::allowOUStringConcat, OUStringConcat<OUString, OUString>{{ ?}}>' (aka 'rtl::OUStringConcat<rtl::OUString, rtl::OUString>'), pass a 'std::u16string_view' via 'rtl::OUStringConcatenation' [loplugin:stringview]}}
call_view(OUString(s4 + s4));
(void)(s3 == l1);
@@ -207,9 +207,9 @@ void f5(OUString s)
buf = s.copy(5);
// expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
buf.append(s.copy(12));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
buf.append(OUString(std::u16string_view(u"foo")));
- // expected-error@+1 {{instead of an 'rtl::OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
+ // expected-error-re@+1 {{instead of an '{{(rtl::)?}}OUString' constructed from a 'std::u16string_view' (aka 'basic_string_view<char16_t>'), pass a 'std::u16string_view' [loplugin:stringview]}}
s += OUString(std::u16string_view(u"foo"));
}
diff --git a/compilerplugins/clang/test/stringviewparam.cxx b/compilerplugins/clang/test/stringviewparam.cxx
index f5f165804490..78176fa096e3 100644
--- a/compilerplugins/clang/test/stringviewparam.cxx
+++ b/compilerplugins/clang/test/stringviewparam.cxx
@@ -19,7 +19,7 @@
#include "sal/types.h"
void f1a(std::string_view);
-// expected-error@+1 {{replace function parameter of type 'const rtl::OString &' with 'std::string_view' [loplugin:stringviewparam]}}
+// expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OString &' with 'std::string_view' [loplugin:stringviewparam]}}
char f1b(OString const& s)
{
f1a(s);
@@ -32,7 +32,7 @@ char f1b(OString const& s)
}
void f2a(std::u16string_view);
-// expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+// expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
sal_Unicode f2b(OUString const& s)
{
f2a(s);
@@ -56,19 +56,19 @@ template <> void f5<OUString>(OUString const&) {}
void f6([[maybe_unused]] OUString const&) {}
bool f7(
- // expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+ // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
const OUString& p1,
- // expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+ // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
const OUString& p2)
{
return p1 == p2;
}
-// expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+// expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
bool f8(const OUString& p1, std::u16string_view p2) { return p1 == p2; }
struct Converter
{
- // expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+ // expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
static bool convertBool(bool& rBool, const OUString& rString)
{
rBool = rString == "true";
@@ -88,7 +88,7 @@ struct S10
}
};
-// expected-error@+1 {{replace function parameter of type 'const rtl::OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
+// expected-error-re@+1 {{replace function parameter of type 'const {{(rtl::)?}}OUString &' with 'std::u16string_view' [loplugin:stringviewparam]}}
void f11(const OUString& f11rString)
{
OUStringBuffer buf;
diff --git a/compilerplugins/clang/test/stringviewvar.cxx b/compilerplugins/clang/test/stringviewvar.cxx
index 016f0fcc85a9..4f5a8fd3def7 100644
--- a/compilerplugins/clang/test/stringviewvar.cxx
+++ b/compilerplugins/clang/test/stringviewvar.cxx
@@ -18,7 +18,7 @@
void f1(std::string_view sv)
{
- // expected-error@+1 {{replace var of type 'rtl::OString' with 'std::string_view' [loplugin:stringviewvar]}}
+ // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
OString s1(sv);
(void)s1;
}
@@ -33,7 +33,7 @@ void f2(const OString s1)
std::string_view f3a();
void f3()
{
- // expected-error@+1 {{replace var of type 'rtl::OString' with 'std::string_view' [loplugin:stringviewvar]}}
+ // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
OString s1 = OString(f3a());
(void)s1;
}
@@ -48,7 +48,7 @@ void f4(std::string_view sv)
void f5(std::string_view sv)
{
- // expected-error@+1 {{replace var of type 'rtl::OString' with 'std::string_view' [loplugin:stringviewvar]}}
+ // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
OString s1(sv);
if (s1 == "xxxx")
f5(sv);
@@ -56,7 +56,7 @@ void f5(std::string_view sv)
void f6(std::u16string_view sv)
{
- // expected-error@+1 {{replace var of type 'rtl::OUString' with 'std::u16string_view' [loplugin:stringviewvar]}}
+ // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OUString' with 'std::u16string_view' [loplugin:stringviewvar]}}
OUString s6;
s6 = sv;
(void)s6;
diff --git a/compilerplugins/clang/typedefparam.cxx b/compilerplugins/clang/typedefparam.cxx
index b7e57b2a1b74..6fffe66c8483 100644
--- a/compilerplugins/clang/typedefparam.cxx
+++ b/compilerplugins/clang/typedefparam.cxx
@@ -189,7 +189,7 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
return dyn_cast<RecordType>(elaboratedType->desugar());
};
auto containsTypedefToRecord = [](clang::QualType type, RecordType const* recordType) {
- TypedefType const* typedefType = dyn_cast<TypedefType>(type);
+ TypedefType const* typedefType = type->getAs<TypedefType>();
if (!typedefType)
return false;
auto tmp = typedefType->desugar();