Clang import; Fixed dead pointer

This commit is contained in:
Daniel Marjamäki 2020-04-12 22:41:35 +02:00
parent 82c09f243b
commit c99867421d
1 changed files with 8 additions and 4 deletions

View File

@ -1098,7 +1098,6 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
function->arg = par1; function->arg = par1;
function->token = nameToken; function->token = nameToken;
// Function arguments // Function arguments
function->argumentList.clear();
for (int i = 0; i < children.size(); ++i) { for (int i = 0; i < children.size(); ++i) {
AstNodePtr child = children[i]; AstNodePtr child = children[i];
if (child->nodeType != ParmVarDecl) if (child->nodeType != ParmVarDecl)
@ -1110,11 +1109,16 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
Token *vartok = nullptr; Token *vartok = nullptr;
if (!spelling.empty()) if (!spelling.empty())
vartok = child->addtoken(tokenList, spelling); vartok = child->addtoken(tokenList, spelling);
if (!prev) {
function->argumentList.push_back(Variable(vartok, child->getType(), nullptr, i, AccessControl::Argument, nullptr, scope)); function->argumentList.push_back(Variable(vartok, child->getType(), nullptr, i, AccessControl::Argument, nullptr, scope));
if (vartok) { if (vartok) {
const std::string addr = child->mExtTokens[0]; const std::string addr = child->mExtTokens[0];
mData->varDecl(addr, vartok, &function->argumentList.back()); mData->varDecl(addr, vartok, &function->argumentList.back());
} }
} else if (vartok) {
const std::string addr = child->mExtTokens[0];
mData->ref(addr, vartok);
}
} }
Token *par2 = addtoken(tokenList, ")"); Token *par2 = addtoken(tokenList, ")");
par1->link(par2); par1->link(par2);