loplugin:typedefparam: Work around different size_t typedefs on macOS

...which for me caused

> [CXX] registry/tools/options.cxx
> /Users/stephan/Software/lo/core/registry/tools/options.cxx:39:89: error: function param 3 at definition site does not match function param at declaration site, 'size_t' (aka 'unsigned long') vs 'size_t' (aka 'unsigned long') [loplugin:typedefparam]
> bool Options::checkArgument(std::vector< std::string> & rArgs, char const * arg, size_t len)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
> /Users/stephan/Software/lo/core/registry/tools/options.hxx:41:93: note: declaration site here [loplugin:typedefparam]
>     static bool checkArgument (std::vector< std::string > & rArgs, char const * arg, size_t len);
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

because one is

  TypedefType 0x115a4d700 'size_t' sugar
  |-Typedef 0x115a4d460 'size_t'
  `-BuiltinType 0x7fde8e0393c0 'unsigned long'

while the other is

  TypedefType 0x7fde8e94a3a0 'size_t' sugar
  |-Typedef 0x7fde8e94a138 'size_t'
  `-TypedefType 0x7fde8e94a100 '__darwin_size_t' sugar
    |-Typedef 0x7fde8e88cc28 '__darwin_size_t'
    `-BuiltinType 0x7fde8e0393c0 'unsigned long'

and

> [CXX] store/source/storcach.cxx
> /Users/stephan/Software/lo/core/store/source/storcach.cxx:218:43: error: function param 1 at definition site does not match function param at declaration site, 'std::size_t' (aka 'unsigned long') vs 'std::size_t' (aka 'unsigned long') [loplugin:typedefparam]
> void PageCache::rescale_Impl (std::size_t new_size)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
> /Users/stephan/Software/lo/core/store/source/storcach.hxx:67:36: note: declaration site here [loplugin:typedefparam]
>     void rescale_Impl (std::size_t new_size);
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

because one is

  ElaboratedType 0x116f5cba0 'std::size_t' sugar
  `-TypedefType 0x7fd58673e090 'size_t' sugar
    |-Typedef 0x7fd58673dde8 'size_t'
    `-BuiltinType 0x7fd58603cfc0 'unsigned long'

while the other is

  ElaboratedType 0x7fd586742200 'std::size_t' sugar
  `-TypedefType 0x7fd58621cdc0 'size_t' sugar
    |-Typedef 0x7fd5861ce4a0 'size_t'
    `-TypedefType 0x7fd5861cdc70 '__darwin_size_t' sugar
      |-Typedef 0x7fd586889ec8 '__darwin_size_t'
      `-BuiltinType 0x7fd58603cfc0 'unsigned long'

Change-Id: I3622716376198cc046b0489db59c5cbf613ea1f4
Reviewed-on: https://gerrit.libreoffice.org/73585
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx
index fd4d46f..0904e5f 100644
--- a/compilerplugins/clang/check.hxx
+++ b/compilerplugins/clang/check.hxx
@@ -33,6 +33,8 @@ class TypeCheck {
public:
    explicit TypeCheck(clang::QualType type): type_(type) {}

    explicit TypeCheck(clang::Type const * type): type_(type, 0) {}

    explicit TypeCheck(clang::TypeDecl const * decl): type_(decl->getTypeForDecl(), 0) {}

    explicit operator bool() const { return !type_.isNull(); }
diff --git a/compilerplugins/clang/typedefparam.cxx b/compilerplugins/clang/typedefparam.cxx
index 28e0a2d..60c413f 100644
--- a/compilerplugins/clang/typedefparam.cxx
+++ b/compilerplugins/clang/typedefparam.cxx
@@ -248,6 +248,30 @@ static bool areTypesEqual(QualType lhs, QualType rhs)
        // comparing the underlying Decl's here doesn't work, they are not unique
        if (lhsTypedef->getDecl()->getName() != rhsTypedef->getDecl()->getName())
            return false;
#if defined __APPLE__
        // My Clang trunk .../lib/clang/9.0.0/include/stddef.h has a
        //
        //   typedef long unsigned int size_t;
        //
        // while /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
        // SDKs/MacOSX10.14.sdk/usr/include/sys/_types/_size_t.h has a
        //
        //   typedef __darwin_size_t size_t;
        //
        // where __darwin_size_t is a typedef for long unsigned int, too, so that, depening on the
        // order in which those two files get inclued, either of those two typedefs can act as a
        // redeclaration of the other one.  However, areTypesEqual would unhelpfuly consider such
        // different occurrences of size_t to be non-equal, so filter them out here.  And, at least
        // with my libcxx trunk .../include/c++/v1/cstddef, std::size_t is a using declaration that
        // brings size_t from the global namespace into namespace std, so that the above checks for
        // ElaboratedType sugar will already have unwrapped those to the size_t typedefs in the
        // global namespace here.
        if (loplugin::TypeCheck(lhsTypedef).Typedef("size_t").GlobalNamespace()
            && loplugin::TypeCheck(rhsTypedef).Typedef("size_t").GlobalNamespace())
        {
            return true;
        }
#endif
        return areTypesEqual(lhsTypedef->desugar(), rhsTypedef->desugar());
    }
    if (auto lhsTemplate = dyn_cast<TemplateSpecializationType>(lhsType))