From c99867421db5652aba45c8b2377c403cf2472218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 12 Apr 2020 22:41:35 +0200 Subject: [PATCH] Clang import; Fixed dead pointer --- lib/clangimport.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index d61eabed5..fa3da0b45 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -1098,7 +1098,6 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) function->arg = par1; function->token = nameToken; // Function arguments - function->argumentList.clear(); for (int i = 0; i < children.size(); ++i) { AstNodePtr child = children[i]; if (child->nodeType != ParmVarDecl) @@ -1110,10 +1109,15 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) Token *vartok = nullptr; if (!spelling.empty()) vartok = child->addtoken(tokenList, spelling); - function->argumentList.push_back(Variable(vartok, child->getType(), nullptr, i, AccessControl::Argument, nullptr, scope)); - if (vartok) { + if (!prev) { + function->argumentList.push_back(Variable(vartok, child->getType(), nullptr, i, AccessControl::Argument, nullptr, scope)); + if (vartok) { + const std::string addr = child->mExtTokens[0]; + mData->varDecl(addr, vartok, &function->argumentList.back()); + } + } else if (vartok) { const std::string addr = child->mExtTokens[0]; - mData->varDecl(addr, vartok, &function->argumentList.back()); + mData->ref(addr, vartok); } } Token *par2 = addtoken(tokenList, ")");