Adapt compilerplugins to recent Clang 16 trunk change

<https://github.com/llvm/llvm-project/commit/1acffe81ee9117691812b9bf8747c03354177d15>
"NFC: [clang] Template argument cleanups."

Change-Id: I84bc276c21efcc11643ae7003e0fee6c7592130f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141860
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2022-10-26 15:06:18 +02:00
parent 932423b8f3
commit 5baeba69bf
5 changed files with 44 additions and 23 deletions
+13
View File
@@ -162,6 +162,19 @@ inline clang::TemplateTypeParmDecl const * getReplacedParameter(
#endif
}
// Printing `std::size_t n` via `report(...) << n` is ambiguous prior to
// <https://github.com/llvm/llvm-project/commit/afdac5fbcb6a375245d435e4427086a376de59ff> "[clang]
// Allow printing 64 bit ints in diagnostics" (in Clang 14.x) and its follow-up
// <https://github.com/llvm/llvm-project/commit/ac7a9ef0ae3a5c63dc4e641f9912d8b659ebd720> "Resolve
// overload ambiguity on Mac OS when printing size_t in diagnostics" (in Clang 15.x):
inline
#if CLANG_VERSION >= 150000
std::size_t
#else
unsigned
#endif
diagnosticSize(std::size_t n) { return n; }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -1
View File
@@ -77,7 +77,8 @@ bool mentions(QualType type1, QualType type2)
}
if (auto const t2 = t1->getAs<TemplateSpecializationType>())
{
for (auto a = t2->begin(); a != t2->end(); ++a)
auto const args = t2->template_arguments();
for (auto a = args.begin(); a != args.end(); ++a)
{
if (a->getKind() != TemplateArgument::Type)
{
@@ -67,10 +67,11 @@ QualType reconstructTemplateArgumentType(
if (i == ps->end()) {
return {};
}
if (ps->size() != specializationType->getNumArgs()) { //TODO
auto const args = specializationType->template_arguments();
if (ps->size() != args.size()) { //TODO
return {};
}
TemplateArgument const & arg = specializationType->getArg(i - ps->begin());
TemplateArgument const & arg = args[i - ps->begin()];
if (arg.getKind() != TemplateArgument::Type) {
return {};
}
@@ -183,16 +184,17 @@ bool isBoolExpr(Expr const * expr) {
break;
}
auto const dc = loplugin::DeclCheck(d->getTemplatedDecl());
if (dc.ClassOrStruct("array").StdNamespace() && t->getNumArgs() >= 2
&& t->getArg(0).getKind() == TemplateArgument::Type)
auto const args = t->template_arguments();
if (dc.ClassOrStruct("array").StdNamespace() && args.size() >= 2
&& args[0].getKind() == TemplateArgument::Type)
{
ty = t->getArg(0).getAsType();
ty = args[0].getAsType();
} else if (dc.Class("Sequence").Namespace("uno").Namespace("star").Namespace("sun")
.Namespace("com").GlobalNamespace()
&& t->getNumArgs() == 1
&& t->getArg(0).getKind() == TemplateArgument::Type)
&& args.size() == 1
&& args[0].getKind() == TemplateArgument::Type)
{
ty = t->getArg(0).getAsType();
ty = args[0].getAsType();
} else {
break;
}
@@ -412,9 +414,10 @@ bool ImplicitBoolConversion::TraverseCXXMemberCallExpr(CXXMemberCallExpr * expr)
= ct->getTemplateName().getAsTemplateDecl();
if (td != nullptr) {
//TODO: fix this superficial nonsense check:
if (ct->getNumArgs() >= 1
&& ct->getArg(0).getKind() == TemplateArgument::Type
&& (loplugin::TypeCheck(ct->getArg(0).getAsType())
auto const args = ct->template_arguments();
if (args.size() >= 1
&& args[0].getKind() == TemplateArgument::Type
&& (loplugin::TypeCheck(args[0].getAsType())
.AnyBoolean()))
{
continue;
@@ -846,9 +849,10 @@ void ImplicitBoolConversion::checkCXXConstructExpr(
ps->begin(), ps->end(),
compat::getReplacedParameter(t2));
if (k != ps->end()) {
if (ps->size() == t1->getNumArgs()) { //TODO
TemplateArgument const & arg = t1->getArg(
k - ps->begin());
auto const args = t1->template_arguments();
if (ps->size() == args.size()) { //TODO
TemplateArgument const & arg = args[
k - ps->begin()];
if (arg.getKind() == TemplateArgument::Type
&& (loplugin::TypeCheck(arg.getAsType())
.AnyBoolean()))
@@ -870,8 +874,9 @@ void ImplicitBoolConversion::reportWarning(ImplicitCastExpr const * expr) {
if (expr->getCastKind() == CK_ConstructorConversion) {
auto const t1 = expr->getType();
if (auto const t2 = t1->getAs<TemplateSpecializationType>()) {
assert(t2->getNumArgs() >= 1);
auto const a = t2->getArg(0);
auto const args = t2->template_arguments();
assert(args.size() >= 1);
auto const a = args[0];
if (a.getKind() == TemplateArgument::Type && a.getAsType()->isBooleanType()
&& (loplugin::TypeCheck(t1).TemplateSpecializationClass()
.ClassOrStruct("atomic").StdNamespace()))
+5 -4
View File
@@ -230,18 +230,19 @@ public:
{
return false;
}
if (t2->getNumArgs() != 1)
auto const args = t2->template_arguments();
if (args.size() != 1)
{
if (isDebugMode())
{
report(DiagnosticsEngine::Fatal,
"TODO: unexpected std::function with %0 template arguments",
expr->getExprLoc())
<< t2->getNumArgs() << expr->getSourceRange();
<< compat::diagnosticSize(args.size()) << expr->getSourceRange();
}
return false;
}
if (t2->getArg(0).getKind() != TemplateArgument::Type)
if (args[0].getKind() != TemplateArgument::Type)
{
if (isDebugMode())
{
@@ -252,7 +253,7 @@ public:
}
return false;
}
target = t2->getArg(0).getAsType();
target = args[0].getAsType();
}
else
{
+3 -2
View File
@@ -518,9 +518,10 @@ static const RecordType* extractTemplateType(QualType cceType)
auto cceTST = dyn_cast<TemplateSpecializationType>(cceType);
if (!cceTST)
return NULL;
if (cceTST->getNumArgs() != 1)
auto const args = cceTST->template_arguments();
if (args.size() != 1)
return NULL;
const TemplateArgument& cceTA = cceTST->getArg(0);
const TemplateArgument& cceTA = args[0];
QualType templateParamType = cceTA.getAsType();
if (auto elaboratedType = dyn_cast<ElaboratedType>(templateParamType))
templateParamType = elaboratedType->desugar();