summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/toolslong.cxx17
-rw-r--r--sw/source/core/doc/doccomp.cxx3
2 files changed, 19 insertions, 1 deletions
diff --git a/compilerplugins/clang/toolslong.cxx b/compilerplugins/clang/toolslong.cxx
index 719b5b0caca5..b0d6a78d35ab 100644
--- a/compilerplugins/clang/toolslong.cxx
+++ b/compilerplugins/clang/toolslong.cxx
@@ -17,6 +17,8 @@
#include "clang/AST/Attr.h"
#include "clang/Basic/Builtins.h"
+#include "config_clang.h"
+
#include "check.hxx"
#include "compat.hxx"
#include "plugin.hxx"
@@ -32,6 +34,21 @@ bool isLong(QualType type)
// some parts of the STL have ::difference_type => long
if (type->getAs<AutoType>() || type->getAs<DecltypeType>())
return false;
+#if CLANG_VERSION < 80000
+ // Prior to <https://github.com/llvm/llvm-project/commit/
+ // c50240dac133451b3eae5b89cecca4c1c4af9fd4> "[AST] Get aliased type info from an aliased
+ // TemplateSpecialization" in Clang 8, if type is a TemplateSpecializationType on top of a
+ // TypedefType, the above getAs<TypedefType> returned null (as it unconditionally desugared the
+ // TemplateSpecializationType to the underlying canonic type, not to any aliased type), so re-
+ // check with the TemplateSpecializationType's aliased type:
+ if (auto const t = type->getAs<TemplateSpecializationType>())
+ {
+ if (t->isTypeAlias())
+ {
+ return isLong(t->getAliasedType());
+ }
+ }
+#endif
if (type->isSpecificBuiltinType(BuiltinType::Kind::Long))
return true;
auto arrayType = type->getAsArrayTypeUnsafe();
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 1b81e89ab4c8..cabd1ff97401 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -47,6 +47,7 @@
#include <cstddef>
#include <memory>
+#include <type_traits>
#include <vector>
using namespace ::com::sun::star;
@@ -829,7 +830,7 @@ void Compare::CompareSequence::Compare( sal_uLong nStt1, sal_uLong nEnd1,
/* Find a point of correspondence in the middle of the files. */
d = CheckDiag( nStt1, nEnd1, nStt2, nEnd2, &c );
- b = m_pBDiag[ d ];
+ b = m_pBDiag[ std::make_signed_t<decltype(d)>(d) ];
if( 1 != c )
{