diff options
Diffstat (limited to 'tools/libclang/CXComment.cpp')
-rw-r--r-- | tools/libclang/CXComment.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index dfa782005b..4189b31446 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -256,7 +256,7 @@ unsigned clang_ParamCommandComment_isParamIndexValid(CXComment CXC) { unsigned clang_ParamCommandComment_getParamIndex(CXComment CXC) { const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC); - if (!PCC) + if (!PCC || !PCC->isParamIndexValid()) return ParamCommandComment::InvalidParamIndex; return PCC->getParamIndex(); @@ -316,11 +316,18 @@ namespace { class ParamCommandCommentCompareIndex { public: + /// This comparison will sort parameters with valid index by index and + /// invalid (unresolved) parameters last. bool operator()(const ParamCommandComment *LHS, const ParamCommandComment *RHS) const { - // To sort invalid (unresolved) parameters last, this comparison relies on - // invalid indices to be UINT_MAX. - return LHS->getParamIndex() < RHS->getParamIndex(); + unsigned LHSIndex = UINT_MAX; + unsigned RHSIndex = UINT_MAX; + if (LHS->isParamIndexValid()) + LHSIndex = LHS->getParamIndex(); + if (RHS->isParamIndexValid()) + RHSIndex = RHS->getParamIndex(); + + return LHSIndex < RHSIndex; } }; |