From 66e5d2f492c44d912349c2b695389a2d1f9c0c81 Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 5 Oct 2018 14:34:50 +0200 Subject: [PATCH] Clang: Fix C++ method code completion Clang returns no result type when the virtual method from the base class is called in the same method override in the derived class. This is not a problem for us because it's not a method definition and therefore it does not require special handling. Change-Id: I736989165c1f031dc1937c7935e26da8236d9e9e Reviewed-by: hjk --- .../clangcodemodel/clangassistproposalitem.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/clangcodemodel/clangassistproposalitem.cpp b/src/plugins/clangcodemodel/clangassistproposalitem.cpp index 6b4d0b81629..ed15a006f66 100644 --- a/src/plugins/clangcodemodel/clangassistproposalitem.cpp +++ b/src/plugins/clangcodemodel/clangassistproposalitem.cpp @@ -210,11 +210,19 @@ void ClangAssistProposalItem::apply(TextDocumentManipulatorInterface &manipulato if (!abandonParen && ccr.completionKind == CodeCompletion::FunctionDefinitionCompletionKind) { const CodeCompletionChunk resultType = ccr.chunks.first(); - QTC_ASSERT(resultType.kind == CodeCompletionChunk::ResultType, return;); - if (::Utils::Text::matchPreviousWord(manipulator, cursor, resultType.text.toString())) { - extraCharacters += methodDefinitionParameters(ccr.chunks); - // To skip the next block. - abandonParen = true; + if (resultType.kind == CodeCompletionChunk::ResultType) { + if (::Utils::Text::matchPreviousWord(manipulator, cursor, resultType.text.toString())) { + extraCharacters += methodDefinitionParameters(ccr.chunks); + // To skip the next block. + abandonParen = true; + } + } else { + // Do nothing becasue it's not a function definition. + + // It's a clang bug that the function might miss a ResultType chunk + // when the base class method is called from the overriding method + // of the derived class. For example: + // void Derived::foo() override { Base:: } } } if (!abandonParen) {