We recently met a bug in QDoc (https://bugreports.qt.io/browse/QTBUG-94365 [this is a reopened old bug, so only the recent comments are relevant]) where we encountered a series of CXError_ASTReadError during the normal processing of our documentation.
QDoc currently uses libclang to parse C++ files to extract and verify our documentation.
On Clang 15.x releases, we started noticing a series of CXError_ASTReadError when parsing many of the source files in the Qt codebase.
Those errors do not seem to appear on Clang 12/13/14.x and neither on the current development branch.
Furthermore, the issue appears to be platform-independent.
"'qHash' has different definitions in different modules; defined here first difference is 1st parameter with name"
QDoc generates a single PCH, trough clang_saveTranslationUnit, for all of headers of the module it is parsing, later including it trough --include-pch when parsing a source file.
Compiling without including the PCH seems to avoid the issue.
Similarly, QDoc compiles with the C++20 standard. When a C++17 standard is enforced, the issue is not encountered.
Bisecting seems to show that the issue originated between 14.x and 15.x at https://reviews.llvm.org/D120812 and is later generally present in 15.x, albeit disappearing on certain heads.
For example, it is not present at 3e7350f3173b02b3c77917100b2228f1964c55c6 / https://reviews.llvm.org/D128695.
We unfortunately were not able to produce a minimum project to replicate the issue.
We couldn't directly pinpoint to what is generating the error, nor are we entirely sure that this does not stem from some errors on our side.
We supposed this might be a bug as this only currently happens on Clang 15.x.
We recently met a bug in QDoc (https://bugreports.qt.io/browse/QTBUG-94365 [this is a reopened old bug, so only the recent comments are relevant]) where we encountered a series of
CXError_ASTReadError
during the normal processing of our documentation.QDoc currently uses libclang to parse C++ files to extract and verify our documentation.
On Clang 15.x releases, we started noticing a series of
CXError_ASTReadError
when parsing many of the source files in the Qt codebase.Those errors do not seem to appear on Clang 12/13/14.x and neither on the current development branch. Furthermore, the issue appears to be platform-independent.
The
CXError_ASTReadError
seems to be generated as a result of libclang incurring in ODR violations in qtbase/src/corelib/tools/qhashfunction.h, for example:"'qHash' has different definitions in different modules; defined here first difference is 1st parameter with name"
QDoc generates a single PCH, trough
clang_saveTranslationUnit
, for all of headers of the module it is parsing, later including it trough--include-pch
when parsing a source file. Compiling without including the PCH seems to avoid the issue.Similarly, QDoc compiles with the C++20 standard. When a C++17 standard is enforced, the issue is not encountered.
Bisecting seems to show that the issue originated between 14.x and 15.x at https://reviews.llvm.org/D120812 and is later generally present in 15.x, albeit disappearing on certain heads. For example, it is not present at 3e7350f3173b02b3c77917100b2228f1964c55c6 / https://reviews.llvm.org/D128695.
We unfortunately were not able to produce a minimum project to replicate the issue.
We couldn't directly pinpoint to what is generating the error, nor are we entirely sure that this does not stem from some errors on our side. We supposed this might be a bug as this only currently happens on Clang 15.x.