Clang import; Handle EnumDecl without children
This commit is contained in:
parent
5c02265041
commit
211d2e336d
|
@ -489,11 +489,14 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
|
||||||
scope->type = scopeType;
|
scope->type = scopeType;
|
||||||
scope->classDef = def;
|
scope->classDef = def;
|
||||||
scope->check = nestedIn->check;
|
scope->check = nestedIn->check;
|
||||||
|
if (!children.empty()) {
|
||||||
Token *bodyStart = children[0]->addtoken(tokenList, "{");
|
Token *bodyStart = children[0]->addtoken(tokenList, "{");
|
||||||
tokenList->back()->scope(scope);
|
tokenList->back()->scope(scope);
|
||||||
for (AstNodePtr astNode: children) {
|
for (AstNodePtr astNode: children) {
|
||||||
astNode->createTokens(tokenList);
|
astNode->createTokens(tokenList);
|
||||||
if (!Token::Match(tokenList->back(), "[;{}]"))
|
if (scopeType == Scope::ScopeType::eEnum)
|
||||||
|
astNode->addtoken(tokenList, ",");
|
||||||
|
else if (!Token::Match(tokenList->back(), "[;{}]"))
|
||||||
astNode->addtoken(tokenList, ";");
|
astNode->addtoken(tokenList, ";");
|
||||||
}
|
}
|
||||||
Token *bodyEnd = children.back()->addtoken(tokenList, "}");
|
Token *bodyEnd = children.back()->addtoken(tokenList, "}");
|
||||||
|
@ -501,6 +504,7 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
|
||||||
bodyEnd->link(bodyStart);
|
bodyEnd->link(bodyStart);
|
||||||
scope->bodyStart = bodyStart;
|
scope->bodyStart = bodyStart;
|
||||||
scope->bodyEnd = bodyEnd;
|
scope->bodyEnd = bodyEnd;
|
||||||
|
}
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,12 +773,8 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
|
||||||
Scope *enumscope = createScope(tokenList, Scope::ScopeType::eEnum, children, enumtok);
|
Scope *enumscope = createScope(tokenList, Scope::ScopeType::eEnum, children, enumtok);
|
||||||
if (nametok)
|
if (nametok)
|
||||||
enumscope->className = nametok->str();
|
enumscope->className = nametok->str();
|
||||||
for (Token *tok = enumtok; tok; tok = tok->next()) {
|
if (enumscope->bodyEnd && Token::simpleMatch(enumscope->bodyEnd->previous(), ", }"))
|
||||||
if (Token::simpleMatch(tok, "; }"))
|
const_cast<Token *>(enumscope->bodyEnd)->deletePrevious();
|
||||||
tok->deleteThis();
|
|
||||||
else if (tok->str() == ";")
|
|
||||||
tok->str(",");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create enum type
|
// Create enum type
|
||||||
mData->mSymbolDatabase->typeList.push_back(Type(enumtok, enumscope, enumtok->scope()));
|
mData->mSymbolDatabase->typeList.push_back(Type(enumtok, enumscope, enumtok->scope()));
|
||||||
|
|
Loading…
Reference in New Issue