mardi 5 juillet 2016

Clang AST Visitor returns wrong data type when visiting variable declarations


Hello I have implemented an AST visitor using clang. It can correctly detect whenever a variable is declared, but sometimes it returns the wrong type for the variable. For example if a variable is declared as size_t or char32_t or even george it returns its type as int. My code is here:

virtual bool VisitVarDecl(VarDecl *var) 
{
    numVariables++;
    string varName = var->getQualifiedNameAsString();
    string varType = var->getType().getAsString();
    cout << "VisitVarDecl: " << varName << " of type " << varType << "n";        
    APIs << varType << ", ";
    return true;
}

Anyone knows why? I would like my code to identify any variable declaration but even with an imaginary type such as test i; george x; Thank you


Aucun commentaire:

Enregistrer un commentaire