diff options
author | Topi Reinio <topi.reinio@qt.io> | 2019-02-12 15:17:24 +0100 |
---|---|---|
committer | Topi Reiniƶ <topi.reinio@qt.io> | 2019-02-13 23:10:31 +0000 |
commit | 37a316be78278f33cfae027b55a7a854a898db10 (patch) | |
tree | 9b84fba7c3b93559e02dbb7b159fb78c5832a4f3 | |
parent | 064d81173cb52c2779686406ee7bd87fdda8301a (diff) | |
download | qttools-37a316be78278f33cfae027b55a7a854a898db10.tar.gz |
qdoc: Improve function overload handling
When QDoc calls Aggregate::normalizeOverloads(), process \internal
function nodes last. This ensures that they get assigned overload
numbers higher than the public ones, and adding internal overloads
no longer shuffle around the public HTML anchors (that are based on
the overload numbers).
Also, when searching for functions, ensure that we don't return an
\internal overload if a matching public one exists. This gets rid of
a number of linking warnings.
Change-Id: Idaac077e2f88d310e3261bf5b4c3df33ca02f873
Reviewed-by: Martin Smith <martin.smith@qt.io>
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/node.cpp | 39 |
2 files changed, 33 insertions, 8 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 91e3b78d8..cc077f440 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -591,7 +591,7 @@ void CppCodeParser::processMetaCommand(const Doc &doc, Note that this might set the overload flag of the primary function. This is ok because the overload flags and overload numbers will be resolved later - in resolveOverloadNumbers(). + in Aggregate::normalizeOverloads(). */ if (node->isFunction()) static_cast<FunctionNode*>(node)->setOverloadFlag(); diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index db9106d6e..a4bc2abff 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -1089,8 +1089,8 @@ Node* Aggregate::findNonfunctionChild(const QString& name, bool (Node::*isMatch) Find a function node that is a child of this node, such that the function node has the specified \a name and \a parameters. If \a parameters is empty but no matching function is found - that has no parameters, return the primary function whether - it has parameters or not. + that has no parameters, return the first non-internal primary + function or overload, whether it has parameters or not. */ FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters ¶meters) { @@ -1118,7 +1118,14 @@ FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters } fn = fn->nextOverload(); } - return parameters.isEmpty() ? i.value() : nullptr; + + if (parameters.isEmpty()) { + for (fn = i.value(); fn != nullptr; fn = fn->nextOverload()) + if (!fn->isInternal()) + return fn; + return i.value(); + } + return nullptr; } /*! @@ -1201,10 +1208,28 @@ void Aggregate::normalizeOverloads() } int count = 0; fn->setOverloadNumber(0); - fn = fn->nextOverload(); + FunctionNode *internalFn = nullptr; while (fn != nullptr) { - fn->setOverloadNumber(++count); - fn = fn->nextOverload(); + FunctionNode *next = fn->nextOverload(); + if (next) { + if (next->isInternal()) { + // internal overloads are moved to a separate list + // and processed last + fn->setNextOverload(next->nextOverload()); + next->setNextOverload(internalFn); + internalFn = next; + } else { + next->setOverloadNumber(++count); + } + fn = fn->nextOverload(); + } else { + fn->setNextOverload(internalFn); + break; + } + } + while (internalFn) { + internalFn->setOverloadNumber(++count); + internalFn = internalFn->nextOverload(); } ++i; // process next function in function map. } @@ -2370,7 +2395,7 @@ void FunctionNode::appendOverload(FunctionNode *fn) /*! This function assumes that this FunctionNode is marked as an - overlaod function. It asks if the next overload is marked as + overload function. It asks if the next overload is marked as an overload. If not, then remove that FunctionNode from the overload list and return it. Otherwise call this function recursively for the next overload. |