From c23d33fc0afbc734faacf5a48d5ad493ac89ee02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 10 Jan 2020 18:13:47 +0100 Subject: [PATCH] Clang import; Fixed getSpelling() and getType() --- lib/clangimport.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) 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();