diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 495c62023..139c8bca4 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -236,13 +236,17 @@ namespace clangimport { std::string clangimport::AstNode::getSpelling() const { - if (mExtTokens.back() == "extern") - return mExtTokens[mExtTokens.size() - 3]; - if (mExtTokens[mExtTokens.size() - 2].compare(0,4,"col:") == 0) + int retTypeIndex = mExtTokens.size() - 1; + if (nodeType == FunctionDecl) { + while (mExtTokens[retTypeIndex][0] != '\'') + retTypeIndex--; + } + const std::string &str = mExtTokens[retTypeIndex - 1]; + if (str.compare(0,4,"col:") == 0) return ""; - if ((mExtTokens[mExtTokens.size() - 2].compare(0,8,"mSymbolDatabase; - const int nameIndex = (mExtTokens.back() == "extern") ? - (mExtTokens.size() - 3) : - (mExtTokens.size() - 2); - const int retTypeIndex = nameIndex + 1; - addTypeTokens(tokenList, mExtTokens[retTypeIndex]); - Token *nameToken = addtoken(tokenList, mExtTokens[nameIndex] + getTemplateParameters()); + addTypeTokens(tokenList, '\'' + getType() + '\''); + Token *nameToken = addtoken(tokenList, getSpelling() + getTemplateParameters()); Scope *nestedIn = const_cast(nameToken->scope()); symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); Scope &scope = symbolDatabase->scopeList.back();