Avoid loplugin:unusedmember crash for templated offsetof

Change-Id: I6cbac308d2911a502381067398d72136ca2b5ae3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149045
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2023-03-17 09:58:21 +01:00
parent f5bfc127dd
commit f0ff4243d4
2 changed files with 33 additions and 0 deletions

View File

@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <cstddef>
namespace Enum
{
namespace
@ -223,6 +225,31 @@ void f()
}
}
namespace Offsetof
{
namespace
{
struct S
{
int i;
};
}
void f() { (void)offsetof(S, i); }
}
namespace OffsetofTemplate
{
namespace
{
template <typename> struct S
{
int i;
};
template <typename T> void f1() { (void)offsetof(T, i); }
}
void f() { f1<S<void>>(); }
}
int main()
{
(void)&Enum::f;
@ -233,6 +260,8 @@ int main()
(void)&Aligned::f;
(void)&Bases::f;
(void)&Unnamed::f;
(void)&Offsetof::f;
(void)&OffsetofTemplate::f;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -220,6 +220,10 @@ public:
return true;
}
auto const t1 = expr->getTypeSourceInfo()->getType();
if (t1->isTemplateTypeParmType())
{
return true;
}
RecordDecl const* d;
if (auto const t2 = t1->getAs<InjectedClassNameType>())
{