File 0001-QDoc-Adapt-clang-AST-QualTypeNames.h-to-breaking-cha.patch of Package qt6-tools
From d796c8138e53d567858e4197a7842efef553573b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
Date: Fri, 22 Aug 2025 20:05:08 +0200
Subject: [PATCH] QDoc: Adapt clang/AST/QualTypeNames.h to breaking change
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
For compatibility reasons, QDoc carries a custom implementation of
`llvm-project.git/clang/lib/AST/QualTypeNames.cpp`. When QDoc is built
against Clang libraries from LLVM 21, QDoc fails to compile with five
separate errors:
- no matching member function for call to
'getTemplateSpecializationType'
note: candidate function not viable: requires at most 3 arguments,
but 4 were provided
- enumeration value 'TypeSpecWithTemplate' not handled in switch
- no matching function for call to 'Create'
note: candidate function not viable: no known conversion from 'const
Type *' to 'const IdentifierInfo *'/'const NamespaceDecl *'/
'const NamespaceAliasDecl *' for 3rd argument
- no member named 'getQualifier' in 'clang::MemberPointerType
The issues relate to several changes upstream, notably commit
14f7bd63b95d0f61a6f47119ac66398ca230559a (see [0]).
This change addresses the issues by adapting QDoc's custom
implementation. The required changes are wrapped in preprocessor
conditionals to ensure correct behavior with LLVM versions prior to 21
as well as 21 and above. Consequentially, the change also adds 21.1 as a
supported Clang version for QDoc.
There is one case of output regression; the index file entry for
`QMediaMetaData::asKeyValueRange<const QHash<Key, QVariant>>` from
qtmultimedia.git and its signature in a list generated in qtdoc.git now
partly desugars `Key` by adding template argument qualification.
However, as this specific function is documented with an fn-command that
overrides the declared return type using `auto`, this is considered
acceptable and a matter to be addressed elsewhere.
[0] - https://github.com/llvm/llvm-project/pull/132401
Fixes: QTBUG-139407
Pick-to: 6.8
Change-Id: I2b1f88be27998eed6c03c9ebb068e21c6e9e3a17
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 4abaf0687ea2008a65e2d9d9c81792b2858dbc5e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c0cce3f50482df944a2e9434442b3d1237026e85)
---
src/qdoc/cmake/QDocConfiguration.cmake | 2 +-
.../qdoc/src/qdoc/clang/AST/QualTypeNames.h | 27 +++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/qdoc/cmake/QDocConfiguration.cmake b/src/qdoc/cmake/QDocConfiguration.cmake
index b4ea6d5a0..8f627b199 100644
--- a/src/qdoc/cmake/QDocConfiguration.cmake
+++ b/src/qdoc/cmake/QDocConfiguration.cmake
@@ -8,6 +8,6 @@ set(QDOC_MINIMUM_CLANG_VERSION "17")
# List of explicitly supported Clang versions for QDoc
set(QDOC_SUPPORTED_CLANG_VERSIONS
- "20.1" "19.1" "18.1" "17.0"
+ "21.1" "20.1" "19.1" "18.1" "17.0"
)
diff --git a/src/qdoc/qdoc/src/qdoc/clang/AST/QualTypeNames.h b/src/qdoc/qdoc/src/qdoc/clang/AST/QualTypeNames.h
index 29a9250de..977859911 100644
--- a/src/qdoc/qdoc/src/qdoc/clang/AST/QualTypeNames.h
+++ b/src/qdoc/qdoc/src/qdoc/clang/AST/QualTypeNames.h
@@ -25,6 +25,7 @@ QT_WARNING_DISABLE_MSVC(4267)
#include "clang/AST/DeclarationName.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Mangle.h"
+#include "clang/Basic/Version.h"
QT_WARNING_POP
@@ -160,9 +161,15 @@ static inline const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
// If a fully qualified arg is different from the unqualified arg,
// allocate new type in the AST.
if (MightHaveChanged) {
+#if CLANG_VERSION_MAJOR >= 21
+ QualType QT = Ctx.getTemplateSpecializationType(
+ TST->getTemplateName(), FQArgs, /*CanonicalArgs=*/{},
+ TST->getCanonicalTypeInternal());
+#else
QualType QT = Ctx.getTemplateSpecializationType(
TST->getTemplateName(), FQArgs,
TST->getCanonicalTypeInternal());
+#endif
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
// it.
@@ -192,9 +199,15 @@ static inline const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
// allocate new type in the AST.
if (MightHaveChanged) {
TemplateName TN(TSTDecl->getSpecializedTemplate());
+#if CLANG_VERSION_MAJOR >= 21
+ QualType QT = Ctx.getTemplateSpecializationType(
+ TN, FQArgs, /*CanonicalArgs=*/{},
+ TSTRecord->getCanonicalTypeInternal());
+#else
QualType QT = Ctx.getTemplateSpecializationType(
TN, FQArgs,
TSTRecord->getCanonicalTypeInternal());
+#endif
// getTemplateSpecializationType returns a fully qualified
// version of the specialization itself, so no need to qualify
// it.
@@ -257,7 +270,10 @@ static inline NestedNameSpecifier *getFullyQualifiedNestedNameSpecifier(
Ctx, Scope->getPrefix(), WithGlobalNsPrefix);
case NestedNameSpecifier::Super:
case NestedNameSpecifier::TypeSpec:
- case NestedNameSpecifier::TypeSpecWithTemplate: {
+#if CLANG_VERSION_MAJOR < 21
+ case NestedNameSpecifier::TypeSpecWithTemplate:
+#endif
+ {
const Type *Type = Scope->getAsType();
// Find decl context.
const TagDecl *TD = nullptr;
@@ -369,7 +385,10 @@ inline NestedNameSpecifier *createNestedNameSpecifier(const ASTContext &Ctx,
return NestedNameSpecifier::Create(
Ctx, createOuterNNS(Ctx, TD, FullyQualify, WithGlobalNsPrefix),
- false /*No TemplateKeyword*/, TypePtr);
+#if CLANG_VERSION_MAJOR < 21
+ false /*No TemplateKeyword*/,
+#endif
+ TypePtr);
}
/// Return the fully qualified type, including fully-qualified
@@ -393,9 +412,13 @@ inline QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
Qualifiers Quals = QT.getQualifiers();
// Fully qualify the pointee and class types.
QT = getFullyQualifiedType(QT->getPointeeType(), Ctx, WithGlobalNsPrefix);
+#if CLANG_VERSION_MAJOR >= 21
+ QT = Ctx.getMemberPointerType(QT, MPT->getQualifier(), MPT->getMostRecentCXXRecordDecl());
+#else
QualType Class = getFullyQualifiedType(QualType(MPT->getClass(), 0), Ctx,
WithGlobalNsPrefix);
QT = Ctx.getMemberPointerType(QT, Class.getTypePtr());
+#endif
// Add back the qualifiers.
QT = Ctx.getQualifiedType(QT, Quals);
return QT;
--
2.51.0