From 4dfb793cd2da1352d5ade395e5e384d29f4a6fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 12 Apr 2020 17:13:58 +0200 Subject: [PATCH] Clang import; Improved handling of constructor --- lib/clangimport.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 91bf99a05..943b6b995 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -632,15 +632,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) return par1; } if (nodeType == CXXConstructorDecl) { - bool hasBody = false; - for (AstNodePtr child: children) { - if (child->nodeType == CompoundStmt && !child->children.empty()) { - hasBody = true; - break; - } - } - if (hasBody) - createTokensFunctionDecl(tokenList); + createTokensFunctionDecl(tokenList); return nullptr; } if (nodeType == CXXDeleteExpr) { @@ -1065,13 +1057,16 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) const bool hasBody = mFile == 0 && !children.empty() && children.back()->nodeType == CompoundStmt; SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; - addTypeTokens(tokenList, '\'' + getType() + '\''); + if (nodeType != CXXConstructorDecl) + addTypeTokens(tokenList, '\'' + getType() + '\''); Token *nameToken = addtoken(tokenList, getSpelling() + getTemplateParameters()); Scope *nestedIn = const_cast(nameToken->scope()); if (!prev) { nestedIn->functionList.push_back(Function(nameToken)); mData->funcDecl(mExtTokens.front(), nameToken, &nestedIn->functionList.back()); + if (nodeType == CXXConstructorDecl) + nestedIn->functionList.back().type = Function::Type::eConstructor; } else { const std::string addr = *(std::find(mExtTokens.begin(), mExtTokens.end(), "prev") + 1); mData->ref(addr, nameToken); @@ -1091,6 +1086,9 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) } Token *par1 = addtoken(tokenList, "("); + if (!prev) + function->arg = par1; + function->token = nameToken; // Function arguments function->argumentList.clear(); for (int i = 0; i < children.size(); ++i) {