Clang import; parse clang ast type with ValueType::parseDecl
This commit is contained in:
parent
ba244be2d6
commit
abc51afcf1
|
@ -136,6 +136,7 @@ namespace clangimport {
|
||||||
Variable *var;
|
Variable *var;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Settings *mSettings = nullptr;
|
||||||
SymbolDatabase *mSymbolDatabase = nullptr;
|
SymbolDatabase *mSymbolDatabase = nullptr;
|
||||||
|
|
||||||
void varDecl(const std::string &addr, Token *def, Variable *var) {
|
void varDecl(const std::string &addr, Token *def, Variable *var) {
|
||||||
|
@ -143,7 +144,7 @@ namespace clangimport {
|
||||||
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
|
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
|
||||||
def->varId(++mVarId);
|
def->varId(++mVarId);
|
||||||
def->variable(var);
|
def->variable(var);
|
||||||
var->setValueType(ValueType(ValueType::Sign::SIGNED, ValueType::Type::INT, 0));
|
var->setValueType(*def->valueType());
|
||||||
notFound(addr);
|
notFound(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,25 +387,9 @@ void clangimport::AstNode::setValueType(Token *tok)
|
||||||
TokenList decl(nullptr);
|
TokenList decl(nullptr);
|
||||||
addTypeTokens(&decl, type);
|
addTypeTokens(&decl, type);
|
||||||
|
|
||||||
if (Token::simpleMatch(decl.front(), "bool"))
|
ValueType valueType = ValueType::parseDecl(decl.front(), mData->mSettings);
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::UNSIGNED, ValueType::Type::BOOL, 0));
|
if (valueType.type != ValueType::Type::UNKNOWN_TYPE)
|
||||||
else if (Token::simpleMatch(decl.front(), "int"))
|
tok->setValueType(new ValueType(valueType.sign, valueType.type, valueType.pointer, valueType.constness));
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::SIGNED, ValueType::Type::INT, 0));
|
|
||||||
else if (Token::simpleMatch(decl.front(), "unsigned long"))
|
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::UNSIGNED, ValueType::Type::LONG, 0));
|
|
||||||
else if (Token::simpleMatch(decl.front(), "__int128"))
|
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::SIGNED, ValueType::Type::UNKNOWN_INT, 0));
|
|
||||||
else if (tok->isNumber())
|
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::SIGNED, ValueType::Type::INT, 0));
|
|
||||||
else if (tok->tokType() == Token::Type::eChar)
|
|
||||||
// TODO
|
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::SIGNED, ValueType::Type::CHAR, 0));
|
|
||||||
else if (tok->tokType() == Token::Type::eString)
|
|
||||||
// TODO
|
|
||||||
tok->setValueType(new ValueType(ValueType::Sign::SIGNED, ValueType::Type::CHAR, 1));
|
|
||||||
else {
|
|
||||||
//decl.front()->printOut("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode)
|
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode)
|
||||||
|
@ -881,6 +866,7 @@ void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f)
|
||||||
symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal;
|
symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal;
|
||||||
|
|
||||||
clangimport::Data data;
|
clangimport::Data data;
|
||||||
|
data.mSettings = tokenizer->getSettings();
|
||||||
data.mSymbolDatabase = symbolDatabase;
|
data.mSymbolDatabase = symbolDatabase;
|
||||||
std::string line;
|
std::string line;
|
||||||
std::vector<AstNodePtr> tree;
|
std::vector<AstNodePtr> tree;
|
||||||
|
|
Loading…
Reference in New Issue