Clang import; Improved handling of constructor

This commit is contained in:
Daniel Marjamäki 2020-04-12 17:13:58 +02:00
parent 0d1a476b1f
commit 4dfb793cd2
1 changed files with 8 additions and 10 deletions

View File

@ -632,14 +632,6 @@ 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);
return nullptr;
}
@ -1065,6 +1057,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
const bool hasBody = mFile == 0 && !children.empty() && children.back()->nodeType == CompoundStmt;
SymbolDatabase *symbolDatabase = mData->mSymbolDatabase;
if (nodeType != CXXConstructorDecl)
addTypeTokens(tokenList, '\'' + getType() + '\'');
Token *nameToken = addtoken(tokenList, getSpelling() + getTemplateParameters());
Scope *nestedIn = const_cast<Scope *>(nameToken->scope());
@ -1072,6 +1065,8 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
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) {