From 54425fbd3de2911bf98a934423ec22e495e8424c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 6 Dec 2016 12:25:10 +0100 Subject: qdoc: fix resolve inheritance bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clangqdoc was unable to find base class nodes, when the base class node was in a different module from the subclass. This was mostly because the fixInheritance() function, which handles base class resolution after the headers have been parsed, was being called before the headers were parsed. This was caused by the new parsing strategy for clangqdoc, which is to use the old loop where qdoc used to parse the header files only to build up a list of all the required header files and to delay parsing the header files until clang is called to build the PCH. The basic fix is to mode the call to resolveInheritance() from main.cpp into clangcodeparser.cpp right after the PCH is built. There are also a few other minor changes in this change that make the base class resolution more robust by ensuring that as much useful information as possible is retained in the index file and in the base class list for a class node. Change-Id: I51433f618cdf40b37b0687ff1686da03359de111 Reviewed-by: Topi Reiniƶ --- src/qdoc/clangcodeparser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/qdoc/clangcodeparser.cpp') diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index f72896dfd..c7bb37120 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -416,9 +416,12 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l auto type = clang_getCursorType(cursor); auto baseCursor = clang_getTypeDeclaration(type); auto baseNode = findNodeForCursor(qdb_, baseCursor); - if (!baseNode || !baseNode->isClass()) - return CXChildVisit_Continue; auto classe = static_cast(parent_); + if (!baseNode || !baseNode->isClass()) { + QString bcName = fromCXString(clang_getCursorSpelling(baseCursor)); + classe->addUnresolvedBaseClass(access, QStringList(bcName), bcName); + return CXChildVisit_Continue; + } auto baseClasse = static_cast(baseNode); classe->addResolvedBaseClass(access, baseClasse); return CXChildVisit_Continue; @@ -1007,6 +1010,7 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin args.pop_back(); // remove the "-xc++"; } } + qdb_->resolveInheritance(); } args.clear(); args.insert(args.begin(), std::begin(defaultArgs), std::end(defaultArgs)); -- cgit v1.2.1